libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

U_V.pass.cpp (1914B)


      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // UNSUPPORTED: c++98, c++03
     11 
     12 // <utility>
     13 
     14 // template <class T1, class T2> struct pair
     15 
     16 // template<class U, class V> pair(U&& x, V&& y);
     17 
     18 #include <utility>
     19 
     20 
     21 struct ExplicitT {
     22     constexpr explicit ExplicitT(int x) : value(x) {}
     23     int value;
     24 };
     25 
     26 struct ImplicitT {
     27     constexpr ImplicitT(int x) : value(x) {}
     28     int value;
     29 };
     30 
     31 struct ExplicitNothrowT {
     32     explicit ExplicitNothrowT(int x) noexcept : value(x) {}
     33     int value;
     34 };
     35 
     36 struct ImplicitNothrowT {
     37     ImplicitNothrowT(int x) noexcept : value(x) {}
     38     int value;
     39 };
     40 
     41 int main() {
     42     { // explicit noexcept test
     43         static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>, int, int>::value, "");
     44         static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>, int, int>::value, "");
     45         static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>, int, int>::value, "");
     46         static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>, int, int>::value, "");
     47     }
     48     { // implicit noexcept test
     49         static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>, int, int>::value, "");
     50         static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>, int, int>::value, "");
     51         static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>, int, int>::value, "");
     52         static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>, int, int>::value, "");
     53     }
     54 }