1// Copyright 2017 Peter Dimov.
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#include <boost/container_hash/is_range.hpp>
6#include <boost/core/lightweight_test_trait.hpp>
7#include <boost/config.hpp>
8#include <string>
9#include <vector>
10#include <list>
11#include <deque>
12#include <set>
13#include <map>
14#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
15# include <array>
16#endif
17#if !defined(BOOST_NO_CXX11_HDR_FORWARD_LIST)
18# include <forward_list>
19#endif
20#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
21# include <unordered_set>
22#endif
23#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP)
24# include <unordered_map>
25#endif
26
27struct X
28{
29};
30
31int main()
32{
33 using boost::container_hash::is_range;
34
35 BOOST_TEST_TRAIT_FALSE((is_range<void>));
36 BOOST_TEST_TRAIT_FALSE((is_range<void const>));
37
38 BOOST_TEST_TRAIT_FALSE((is_range<int>));
39 BOOST_TEST_TRAIT_FALSE((is_range<int const>));
40
41 BOOST_TEST_TRAIT_FALSE((is_range<X>));
42 BOOST_TEST_TRAIT_FALSE((is_range<X const>));
43
44 BOOST_TEST_TRAIT_FALSE((is_range<int[2]>));
45 BOOST_TEST_TRAIT_FALSE((is_range<int const[2]>));
46
47 BOOST_TEST_TRAIT_TRUE((is_range<std::string>));
48 BOOST_TEST_TRAIT_TRUE((is_range<std::string const>));
49
50 BOOST_TEST_TRAIT_TRUE((is_range<std::wstring>));
51 BOOST_TEST_TRAIT_TRUE((is_range<std::wstring const>));
52
53 BOOST_TEST_TRAIT_TRUE((is_range< std::vector<X> >));
54 BOOST_TEST_TRAIT_TRUE((is_range< std::vector<X> const >));
55
56 BOOST_TEST_TRAIT_TRUE((is_range< std::deque<X> >));
57 BOOST_TEST_TRAIT_TRUE((is_range< std::deque<X> const >));
58
59 BOOST_TEST_TRAIT_TRUE((is_range< std::set<int> >));
60 BOOST_TEST_TRAIT_TRUE((is_range< std::set<int> const >));
61
62 BOOST_TEST_TRAIT_TRUE((is_range< std::multiset<int> >));
63 BOOST_TEST_TRAIT_TRUE((is_range< std::multiset<int> const >));
64
65 BOOST_TEST_TRAIT_TRUE((is_range< std::map<int, X> >));
66 BOOST_TEST_TRAIT_TRUE((is_range< std::map<int, X> const >));
67
68 BOOST_TEST_TRAIT_TRUE((is_range< std::multimap<int, X> >));
69 BOOST_TEST_TRAIT_TRUE((is_range< std::multimap<int, X> const >));
70
71#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
72 BOOST_TEST_TRAIT_TRUE((is_range< std::array<X, 2> >));
73 BOOST_TEST_TRAIT_TRUE((is_range< std::array<X, 2> const >));
74#endif
75
76#if !defined(BOOST_NO_CXX11_HDR_FORWARD_LIST)
77 BOOST_TEST_TRAIT_TRUE((is_range< std::forward_list<X> >));
78 BOOST_TEST_TRAIT_TRUE((is_range< std::forward_list<X> const >));
79#endif
80
81#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
82 BOOST_TEST_TRAIT_TRUE((is_range< std::unordered_set<int> >));
83 BOOST_TEST_TRAIT_TRUE((is_range< std::unordered_set<int> const >));
84
85 BOOST_TEST_TRAIT_TRUE((is_range< std::unordered_multiset<int> >));
86 BOOST_TEST_TRAIT_TRUE((is_range< std::unordered_multiset<int> const >));
87#endif
88
89#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP)
90 BOOST_TEST_TRAIT_TRUE((is_range< std::unordered_map<int, X> >));
91 BOOST_TEST_TRAIT_TRUE((is_range< std::unordered_map<int, X> const >));
92
93 BOOST_TEST_TRAIT_TRUE((is_range< std::unordered_multimap<int, X> >));
94 BOOST_TEST_TRAIT_TRUE((is_range< std::unordered_multimap<int, X> const >));
95#endif
96
97 return boost::report_errors();
98}
99

source code of boost/libs/container_hash/test/is_range_test.cpp