Home | History | Annotate | Download | only in multiset
      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 // <set>
     11 
     12 // template <class Key, class Compare = less<Key>,
     13 //           class Allocator = allocator<Key>>
     14 // class multiset
     15 // {
     16 // public:
     17 //     // types:
     18 //     typedef Key                                      key_type;
     19 //     typedef key_type                                 value_type;
     20 //     typedef Compare                                  key_compare;
     21 //     typedef key_compare                              value_compare;
     22 //     typedef Allocator                                allocator_type;
     23 //     typedef typename allocator_type::reference       reference;
     24 //     typedef typename allocator_type::const_reference const_reference;
     25 //     typedef typename allocator_type::pointer         pointer;
     26 //     typedef typename allocator_type::const_pointer   const_pointer;
     27 //     typedef typename allocator_type::size_type       size_type;
     28 //     typedef typename allocator_type::difference_type difference_type;
     29 //     ...
     30 // };
     31 
     32 #include <set>
     33 #include <type_traits>
     34 
     35 #include "min_allocator.h"
     36 
     37 int main()
     38 {
     39     {
     40     typedef std::multiset<int> C;
     41     static_assert((std::is_same<C::key_type, int>::value), "");
     42     static_assert((std::is_same<C::value_type, int>::value), "");
     43     static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
     44     static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
     45     static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
     46     static_assert((std::is_same<C::reference, int&>::value), "");
     47     static_assert((std::is_same<C::const_reference, const int&>::value), "");
     48     static_assert((std::is_same<C::pointer, int*>::value), "");
     49     static_assert((std::is_same<C::const_pointer, const int*>::value), "");
     50     static_assert((std::is_same<C::size_type, std::size_t>::value), "");
     51     static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
     52     }
     53 #if TEST_STD_VER >= 11
     54     {
     55     typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
     56     static_assert((std::is_same<C::key_type, int>::value), "");
     57     static_assert((std::is_same<C::value_type, int>::value), "");
     58     static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
     59     static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
     60     static_assert((std::is_same<C::allocator_type, min_allocator<int>>::value), "");
     61     static_assert((std::is_same<C::reference, int&>::value), "");
     62     static_assert((std::is_same<C::const_reference, const int&>::value), "");
     63     static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
     64     static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
     65 //  min_allocator doesn't have a size_type, so one gets synthesized
     66     static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
     67     static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
     68     }
     69 #endif
     70 }
     71