]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/include/boost/test/data/monomorphic/fwd.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / test / include / boost / test / data / monomorphic / fwd.hpp
1 // (C) Copyright Gennadiy Rozental 2001.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org/libs/test for the library home page.
7 //
8 /// @file
9 /// Forward declares monomorphic datasets interfaces
10 // ***************************************************************************
11
12 #ifndef BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
13 #define BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
14
15 // Boost.Test
16 #include <boost/test/data/config.hpp>
17 #include <boost/test/data/size.hpp>
18
19 #include <boost/test/utils/is_forward_iterable.hpp>
20
21 // Boost
22 #include <boost/type_traits/remove_const.hpp>
23 #include <boost/type_traits/remove_reference.hpp>
24 #include <boost/type_traits/is_array.hpp>
25 #include <boost/mpl/bool.hpp>
26
27 // STL
28 #include <tuple>
29
30 #include <boost/test/detail/suppress_warnings.hpp>
31
32 // STL
33 #include <initializer_list>
34
35 //____________________________________________________________________________//
36
37 namespace boost {
38 namespace unit_test {
39 namespace data {
40
41 namespace monomorphic {
42
43
44 #if !defined(BOOST_TEST_DOXYGEN_DOC__)
45
46 template<typename T, typename Specific>
47 class dataset;
48
49 template<typename T>
50 class singleton;
51
52 template<typename C>
53 class collection;
54
55 template<typename T>
56 class array;
57
58 template<typename T>
59 class init_list;
60
61 #endif
62
63 // ************************************************************************** //
64 // ************** monomorphic::is_dataset ************** //
65 // ************************************************************************** //
66
67 //! Helper metafunction indicating if the specified type is a dataset.
68 template<typename DataSet>
69 struct is_dataset : mpl::false_ {};
70
71 //____________________________________________________________________________//
72
73 //! A reference to a dataset is a dataset
74 template<typename DataSet>
75 struct is_dataset<DataSet&> : is_dataset<DataSet> {};
76
77 //____________________________________________________________________________//
78
79 //! A const dataset is a dataset
80 template<typename DataSet>
81 struct is_dataset<DataSet const> : is_dataset<DataSet> {};
82
83 } // namespace monomorphic
84
85 // ************************************************************************** //
86 // ************** data::make ************** //
87 // ************************************************************************** //
88
89 //! @brief Creates a dataset from a value, a collection or an array
90 //!
91 //! This function has several overloads:
92 //! @code
93 //! // returns ds if ds is already a dataset
94 //! template <typename DataSet> DataSet make(DataSet&& ds);
95 //!
96 //! // creates a singleton dataset, for non forward iterable and non dataset type T
97 //! // (a C string is not considered as a sequence).
98 //! template <typename T> monomorphic::singleton<T> make(T&& v);
99 //! monomorphic::singleton<char*> make( char* str );
100 //! monomorphic::singleton<char const*> make( char const* str );
101 //!
102 //! // creates a collection dataset, for forward iterable and non dataset type C
103 //! template <typename C> monomorphic::collection<C> make(C && c);
104 //!
105 //! // creates an array dataset
106 //! template<typename T, std::size_t size> monomorphic::array<T> make( T (&a)[size] );
107 //! @endcode
108 template<typename DataSet>
109 inline typename std::enable_if<monomorphic::is_dataset<DataSet>::value,DataSet>::type
110 make(DataSet&& ds)
111 {
112 return std::forward<DataSet>( ds );
113 }
114
115 //____________________________________________________________________________//
116
117 // warning: doxygen is apparently unable to handle @overload from different files, so if the overloads
118 // below are not declared with @overload in THIS file, they do not appear in the documentation.
119
120 //! @overload boost::unit_test::data::make()
121 template<typename T>
122 inline typename std::enable_if<!is_forward_iterable<T>::value &&
123 !monomorphic::is_dataset<T>::value &&
124 !is_array<typename remove_reference<T>::type>::value,
125 monomorphic::singleton<T>>::type
126 make( T&& v );
127
128 //____________________________________________________________________________//
129
130 //! @overload boost::unit_test::data::make()
131 template<typename C>
132 inline typename std::enable_if<is_forward_iterable<C>::value,monomorphic::collection<C>>::type
133 make( C&& c );
134
135 //____________________________________________________________________________//
136
137 //! @overload boost::unit_test::data::make()
138 template<typename T, std::size_t size>
139 inline monomorphic::array< typename boost::remove_const<T>::type >
140 make( T (&a)[size] );
141
142 //____________________________________________________________________________//
143
144 //! @overload boost::unit_test::data::make()
145 inline monomorphic::singleton<char*>
146 make( char* str );
147
148 //____________________________________________________________________________//
149
150 //! @overload boost::unit_test::data::make()
151 inline monomorphic::singleton<char const*>
152 make( char const* str );
153
154 //____________________________________________________________________________//
155
156 //! @overload boost::unit_test::data::make()
157 template<typename T>
158 inline monomorphic::init_list<T>
159 make( std::initializer_list<T>&& );
160
161 //____________________________________________________________________________//
162
163 namespace result_of {
164
165 //! Result of the make call.
166 template<typename DataSet>
167 struct make {
168 typedef decltype( data::make( declval<DataSet>() ) ) type;
169 };
170
171 } // namespace result_of
172
173 } // namespace data
174 } // namespace unit_test
175 } // namespace boost
176
177 #include <boost/test/detail/enable_warnings.hpp>
178
179 #endif // BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
180