PR libstdc++/89102 fix common_type<> and common_type<T> specializations
This is a partial implementation of the revised std::common_type rules from P0435R1. PR libstdc++/89102 (partial) * include/std/type_traits (common_type<>): Define. (common_type<T>): Derive from common_type<T, T>. * testsuite/20_util/common_type/requirements/explicit_instantiation.cc: Test zero-length template argument list. * testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc: Test additional single argument cases. * testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc: Adjust expected error. From-SVN: r268586
This commit is contained in:
parent
12f82acc9e
commit
373c726ec6
|
@ -1,3 +1,15 @@
|
|||
2019-02-06 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/89102 (partial)
|
||||
* include/std/type_traits (common_type<>): Define.
|
||||
(common_type<T>): Derive from common_type<T, T>.
|
||||
* testsuite/20_util/common_type/requirements/explicit_instantiation.cc:
|
||||
Test zero-length template argument list.
|
||||
* testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc:
|
||||
Test additional single argument cases.
|
||||
* testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc:
|
||||
Adjust expected error.
|
||||
|
||||
2019-02-05 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/89128
|
||||
|
|
|
@ -2132,9 +2132,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
struct __expanded_common_type_wrapper<__failure_type, _Args...>
|
||||
{ typedef __failure_type type; };
|
||||
|
||||
template<>
|
||||
struct common_type<>
|
||||
{ };
|
||||
|
||||
template<typename _Tp>
|
||||
struct common_type<_Tp>
|
||||
{ typedef typename decay<_Tp>::type type; };
|
||||
: common_type<_Tp, _Tp>
|
||||
{ };
|
||||
|
||||
template<typename _Tp, typename _Up>
|
||||
struct common_type<_Tp, _Up>
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace std
|
|||
typedef void test_type5;
|
||||
typedef const void test_type6;
|
||||
|
||||
template struct common_type<>;
|
||||
template struct common_type<test_type1>;
|
||||
template struct common_type<test_type1, test_type2>;
|
||||
template struct common_type<test_type1, test_type2, test_type3>;
|
||||
|
|
|
@ -159,7 +159,10 @@ namespace std {
|
|||
};
|
||||
}
|
||||
|
||||
static_assert(is_type<std::common_type<int>, int>(), "");
|
||||
static_assert(is_type<std::common_type<const int>, int>(), "");
|
||||
static_assert(is_type<std::common_type<int, int>, int>(), "");
|
||||
static_assert(is_type<std::common_type<const int, int>, int>(), "");
|
||||
static_assert(is_type<std::common_type<ScEn, ScEn>, ScEn>(), "");
|
||||
static_assert(is_type<std::common_type<UnscEn, UnscEn>, UnscEn>(), "");
|
||||
static_assert(is_type<std::common_type<UnscEn, int>, int>(), "");
|
||||
|
@ -180,6 +183,8 @@ static_assert(is_type<std::common_type<int*, const volatile int*>,
|
|||
const volatile int*>(), "");
|
||||
static_assert(is_type<std::common_type<void*, const volatile int*>,
|
||||
const volatile void*>(), "");
|
||||
static_assert(is_type<std::common_type<void>, void>(), "");
|
||||
static_assert(is_type<std::common_type<const void>, void>(), "");
|
||||
static_assert(is_type<std::common_type<void, void>, void>(), "");
|
||||
static_assert(is_type<std::common_type<const void, const void>, void>(), "");
|
||||
static_assert(is_type<std::common_type<int&, int&&>, int>(), "");
|
||||
|
@ -316,6 +321,14 @@ static_assert(!has_type<std::common_type<UConv1, Abstract&&>>(), "");
|
|||
static_assert(!has_type<std::common_type<std::initializer_list<int>,
|
||||
std::initializer_list<long>>>(), "");
|
||||
|
||||
// PR libstdc++/89102
|
||||
static_assert(!has_type<std::common_type<int() &>>(), "");
|
||||
static_assert(!has_type<std::common_type<int() & noexcept>>(), "");
|
||||
static_assert(!has_type<std::common_type<int() const>>(), "");
|
||||
static_assert(!has_type<std::common_type<int(...) &>>(), "");
|
||||
static_assert(!has_type<std::common_type<int(...) & noexcept>>(), "");
|
||||
static_assert(!has_type<std::common_type<int(...) const>>(), "");
|
||||
|
||||
void test(int i)
|
||||
{
|
||||
auto local_lmd1 = [=](int, double) { return i + i; };
|
||||
|
|
|
@ -25,7 +25,7 @@ template<typename... Args>
|
|||
constexpr
|
||||
std::array<typename std::common_type<Args...>::type,
|
||||
sizeof...(Args)>
|
||||
make_array(Args&&... args) // { dg-error "invalid use" }
|
||||
make_array(Args&&... args) // { dg-error "no type.*common_type<>" }
|
||||
{
|
||||
typedef typename std::common_type<Args...>::type CT;
|
||||
return std::array<CT, sizeof...(Args)>{static_cast<CT>
|
||||
|
|
Loading…
Reference in New Issue