Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/test/data/monomorphic/fwd.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at 
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 /// @file
0009 /// Forward declares monomorphic datasets interfaces
0010 // ***************************************************************************
0011 
0012 #ifndef BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
0013 #define BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
0014 
0015 // Boost.Test
0016 #include <boost/test/data/config.hpp>
0017 #include <boost/test/data/size.hpp>
0018 
0019 #include <boost/test/utils/is_forward_iterable.hpp>
0020 
0021 // Boost
0022 #include <boost/type_traits/remove_const.hpp>
0023 #include <boost/type_traits/remove_reference.hpp>
0024 #include <boost/type_traits/is_array.hpp>
0025 #include <boost/mpl/bool.hpp>
0026 
0027 // STL
0028 #include <tuple>
0029 
0030 #include <boost/test/detail/suppress_warnings.hpp>
0031 
0032 // STL
0033 #include <initializer_list>
0034 
0035 //____________________________________________________________________________//
0036 
0037 namespace boost {
0038 namespace unit_test {
0039 namespace data {
0040 
0041 namespace monomorphic {
0042 
0043 
0044 #if !defined(BOOST_TEST_DOXYGEN_DOC__)
0045 
0046 template<typename T>
0047 class singleton;
0048 
0049 template<typename C>
0050 class collection;
0051 
0052 template<typename T>
0053 class array;
0054 
0055 template<typename T>
0056 class init_list;
0057 
0058 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0059     !defined(BOOST_NO_CXX11_HDR_TUPLE)
0060 template<class dataset_t, class ...Args>
0061 class delayed_dataset;
0062 #endif
0063 
0064 #endif
0065 
0066 // ************************************************************************** //
0067 // **************            monomorphic::is_dataset           ************** //
0068 // ************************************************************************** //
0069 
0070 //! Helper metafunction indicating if the specified type is a dataset.
0071 template<typename DataSet>
0072 struct is_dataset : mpl::false_ {};
0073 
0074 //____________________________________________________________________________//
0075 
0076 //! A reference to a dataset is a dataset
0077 template<typename DataSet>
0078 struct is_dataset<DataSet&> : is_dataset<DataSet> {};
0079 template<typename DataSet>
0080 struct is_dataset<DataSet&&> : is_dataset<DataSet> {};
0081 
0082 //____________________________________________________________________________//
0083 
0084 //! A const dataset is a dataset
0085 template<typename DataSet>
0086 struct is_dataset<DataSet const> : is_dataset<DataSet> {};
0087 
0088 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0089 
0090 //! Helper to check if a list of types contains a dataset
0091 template<class DataSet, class...>
0092 struct has_dataset : is_dataset<DataSet> {};
0093 
0094 template<class DataSet0, class DataSet1, class... DataSetTT>
0095 struct has_dataset<DataSet0, DataSet1, DataSetTT...>
0096   : std::integral_constant<bool, is_dataset<DataSet0>::value || has_dataset<DataSet1, DataSetTT...>::value>
0097 {};
0098 #endif
0099 
0100 } // namespace monomorphic
0101 
0102 // ************************************************************************** //
0103 // **************                  data::make                  ************** //
0104 // ************************************************************************** //
0105 
0106 //! @brief Creates a dataset from a value, a collection or an array
0107 //!
0108 //! This function has several overloads:
0109 //! @code
0110 //! // returns ds if ds is already a dataset
0111 //! template <typename DataSet> DataSet make(DataSet&& ds); 
0112 //!
0113 //! // creates a singleton dataset, for non forward iterable and non dataset type T
0114 //! // (a C string is not considered as a sequence).
0115 //! template <typename T> monomorphic::singleton<T> make(T&& v); 
0116 //! monomorphic::singleton<char*> make( char* str );
0117 //! monomorphic::singleton<char const*> make( char const* str );
0118 //!
0119 //! // creates a collection dataset, for forward iterable and non dataset type C
0120 //! template <typename C> monomorphic::collection<C> make(C && c);
0121 //!
0122 //! // creates an array dataset
0123 //! template<typename T, std::size_t size> monomorphic::array<T> make( T (&a)[size] );
0124 //! @endcode
0125 template<typename DataSet>
0126 inline typename std::enable_if<monomorphic::is_dataset<DataSet>::value,DataSet>::type
0127 make(DataSet&& ds)
0128 {
0129     return std::forward<DataSet>( ds );
0130 }
0131 
0132 //____________________________________________________________________________//
0133 
0134 // warning: doxygen is apparently unable to handle @overload from different files, so if the overloads
0135 // below are not declared with @overload in THIS file, they do not appear in the documentation.
0136 
0137 //! @overload boost::unit_test::data::make()
0138 template<typename T>
0139 inline typename std::enable_if<!is_container_forward_iterable<T>::value && 
0140                                !monomorphic::is_dataset<T>::value &&
0141                                !is_array<typename remove_reference<T>::type>::value, 
0142                                monomorphic::singleton<T>>::type
0143 make( T&& v );
0144 
0145 //____________________________________________________________________________//
0146 
0147 //! @overload boost::unit_test::data::make()
0148 template<typename C>
0149 inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
0150 make( C&& c );
0151 
0152 //____________________________________________________________________________//
0153 
0154 //! @overload boost::unit_test::data::make()
0155 template<typename T, std::size_t size>
0156 inline monomorphic::array< typename boost::remove_const<T>::type >
0157 make( T (&a)[size] );
0158 
0159 //____________________________________________________________________________//
0160 
0161 //! @overload boost::unit_test::data::make()
0162 inline monomorphic::singleton<char*>
0163 make( char* str );
0164 
0165 //____________________________________________________________________________//
0166 
0167 //! @overload boost::unit_test::data::make()
0168 inline monomorphic::singleton<char const*>
0169 make( char const* str );
0170 
0171 //____________________________________________________________________________//
0172 
0173 //! @overload boost::unit_test::data::make()
0174 template<typename T>
0175 inline monomorphic::init_list<T>
0176 make( std::initializer_list<T>&& );
0177 
0178 //____________________________________________________________________________//
0179 
0180 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0181     !defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
0182 //! @overload boost::unit_test::data::make()
0183 template<class T, class ...Args>
0184 inline typename std::enable_if<
0185   !monomorphic::has_dataset<T, Args...>::value,
0186   monomorphic::init_list<T>
0187 >::type
0188 make( T&& arg0, Args&&... args );
0189 #endif
0190 
0191 //____________________________________________________________________________//
0192 
0193 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0194     !defined(BOOST_NO_CXX11_HDR_TUPLE)
0195 template<class dataset_t, class ...Args>
0196 inline typename std::enable_if<
0197   monomorphic::is_dataset< dataset_t >::value,
0198   monomorphic::delayed_dataset<dataset_t, Args...>
0199 >::type
0200 make_delayed(Args... args);
0201 #endif
0202 
0203 //____________________________________________________________________________//
0204 
0205 namespace result_of {
0206 
0207 //! Result of the make call.
0208 template<typename DataSet>
0209 struct make {
0210     typedef decltype( data::make( declval<DataSet>() ) ) type;
0211 };
0212 
0213 } // namespace result_of
0214 
0215 } // namespace data
0216 } // namespace unit_test
0217 } // namespace boost
0218 
0219 #include <boost/test/detail/enable_warnings.hpp>
0220 
0221 #endif // BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER
0222