File: flat_set_adaptor_test.cpp

package info (click to toggle)
boost1.90 1.90.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 593,120 kB
  • sloc: cpp: 4,190,908; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,774; makefile: 1,161; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (123 lines) | stat: -rw-r--r-- 4,621 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2004-2019. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/container/flat_set.hpp>
#include <boost/container/small_vector.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/container/stable_vector.hpp>
#include <boost/container/vector.hpp>
#include <boost/container/deque.hpp>
#include <boost/container/devector.hpp>

#include <boost/container/detail/container_or_allocator_rebind.hpp>

#include "set_test.hpp"
#include <set>

using namespace boost::container;

template<class VoidAllocatorOrContainer>
struct GetSetContainer
{
   template<class ValueType>
   struct apply
   {
      typedef flat_set < ValueType
                       , std::less<ValueType>
                       , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, ValueType>::type
                        > set_type;

      typedef flat_multiset < ValueType
                            , std::less<ValueType>
                            , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, ValueType>::type
                            > multiset_type;
   };
};

int main()
{
   using namespace boost::container::test;

   ////////////////////////////////////
   //    Testing sequence container implementations
   ////////////////////////////////////
   {
      typedef std::set<int>                                     MyStdSet;
      typedef std::multiset<int>                                MyStdMultiSet;

      if (0 != test::set_test
         < GetSetContainer<vector<int> >::apply<int>::set_type
         , MyStdSet
         , GetSetContainer<vector<int> >::apply<int>::multiset_type
         , MyStdMultiSet>()) {
         std::cout << "Error in set_test<vector<int> >" << std::endl;
         return 1;
      }

      if (0 != test::set_test
         < GetSetContainer<small_vector<int, 7> >::apply<int>::set_type
         , MyStdSet
         , GetSetContainer<small_vector<int, 7> >::apply<int>::multiset_type
         , MyStdMultiSet>()) {
         std::cout << "Error in set_test<small_vector<int, 7> >" << std::endl;
         return 1;
      }

       if (0 != test::set_test
         < GetSetContainer<static_vector<int, MaxElem * 10> >::apply<int>::set_type
         , MyStdSet
         , GetSetContainer<static_vector<int, MaxElem * 10> >::apply<int>::multiset_type
         , MyStdMultiSet>()) {
         std::cout << "Error in set_test<static_vector<int, MaxElem * 10> >" << std::endl;
         return 1;
      }

      if (0 != test::set_test
         < GetSetContainer<stable_vector<int> >::apply<int>::set_type
         , MyStdSet
         , GetSetContainer<stable_vector<int> >::apply<int>::multiset_type
         , MyStdMultiSet>()) {
         std::cout << "Error in set_test<stable_vector<int> >" << std::endl;
         return 1;
      }


      if (0 != test::set_test
         < GetSetContainer<deque<int> >::apply<int>::set_type
         , MyStdSet
         , GetSetContainer<deque<int> >::apply<int>::multiset_type
         , MyStdMultiSet>()) {
         std::cout << "Error in set_test<deque<int> >" << std::endl;
         return 1;
      }
      if (0 != test::set_test
         < GetSetContainer<devector<int> >::apply<int>::set_type
         , MyStdSet
         , GetSetContainer<devector<int> >::apply<int>::multiset_type
         , MyStdMultiSet>()) {
         std::cout << "Error in set_test<deque<int> >" << std::endl;
         return 1;
      }
   }
   {
      using namespace boost::container;
      using boost::container::dtl::is_same;

      typedef flat_set<int, std::less<int>, small_vector<int, 10> > set_container_t;
      typedef flat_multiset<int, std::less<int>, small_vector<int, 10> > multiset_container_t;
      #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
      BOOST_CONTAINER_STATIC_ASSERT(( is_same<set_container_t, small_flat_set<int, 10> >::value ));
      BOOST_CONTAINER_STATIC_ASSERT(( is_same<multiset_container_t, small_flat_multiset<int, 10> >::value ));
      #endif
      BOOST_CONTAINER_STATIC_ASSERT(( is_same<set_container_t, small_flat_set_of<int, 10>::type >::value ));
      BOOST_CONTAINER_STATIC_ASSERT(( is_same<multiset_container_t, small_flat_multiset_of<int, 10>::type >::value ));
   }

   return 0;
}