libcxx

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

copy_ctor.pass.cpp (957B)


      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 // <utility>
     11 
     12 // template <class T1, class T2> struct pair
     13 
     14 // pair(const pair&) = default;
     15 
     16 #include <utility>
     17 #include <cassert>
     18 
     19 #include "test_macros.h"
     20 
     21 int main()
     22 {
     23     {
     24         typedef std::pair<int, short> P1;
     25         P1 p1(3, static_cast<short>(4));
     26         P1 p2 = p1;
     27         assert(p2.first == 3);
     28         assert(p2.second == 4);
     29     }
     30 #if TEST_STD_VER > 11
     31     {
     32         typedef std::pair<int, short> P1;
     33         constexpr P1 p1(3, static_cast<short>(4));
     34         constexpr P1 p2 = p1;
     35         static_assert(p2.first == 3, "");
     36         static_assert(p2.second == 4, "");
     37     }
     38 #endif
     39 }