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
37namespace boost {
38namespace unit_test {
39namespace data {
40
41namespace monomorphic {
42
43
44#if !defined(BOOST_TEST_DOXYGEN_DOC__)
45
46template<typename T>
47class singleton;
48
49template<typename C>
50class collection;
51
52template<typename T>
53class array;
54
55template<typename T>
56class init_list;
57
58#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
59 !defined(BOOST_NO_CXX11_HDR_TUPLE)
60template<class dataset_t, class ...Args>
61class delayed_dataset;
62#endif
63
64#endif
65
66// ************************************************************************** //
67// ************** monomorphic::is_dataset ************** //
68// ************************************************************************** //
69
70//! Helper metafunction indicating if the specified type is a dataset.
71template<typename DataSet>
72struct is_dataset : mpl::false_ {};
73
74//____________________________________________________________________________//
75
76//! A reference to a dataset is a dataset
77template<typename DataSet>
78struct is_dataset<DataSet&> : is_dataset<DataSet> {};
79template<typename DataSet>
80struct is_dataset<DataSet&&> : is_dataset<DataSet> {};
81
82//____________________________________________________________________________//
83
84//! A const dataset is a dataset
85template<typename DataSet>
86struct is_dataset<DataSet const> : is_dataset<DataSet> {};
87
88#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
89
90//! Helper to check if a list of types contains a dataset
91template<class DataSet, class...>
92struct has_dataset : is_dataset<DataSet> {};
93
94template<class DataSet0, class DataSet1, class... DataSetTT>
95struct has_dataset<DataSet0, DataSet1, DataSetTT...>
96 : std::integral_constant<bool, is_dataset<DataSet0>::value || has_dataset<DataSet1, DataSetTT...>::value>
97{};
98#endif
99
100} // namespace monomorphic
101
102// ************************************************************************** //
103// ************** data::make ************** //
104// ************************************************************************** //
105
106//! @brief Creates a dataset from a value, a collection or an array
107//!
108//! This function has several overloads:
109//! @code
110//! // returns ds if ds is already a dataset
111//! template <typename DataSet> DataSet make(DataSet&& ds);
112//!
113//! // creates a singleton dataset, for non forward iterable and non dataset type T
114//! // (a C string is not considered as a sequence).
115//! template <typename T> monomorphic::singleton<T> make(T&& v);
116//! monomorphic::singleton<char*> make( char* str );
117//! monomorphic::singleton<char const*> make( char const* str );
118//!
119//! // creates a collection dataset, for forward iterable and non dataset type C
120//! template <typename C> monomorphic::collection<C> make(C && c);
121//!
122//! // creates an array dataset
123//! template<typename T, std::size_t size> monomorphic::array<T> make( T (&a)[size] );
124//! @endcode
125template<typename DataSet>
126inline typename std::enable_if<monomorphic::is_dataset<DataSet>::value,DataSet>::type
127make(DataSet&& ds)
128{
129 return std::forward<DataSet>( ds );
130}
131
132//____________________________________________________________________________//
133
134// warning: doxygen is apparently unable to handle @overload from different files, so if the overloads
135// below are not declared with @overload in THIS file, they do not appear in the documentation.
136
137//! @overload boost::unit_test::data::make()
138template<typename T>
139inline typename std::enable_if<!is_container_forward_iterable<T>::value &&
140 !monomorphic::is_dataset<T>::value &&
141 !is_array<typename remove_reference<T>::type>::value,
142 monomorphic::singleton<T>>::type
143make( T&& v );
144
145//____________________________________________________________________________//
146
147//! @overload boost::unit_test::data::make()
148template<typename C>
149inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
150make( C&& c );
151
152//____________________________________________________________________________//
153
154//! @overload boost::unit_test::data::make()
155template<typename T, std::size_t size>
156inline monomorphic::array< typename boost::remove_const<T>::type >
157make( T (&a)[size] );
158
159//____________________________________________________________________________//
160
161//! @overload boost::unit_test::data::make()
162inline monomorphic::singleton<char*>
163make( char* str );
164
165//____________________________________________________________________________//
166
167//! @overload boost::unit_test::data::make()
168inline monomorphic::singleton<char const*>
169make( char const* str );
170
171//____________________________________________________________________________//
172
173//! @overload boost::unit_test::data::make()
174template<typename T>
175inline monomorphic::init_list<T>
176make( std::initializer_list<T>&& );
177
178//____________________________________________________________________________//
179
180#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
181 !defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
182//! @overload boost::unit_test::data::make()
183template<class T, class ...Args>
184inline typename std::enable_if<
185 !monomorphic::has_dataset<T, Args...>::value,
186 monomorphic::init_list<T>
187>::type
188make( T&& arg0, Args&&... args );
189#endif
190
191//____________________________________________________________________________//
192
193#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
194 !defined(BOOST_NO_CXX11_HDR_TUPLE)
195template<class dataset_t, class ...Args>
196inline typename std::enable_if<
197 monomorphic::is_dataset< dataset_t >::value,
198 monomorphic::delayed_dataset<dataset_t, Args...>
199>::type
200make_delayed(Args... args);
201#endif
202
203//____________________________________________________________________________//
204
205namespace result_of {
206
207//! Result of the make call.
208template<typename DataSet>
209struct make {
210 typedef decltype( data::make( declval<DataSet>() ) ) type;
211};
212
213} // namespace result_of
214
215} // namespace data
216} // namespace unit_test
217} // namespace boost
218
219#include <boost/test/detail/enable_warnings.hpp>
220
221#endif // BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
222
223

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of boost/libs/test/include/boost/test/data/monomorphic/fwd.hpp