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)
6 // See http://www.boost.org/libs/test for the library home page.
9 /// Forward declares monomorphic datasets interfaces
10 // ***************************************************************************
12 #ifndef BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
13 #define BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
16 #include <boost/test/data/config.hpp>
17 #include <boost/test/data/size.hpp>
19 #include <boost/test/utils/is_forward_iterable.hpp>
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>
30 #include <boost/test/detail/suppress_warnings.hpp>
33 #include <initializer_list>
35 //____________________________________________________________________________//
41 namespace monomorphic {
44 #if !defined(BOOST_TEST_DOXYGEN_DOC__)
46 template<typename T, typename Specific>
63 // ************************************************************************** //
64 // ************** monomorphic::is_dataset ************** //
65 // ************************************************************************** //
67 //! Helper metafunction indicating if the specified type is a dataset.
68 template<typename DataSet>
69 struct is_dataset : mpl::false_ {};
71 //____________________________________________________________________________//
73 //! A reference to a dataset is a dataset
74 template<typename DataSet>
75 struct is_dataset<DataSet&> : is_dataset<DataSet> {};
77 //____________________________________________________________________________//
79 //! A const dataset is a dataset
80 template<typename DataSet>
81 struct is_dataset<DataSet const> : is_dataset<DataSet> {};
83 } // namespace monomorphic
85 // ************************************************************************** //
86 // ************** data::make ************** //
87 // ************************************************************************** //
89 //! @brief Creates a dataset from a value, a collection or an array
91 //! This function has several overloads:
93 //! // returns ds if ds is already a dataset
94 //! template <typename DataSet> DataSet make(DataSet&& ds);
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 );
102 //! // creates a collection dataset, for forward iterable and non dataset type C
103 //! template <typename C> monomorphic::collection<C> make(C && c);
105 //! // creates an array dataset
106 //! template<typename T, std::size_t size> monomorphic::array<T> make( T (&a)[size] );
108 template<typename DataSet>
109 inline typename std::enable_if<monomorphic::is_dataset<DataSet>::value,DataSet>::type
112 return std::forward<DataSet>( ds );
115 //____________________________________________________________________________//
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.
120 //! @overload boost::unit_test::data::make()
122 inline typename std::enable_if<!is_container_forward_iterable<T>::value &&
123 !monomorphic::is_dataset<T>::value &&
124 !is_array<typename remove_reference<T>::type>::value,
125 monomorphic::singleton<T>>::type
128 //____________________________________________________________________________//
130 //! @overload boost::unit_test::data::make()
132 inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
135 //____________________________________________________________________________//
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] );
142 //____________________________________________________________________________//
144 //! @overload boost::unit_test::data::make()
145 inline monomorphic::singleton<char*>
148 //____________________________________________________________________________//
150 //! @overload boost::unit_test::data::make()
151 inline monomorphic::singleton<char const*>
152 make( char const* str );
154 //____________________________________________________________________________//
156 //! @overload boost::unit_test::data::make()
158 inline monomorphic::init_list<T>
159 make( std::initializer_list<T>&& );
161 //____________________________________________________________________________//
163 namespace result_of {
165 //! Result of the make call.
166 template<typename DataSet>
168 typedef decltype( data::make( declval<DataSet>() ) ) type;
171 } // namespace result_of
174 } // namespace unit_test
177 #include <boost/test/detail/enable_warnings.hpp>
179 #endif // BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER