Home | History | Annotate | Download | only in allocator.traits.types
      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 // <memory>
     11 
     12 // template <class Alloc>
     13 // struct allocator_traits
     14 // {
     15 //     typedef Alloc::propagate_on_container_copy_assignment
     16 //           | false_type                   propagate_on_container_copy_assignment;
     17 //     ...
     18 // };
     19 
     20 #include <memory>
     21 #include <type_traits>
     22 
     23 #include "test_macros.h"
     24 
     25 template <class T>
     26 struct A
     27 {
     28     typedef T value_type;
     29     typedef std::true_type propagate_on_container_copy_assignment;
     30 };
     31 
     32 template <class T>
     33 struct B
     34 {
     35     typedef T value_type;
     36 };
     37 
     38 
     39 template <class T>
     40 struct C
     41 {
     42     typedef T value_type;
     43 private:
     44     typedef std::true_type propagate_on_container_copy_assignment;
     45 };
     46 
     47 int main()
     48 {
     49     static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_copy_assignment, std::true_type>::value), "");
     50     static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_copy_assignment, std::false_type>::value), "");
     51 #if TEST_STD_VER >= 11
     52     static_assert((std::is_same<std::allocator_traits<C<char> >::propagate_on_container_copy_assignment, std::false_type>::value), "");
     53 #endif
     54 }
     55