diff --git a/reference/compare/compare_three_way_result.md b/reference/compare/compare_three_way_result.md index 60aac5dd54..8af93a5ed7 100644 --- a/reference/compare/compare_three_way_result.md +++ b/reference/compare/compare_three_way_result.md @@ -42,25 +42,19 @@ namespace std { #include template -struct fallback_comp3way { - using type = Cat; -}; - -template -struct fallback_comp3way { - using type = std::compare_three_way_result_t; -}; +using fallback_comp3way_t = std::conditional_t, std::compare_three_way_result, std::type_identity>::type; template struct wrap { T t; - //<=>を使用可能ならそれを、そうでないなら< ==を使ってdefault実装 + // <=>を使用可能ならそれを、そうでないなら< ==を使ってdefault実装 auto operator<=>(const wrap&) const - -> fallback_comp3way::type + -> fallback_comp3way_t = default; } +// <=>を定義しない型 struct no_spaceship { int n; @@ -85,6 +79,7 @@ int main() } ``` * compare_three_way_result_t[color ff0000] +* type_identity[link /reference/type_traits/type_identity.md] ### 出力 ```