Home | History | Annotate | Download | only in pairs.pair
      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 // REQUIRES: c++98 || c++03
     11 
     12 // <utility>
     13 
     14 // template <class T1, class T2> struct pair
     15 
     16 // pair& operator=(pair const& p);
     17 
     18 #include <utility>
     19 #include <memory>
     20 #include <cassert>
     21 
     22 struct NonAssignable {
     23   NonAssignable() {}
     24 private:
     25   NonAssignable& operator=(NonAssignable const&);
     26 };
     27 
     28 struct Incomplete;
     29 extern Incomplete inc_obj;
     30 
     31 int main()
     32 {
     33     {
     34     // Test that we don't constrain the assignment operator in C++03 mode.
     35     // Since we don't have access control SFINAE having pair evaluate SFINAE
     36     // may cause a hard error.
     37     typedef std::pair<int, NonAssignable> P;
     38     static_assert(std::is_copy_assignable<P>::value, "");
     39     }
     40     {
     41     typedef std::pair<int, Incomplete&> P;
     42     static_assert(std::is_copy_assignable<P>::value, "");
     43     P p(42, inc_obj);
     44     assert(&p.second == &inc_obj);
     45     }
     46 }
     47 
     48 struct Incomplete {};
     49 Incomplete inc_obj;
     50