Skip to content

Commit 03e07f6

Browse files
authored
compare_three_way_result : サンプルコードを動くように修正
1 parent f060ad2 commit 03e07f6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

reference/compare/compare_three_way_result.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,22 @@ namespace std {
4242
#include <type_traits>
4343
4444
template<typename T, typename Cat>
45-
using fallback_comp3way = std::conditional_t<std::three_way_comparable<T>, std::compare_three_way_result_t<T>, Cat>;
45+
struct fallback_comp3way {
46+
using type = Cat;
47+
};
48+
49+
template<std::three_way_comparable T, typename Cat>
50+
struct fallback_comp3way<T, Cat> {
51+
using type = std::compare_three_way_result_t<T>;
52+
};
4653
4754
template<typename T>
4855
struct wrap {
4956
T t;
5057
5158
//<=>を使用可能ならそれを、そうでないなら< ==を使ってdefault実装
5259
auto operator<=>(const wrap&) const
53-
-> fallback_comp3way<T, std::weak_ordering>
60+
-> fallback_comp3way<T, std::weak_ordering>::type
5461
= default;
5562
}
5663

0 commit comments

Comments
 (0)