diff options
author | Daniel Krugler <daniel.kruegler@googlemail.com> | 2012-10-09 22:31:44 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2012-10-09 22:31:44 +0000 |
commit | b3618b716790fec683f2f6aa14225e8a87a50f3b (patch) | |
tree | 8ed2608f34cbf269d7220c821624ef679371cc03 /libstdc++-v3/testsuite | |
parent | 71111e6b202aa01dc4b2ba50ee592c87f240ba7f (diff) | |
download | gcc-b3618b716790fec683f2f6aa14225e8a87a50f3b.zip gcc-b3618b716790fec683f2f6aa14225e8a87a50f3b.tar.gz gcc-b3618b716790fec683f2f6aa14225e8a87a50f3b.tar.bz2 |
type_traits (common_time): Provide "SFINAE-friendly" implementation.
2012-10-09 Daniel Krugler <daniel.kruegler@googlemail.com>
* include/std/type_traits (common_time): Provide "SFINAE-friendly"
implementation.
(__success_type, __failure_type): Fix.
* include/std/chrono (common_type): Likewise for the chrono::time_point
specialization.
* testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc: New.
* testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc:
Likewise.
* testsuite/20_util/duration/requirements/sfinae_friendly_1.cc:
Likewise.
* testsuite/20_util/common_type/requirements/typedefs-1.cc: Adjust wrt
LWG 2141.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Adjust
dg-error line numbers.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Likewise.
* testsuite/20_util/result_of/sfinae_friendly_1.cc: Trivial stylistic
tweaks.
* testsuite/20_util/result_of/sfinae_friendly_2.cc: Likewise.
From-SVN: r192276
Diffstat (limited to 'libstdc++-v3/testsuite')
12 files changed, 500 insertions, 38 deletions
diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc new file mode 100644 index 0000000..de7ca27 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc @@ -0,0 +1,341 @@ +// { dg-options "-std=c++11" } +// { dg-do compile } + +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <initializer_list> + +//TODO: Uncomment this once gcc bug 53000 has been resolved: +//#define HAS_53000_FIXED + +// Helper types: +struct has_type_impl +{ + template<typename T, typename = typename T::type> + static std::true_type test(int); + template<typename> + static std::false_type test(...); +}; + +template<typename T> +struct has_type : public decltype(has_type_impl::test<T>(0)) +{}; + +template<typename T, typename Expected> +struct is_expected_type : public std::is_same<typename T::type, Expected> +{}; + +template<typename P1, typename P2> +struct and_ : public std::conditional<P1::value, P2, std::false_type>::type +{}; + +template<typename T, typename Expected> +struct is_type : public and_<has_type<T>, is_expected_type<T, Expected>> +{}; + +// Inspection types: + +struct S {}; + +struct B {}; +struct D : B {}; + +struct F1 { operator void*(); }; +struct F2 { operator void*(); }; + +struct G1 { operator const void*(); }; +struct G2 { operator volatile void*(); }; + +template<typename T> +struct ImplicitTo +{ + operator T(); +}; + +template<typename T> +struct ExplicitTo +{ + explicit operator T(); +}; + +template<typename T> +struct PrivateImplicitTo +{ +private: + operator T(); +}; + +auto lmd1 = [](int, double) {}; +auto lmd2 = [](int, double) {}; + +struct Abstract +{ + virtual ~Abstract() = 0; +}; + +enum class ScEn; + +enum UnscEn : int; + +struct Ukn; + +union U +{ + int i; +}; + +union U2 +{ + long i; +}; + +union UConv1 +{ + operator Abstract*(); +}; + +union UConv2 +{ + operator Abstract*(); +}; + +struct X1 {}; +struct X2 {}; +struct RX12 {}; +struct RX21 {}; +struct Y1 {}; +struct Y2 {}; +struct Y3 {}; +struct Y4 {}; + +namespace std { + + template<> + struct common_type<X1, X2> + { + typedef RX12 type; + }; + + template<> + struct common_type<X2, X1> + { + typedef RX21 type; + }; + + template<> + struct common_type<RX12, X1> + { + typedef Y1 type; + }; + + template<> + struct common_type<X1, RX12> + { + typedef Y2 type; + }; + + template<> + struct common_type<RX21, X1> + { + typedef Y3 type; + }; + + template<> + struct common_type<X1, RX21> + { + typedef Y4 type; + }; +} + +static_assert(is_type<std::common_type<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<int, int>, int>(), ""); +static_assert(is_type<std::common_type<UnscEn, int>, int>(), ""); +static_assert(is_type<std::common_type<int, int, int>, int>(), ""); +static_assert(is_type<std::common_type<int, int, int, int>, int>(), ""); +static_assert(is_type<std::common_type<int, int, int, int, int>, int>(), ""); +static_assert(is_type<std::common_type<S, S>, S>(), ""); +static_assert(is_type<std::common_type<const S, const S>, S>(), ""); +static_assert(is_type<std::common_type<std::initializer_list<int>, + std::initializer_list<int>>, std::initializer_list<int>>(), ""); +static_assert(is_type<std::common_type<B, D>, B>(), ""); +static_assert(is_type<std::common_type<D, B>, B>(), ""); +static_assert(is_type<std::common_type<F1, F2>, void*>(), ""); +static_assert(is_type<std::common_type<F2, F1>, void*>(), ""); +static_assert(is_type<std::common_type<G1, G2>, const volatile void*>(), ""); +static_assert(is_type<std::common_type<G2, G1>, const volatile void*>(), ""); +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>, void>(), ""); +static_assert(is_type<std::common_type<const void, const void>, void>(), ""); +static_assert(is_type<std::common_type<int&, int&&>, int>(), ""); +static_assert(is_type<std::common_type<int&, int&>, int>(), ""); +static_assert(is_type<std::common_type<int&&, int&&>, int>(), ""); +static_assert(is_type<std::common_type<U&, const U&&>, U>(), ""); +static_assert(is_type<std::common_type<U&, U&>, U>(), ""); +static_assert(is_type<std::common_type<U&&, U&&>, U>(), ""); +static_assert(is_type<std::common_type<int B::*, int D::*>, int D::*>(), ""); +static_assert(is_type<std::common_type<int D::*, int B::*>, int D::*>(), ""); +static_assert(is_type<std::common_type<const int B::*, volatile int D::*>, + const volatile int D::*>(), ""); +static_assert(is_type<std::common_type<int (B::*)(), int (D::*)()>, + int (D::*)()>(), ""); +static_assert(is_type<std::common_type<int (B::*)() const, int (D::*)() const>, + int (D::*)() const>(), ""); +static_assert(is_type<std::common_type<int[3], int[3]>, int*>(), ""); +static_assert(is_type<std::common_type<int[1], const int[3]>, + const int*>(), ""); +static_assert(is_type<std::common_type<void(), void()>, void(*)()>(), ""); +static_assert(is_type<std::common_type<void(&)(), void(&)()>, void(*)()>(), ""); +static_assert(is_type<std::common_type<void(&)(), void(&&)()>, + void(*)()>(), ""); +static_assert(is_type<std::common_type<void(&&)(), void(&)()>, + void(*)()>(), ""); +static_assert(is_type<std::common_type<void(&&)(), void(&&)()>, + void(*)()>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<int>, int>, int>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<int>, ImplicitTo<int>>, + ImplicitTo<int>>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<int>, int, + ImplicitTo<int>>, int>(), ""); +static_assert(is_type<std::common_type<ExplicitTo<int>, ExplicitTo<int>>, + ExplicitTo<int>>(), ""); +static_assert(is_type<std::common_type<decltype(lmd1), decltype(lmd1)>, + decltype(lmd1)>(), ""); +static_assert(is_type<std::common_type<decltype(lmd1)&, decltype(lmd1)&>, + decltype(lmd1)>(), ""); +static_assert(is_type<std::common_type<decltype(lmd1)&, decltype(lmd2)&>, + void(*)(int, double)>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), void*>, void*>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), int*>, int*>(), ""); +static_assert(is_type<std::common_type<const decltype(nullptr)&, int*>, + int*>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), const volatile int*>, + const volatile int*>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), int (B::*)()>, + int (B::*)()>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), int (B::*)() const>, + int (B::*)() const>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), const int B::*>, + const int B::*>(), ""); +static_assert(is_type<std::common_type<Abstract&, Abstract&>, Abstract>(), ""); +static_assert(is_type<std::common_type<Ukn&, Ukn&>, Ukn>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<B&>, B&>, B>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<B&>&, B&&>, B>(), ""); +static_assert(is_type<std::common_type<UConv1, const Abstract*&>, + const Abstract*>(), ""); +static_assert(is_type<std::common_type<UConv1, UConv2>, Abstract*>(), ""); +static_assert(is_type<std::common_type<UConv1&, UConv2&>, Abstract*>(), ""); + +#ifdef HAS_53000_FIXED +static_assert(is_type<std::common_type<Abstract&&, Abstract&&>, + Abstract>(), ""); +static_assert(is_type<std::common_type<const Abstract&&, + volatile Abstract&&>, Abstract>(), ""); +static_assert(is_type<std::common_type<Ukn&&, Ukn&&>, Ukn>(), ""); +static_assert(is_type<std::common_type<const Ukn&&, volatile Ukn&&>, + Ukn>(), ""); +#endif + +static_assert(is_type<std::common_type<X1, X2>, RX12>(), ""); +static_assert(is_type<std::common_type<X2, X1>, RX21>(), ""); + +static_assert(is_type<std::common_type<X1, X2, X1>, Y1>(), ""); +static_assert(is_type<std::common_type<X2, X1, X1>, Y3>(), ""); + +static_assert(is_type<std::common_type<X1, X1, X2>, RX12>(), ""); +static_assert(is_type<std::common_type<X1, X1, X2, X1>, Y1>(), ""); + +static_assert(!has_type<std::common_type<>>(), ""); +static_assert(!has_type<std::common_type<int, S>>(), ""); +static_assert(!has_type<std::common_type<U, S>>(), ""); +static_assert(!has_type<std::common_type<U, U2>>(), ""); +static_assert(!has_type<std::common_type<const ImplicitTo<int>, int>>(), ""); +static_assert(!has_type<std::common_type<PrivateImplicitTo<int>, int>>(), ""); +static_assert(!has_type<std::common_type<const PrivateImplicitTo<int>, + int>>(), ""); +static_assert(!has_type<std::common_type<int, Ukn>>(), ""); +static_assert(!has_type<std::common_type<int, Abstract>>(), ""); +static_assert(!has_type<std::common_type<Ukn, Abstract>>(), ""); +static_assert(!has_type<std::common_type<int, void>>(), ""); +static_assert(!has_type<std::common_type<int, const volatile void>>(), ""); +static_assert(!has_type<std::common_type<Abstract, void>>(), ""); +static_assert(!has_type<std::common_type<Ukn, void>>(), ""); +static_assert(!has_type<std::common_type<int[4], void>>(), ""); +static_assert(!has_type<std::common_type<ScEn, void>>(), ""); +static_assert(!has_type<std::common_type<UnscEn, void>>(), ""); +static_assert(!has_type<std::common_type<U, void>>(), ""); +static_assert(!has_type<std::common_type<std::initializer_list<int>, + void>>(), ""); +static_assert(!has_type<std::common_type<int, int, int, S>>(), ""); +static_assert(!has_type<std::common_type<int, int, S, int>>(), ""); +static_assert(!has_type<std::common_type<int, S, int, int>>(), ""); +static_assert(!has_type<std::common_type<S, int, int, int>>(), ""); +static_assert(!has_type<std::common_type<int, int, void, int, int>>(), ""); +static_assert(!has_type<std::common_type<B, S>>(), ""); +static_assert(!has_type<std::common_type<int, B, S>>(), ""); +static_assert(!has_type<std::common_type<B, int, S>>(), ""); +static_assert(!has_type<std::common_type<B, S, int>>(), ""); +static_assert(!has_type<std::common_type<int*, double*>>(), ""); +static_assert(!has_type<std::common_type<void*, void(*)(...)>>(), ""); +static_assert(!has_type<std::common_type<void(*)(), void(*)(...)>>(), ""); +static_assert(!has_type<std::common_type<void(*)(), void(S::*)()>>(), ""); +static_assert(!has_type<std::common_type<void(S::*)() const, + void(S::*)()>>(), ""); +static_assert(!has_type<std::common_type<int S::*, long S::*>>(), ""); +static_assert(!has_type<std::common_type<int S::*, void(S::*)()>>(), ""); +static_assert(!has_type<std::common_type<int (B::*)(), + int (D::*)() const>>(), ""); +static_assert(!has_type<std::common_type<int (B::*)() const, + int (D::*)()>>(), ""); +static_assert(!has_type<std::common_type<int, ExplicitTo<int>>>(), ""); +static_assert(!has_type<std::common_type<ImplicitTo<int>, + ExplicitTo<int>>>(), ""); +static_assert(!has_type<std::common_type<ScEn, int>>(), ""); +static_assert(!has_type<std::common_type<ScEn, UnscEn>>(), ""); +static_assert(!has_type<std::common_type<U, S, Abstract, void, D, + int (B::*)(), int[5]>>(), ""); +static_assert(!has_type<std::common_type<UConv1, Abstract&&>>(), ""); +static_assert(!has_type<std::common_type<std::initializer_list<int>, + std::initializer_list<long>>>(), ""); + +void test(int i) +{ + auto local_lmd1 = [=](int, double) { return i + i; }; + auto local_lmd2 = [=](int, double) { return i - i; }; + + static_assert(is_type<std::common_type<decltype(local_lmd1), + decltype(local_lmd1)>, decltype(local_lmd1)>(), ""); + static_assert(is_type<std::common_type<decltype(local_lmd1)&, + decltype(local_lmd1)>, decltype(local_lmd1)>(), ""); + static_assert(is_type<std::common_type<decltype(local_lmd1)&, + decltype(local_lmd1)&>, decltype(local_lmd1)>(), ""); + + static_assert(!has_type<std::common_type<decltype(local_lmd1), + decltype(lmd1)>>(), ""); + static_assert(!has_type<std::common_type<decltype(local_lmd1)&, + decltype(lmd1)&>>(), ""); + static_assert(!has_type<std::common_type<decltype(local_lmd1), + decltype(local_lmd2)>>(), ""); + static_assert(!has_type<std::common_type<decltype(local_lmd1)&, + decltype(local_lmd2)&>>(), ""); +} diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc new file mode 100644 index 0000000..e4d4fa0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=c++11" } +// { dg-do compile } + +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <array> +#include <utility> + +template<typename... Args> +constexpr +std::array<typename std::common_type<Args...>::type, sizeof...(Args)> +make_array(Args&&... args) // { dg-error "invalid use" } +{ + typedef typename std::common_type<Args...>::type CT; + return std::array<CT, sizeof...(Args)>{static_cast<CT> + (std::forward<Args>(args))...}; +} + +void test01() +{ + constexpr auto a1 = make_array(0); + constexpr auto a2 = make_array(0, 1.2); + constexpr auto a3 = make_array(5, true, 3.1415f, 'c'); + + static_assert(std::is_same<decltype(a1), const std::array<int, 1>>(), ""); + static_assert(std::is_same<decltype(a2), const std::array<double, 2>>(), ""); + static_assert(std::is_same<decltype(a3), const std::array<float, 4>>(), ""); +} + +void test02() +{ + make_array(); // { dg-error "no matching function" } +} +// { dg-prune-output "substitution" } +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc index 94469d9..2d6babe 100644 --- a/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc @@ -1,6 +1,6 @@ // { dg-options "-std=gnu++0x" } // -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -105,7 +105,7 @@ void test02() COMMON_TYPE_TEST_ALL_2(int, int, int, 1); COMMON_TYPE_TEST_ALL_2(int, double, double, 2); COMMON_TYPE_TEST_2(NO_CV, A, A, A, 3); - COMMON_TYPE_TEST_2(const, A, A, const A, 4); + COMMON_TYPE_TEST_2(const, A, A, A, 4); COMMON_TYPE_TEST_2(NO_CV, B, A, A, 5); } diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc index 6b9a4cb..91d3553 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-error "static assertion failed" "" { target *-*-* } 1812 } +// { dg-error "static assertion failed" "" { target *-*-* } 1869 } #include <utility> diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc new file mode 100644 index 0000000..48b0197 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=c++11" } +// { dg-do compile } + +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <chrono> + +// Helper types: +struct has_type_impl +{ + template<typename T, typename = typename T::type> + static std::true_type test(int); + template<typename> + static std::false_type test(...); +}; + +template<typename T> +struct has_type : public decltype(has_type_impl::test<T>(0)) +{}; + +template<typename T, typename Expected> +struct is_expected_type : public std::is_same<typename T::type, Expected> +{}; + +template<typename P1, typename P2> +struct and_ : public std::conditional<P1::value, P2, std::false_type>::type +{}; + +template<typename T, typename Expected> +struct is_type : public and_<has_type<T>, is_expected_type<T, Expected>> +{}; + +// Inspection types: + +typedef std::chrono::duration<int, std::nano> din; +typedef std::chrono::duration<double, std::nano> ddn; +typedef std::chrono::duration<int, std::milli> dim; + +static_assert(is_type<std::common_type<din, din>, din>(), ""); +static_assert(is_type<std::common_type<din, din, din>, din>(), ""); + +static_assert(is_type<std::common_type<din, ddn>, ddn>(), ""); +static_assert(is_type<std::common_type<din, din, ddn>, ddn>(), ""); +static_assert(is_type<std::common_type<din, ddn>, ddn>(), ""); +static_assert(is_type<std::common_type<ddn, din, din>, ddn>(), ""); + +static_assert(!has_type<std::common_type<din, int>>(), ""); +static_assert(!has_type<std::common_type<din, din, int>>(), ""); +static_assert(!has_type<std::common_type<int, din, din>>(), ""); + diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc index a3671b0..d127d21 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc @@ -3,7 +3,7 @@ // { dg-require-cstdint "" } // 2008-07-31 Chris Fairles <chris.fairles@gmail.com> -// Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2008-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -31,5 +31,5 @@ void test01() test_type d; } -// { dg-error "rep cannot be a duration" "" { target *-*-* } 225 } +// { dg-error "rep cannot be a duration" "" { target *-*-* } 245 } // { dg-error "required from here" "" { target *-*-* } 31 } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc index 17d24e5..f4e4501 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc @@ -3,7 +3,7 @@ // { dg-require-cstdint "" } // 2008-07-31 Chris Fairles <chris.fairles@gmail.com> -// Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2008-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -32,5 +32,5 @@ void test01() test_type d; // { dg-error "required from here" } } -// { dg-error "must be a specialization of ratio" "" { target *-*-* } 226 } +// { dg-error "must be a specialization of ratio" "" { target *-*-* } 246 } // { dg-prune-output "not a member" } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc index 4b2df49..113cda8 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc @@ -3,7 +3,7 @@ // { dg-require-cstdint "" } // 2008-07-31 Chris Fairles <chris.fairles@gmail.com> -// Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2008-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -33,5 +33,5 @@ void test01() test_type d; } -// { dg-error "period must be positive" "" { target *-*-* } 228 } +// { dg-error "period must be positive" "" { target *-*-* } 248 } // { dg-error "required from here" "" { target *-*-* } 33 } diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index 3f1d33b..b0b8111 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1601 } -// { dg-error "declaration of" "" { target *-*-* } 1565 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1613 } +// { dg-error "declaration of" "" { target *-*-* } 1577 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index b13200e..8f4cf24 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1519 } -// { dg-error "declaration of" "" { target *-*-* } 1483 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1531 } +// { dg-error "declaration of" "" { target *-*-* } 1495 } diff --git a/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc b/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc index 3ea9e60..b70c85b9 100644 --- a/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc +++ b/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc @@ -29,23 +29,27 @@ // Helper types: struct has_type_impl { - template<class T, class = typename T::type> + template<typename T, typename = typename T::type> static std::true_type test(int); - template<class> + template<typename> static std::false_type test(...); }; -template<class T> -struct has_type : decltype(has_type_impl::test<T>(0)) +template<typename T> +struct has_type : public decltype(has_type_impl::test<T>(0)) {}; -template<class T, class Res> -struct is_expected_type : std::is_same<typename T::type, Res> +template<typename T, typename Res> +struct is_expected_type : public std::is_same<typename T::type, Res> {}; -template<class T, class Res> -struct is_type : std::__and_<has_type<T>, is_expected_type<T, Res>> +template<typename P1, typename P2> +struct and_ : public std::conditional<P1::value, P2, std::false_type>::type +{}; + +template<typename T, typename Res> +struct is_type : public and_<has_type<T>, is_expected_type<T, Res>> {}; // Types under inspection: @@ -76,18 +80,18 @@ typedef void (B::*base_func_void)() const; typedef bool (B::*base_func_bool_int)(int) const volatile; struct ident_functor { - template<class T> + template<typename T> T operator()(T&& x); }; -template<class Ret = void> +template<typename Ret = void> struct variable_functor { - template<class... T> + template<typename... T> Ret operator()(T&&...); }; struct ident_functor_noref { - template<class T> + template<typename T> typename std::remove_reference<T>::type operator()(T&& x); }; @@ -136,26 +140,26 @@ public: bool operator()(std::nullptr_t); }; -template<class T> +template<typename T> struct ImplicitTo { operator T(); }; -template<class> +template<typename> struct never { static const bool value = false; }; -template<class T> +template<typename T> struct BrokenTrait { static_assert(never<T>::value, "Error!"); typedef T type; }; -template<class T> +template<typename T> struct BadSmartPtr : T { T& operator*() const noexcept(typename BrokenTrait<T>::type()); }; -template<class Ret> +template<typename Ret> using FuncEllipses = Ret(...); static_assert(is_type<std::result_of<S(int)>, short>::value, "Error!"); diff --git a/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_2.cc b/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_2.cc index 57dcc5f..d566c93 100644 --- a/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_2.cc +++ b/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_2.cc @@ -23,16 +23,16 @@ #include <type_traits> #include <string> -struct eat { template<class T> eat(T const &) {} }; +struct eat { template<typename T> eat(T const &) {} }; struct not_incrementable {}; struct inc { - template<class T> + template<typename T> auto operator()(T t) const -> decltype(t++) { return t++; } }; -template<class A> +template<typename A> typename std::result_of<inc(A)>::type // sfinae here try_inc(A a) { return inc()(a); @@ -43,10 +43,10 @@ try_inc(eat) { return not_incrementable(); } -template<class> +template<typename> struct never { static const bool value = false; }; -template<class T> +template<typename T> struct Fail { static_assert(never<T>::value, "duh"); @@ -55,16 +55,16 @@ struct Fail struct Fun { - template<class T> + template<typename T> typename Fail<T>::type operator()(T) { return 0; } }; -template<class T> +template<typename T> typename std::result_of<Fun(T)>::type foo(T) { return 0; } -template<class> +template<typename> int foo(...) { return 0; } |