Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<__msvc_int128.hpp>: Remove unnecessary common_type partial specializations #3153

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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