Skip to content

Commit

Permalink
<__msvc_int128.hpp>: Remove unnecessary common_type partial speci…
Browse files Browse the repository at this point in the history
…alizations (#3153)
  • Loading branch information
frederick-vs-ja committed Oct 24, 2022
1 parent e07c062 commit 032aae1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
32 changes: 0 additions & 32 deletions stl/inc/__msvc_int128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,22 +1026,6 @@ class numeric_limits<_Unsigned128> : public _Num_int_base {
static constexpr int digits10 = 38;
};

#ifdef __cpp_lib_concepts
template <integral _Ty>
struct common_type<_Ty, _Unsigned128> {
using type = _Unsigned128;
};
template <integral _Ty>
struct common_type<_Unsigned128, _Ty> {
using type = _Unsigned128;
};
#else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv
template <class _Ty>
struct common_type<_Ty, _Unsigned128> : enable_if<is_integral_v<_Ty>, _Unsigned128> {};
template <class _Ty>
struct common_type<_Unsigned128, _Ty> : enable_if<is_integral_v<_Ty>, _Unsigned128> {};
#endif // ^^^ !defined(__cpp_lib_concepts) ^^^

struct _Signed128 : _Base128 {
using _Signed_type = _Signed128;
using _Unsigned_type = _Unsigned128;
Expand Down Expand Up @@ -1427,22 +1411,6 @@ class numeric_limits<_Signed128> : public _Num_int_base {
static constexpr int digits10 = 38;
};

#ifdef __cpp_lib_concepts
template <integral _Ty>
struct common_type<_Ty, _Signed128> {
using type = _Signed128;
};
template <integral _Ty>
struct common_type<_Signed128, _Ty> {
using type = _Signed128;
};
#else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv
template <class _Ty>
struct common_type<_Ty, _Signed128> : enable_if<is_integral_v<_Ty>, _Signed128> {};
template <class _Ty>
struct common_type<_Signed128, _Ty> : enable_if<is_integral_v<_Ty>, _Signed128> {};
#endif // ^^^ !defined(__cpp_lib_concepts) ^^^

template <>
struct common_type<_Signed128, _Unsigned128> {
using type = _Unsigned128;
Expand Down
24 changes: 24 additions & 0 deletions tests/std/tests/P1522R1_difference_type/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ constexpr bool test_unsigned() {
STATIC_ASSERT(SAME_AS<std::common_type_t<_Unsigned128, unsigned long long>, _Unsigned128>);
STATIC_ASSERT(SAME_AS<std::common_type_t<_Unsigned128, _Signed128>, _Unsigned128>);

struct ConversionSource {
constexpr operator _Unsigned128() const {
return _Unsigned128{};
}
};
STATIC_ASSERT(SAME_AS<std::common_type_t<_Unsigned128, ConversionSource>, _Unsigned128>);

struct ConversionTarget {
constexpr ConversionTarget(_Unsigned128) {}
};
STATIC_ASSERT(SAME_AS<std::common_type_t<_Unsigned128, ConversionTarget>, ConversionTarget>);

#ifdef __cpp_lib_concepts // TRANSITION, GH-395
STATIC_ASSERT(std::_Integer_class<_Unsigned128>);
STATIC_ASSERT(std::_Integer_like<_Unsigned128>);
Expand Down Expand Up @@ -446,6 +458,18 @@ constexpr bool test_signed() {
STATIC_ASSERT(SAME_AS<std::common_type_t<_Signed128, long long>, _Signed128>);
STATIC_ASSERT(SAME_AS<std::common_type_t<_Signed128, unsigned long long>, _Signed128>);

struct ConversionSource {
constexpr operator _Signed128() const {
return _Signed128{};
}
};
STATIC_ASSERT(SAME_AS<std::common_type_t<_Signed128, ConversionSource>, _Signed128>);

struct ConversionTarget {
constexpr ConversionTarget(_Signed128) {}
};
STATIC_ASSERT(SAME_AS<std::common_type_t<_Signed128, ConversionTarget>, ConversionTarget>);

#ifdef __cpp_lib_concepts // TRANSITION, GH-395
STATIC_ASSERT(std::_Integer_class<_Signed128>);
STATIC_ASSERT(std::_Integer_like<_Signed128>);
Expand Down

0 comments on commit 032aae1

Please sign in to comment.