// (C) Copyright Gennadiy Rozental 2012-2014. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/test for the library home page. // /// @file /// Forward declares monomorphic datasets interfaces // *************************************************************************** #ifndef BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER #define BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER // Boost.Test #include #include #include // Boost #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES #include #include #else #include #endif #include #include #include #include #include #include //____________________________________________________________________________// namespace boost { namespace unit_test { namespace data { namespace monomorphic { #if !defined(BOOST_TEST_DOXYGEN_DOC__) template struct traits; template class dataset; template class singleton; template class collection; template class array; #endif #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES # define BOOST_TEST_ENABLE_IF std::enable_if #else # define BOOST_TEST_ENABLE_IF boost::enable_if_c #endif // ************************************************************************** // // ************** monomorphic::is_dataset ************** // // ************************************************************************** // //! Helper metafunction indicating if the specified type is a dataset. template struct is_dataset : mpl::false_ {}; //! A reference to a dataset is a dataset template struct is_dataset : is_dataset {}; //! A const dataset is a dataset template struct is_dataset : is_dataset {}; //____________________________________________________________________________// } // namespace monomorphic // ************************************************************************** // // ************** data::make ************** // // ************************************************************************** // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES //! @brief Creates a dataset from a value, a collection or an array //! //! This function has several overloads: //! @code //! // returns ds if ds is already a dataset //! template DataSet make(DataSet&& ds); //! //! // creates a singleton dataset, for non forward iterable and non dataset type T //! // (a C string is not considered as a sequence). //! template monomorphic::singleton make(T&& v); //! monomorphic::singleton make( char* str ); //! monomorphic::singleton make( char const* str ); //! //! // creates a collection dataset, for forward iterable and non dataset type C //! template monomorphic::collection make(C && c); //! //! // creates an array dataset //! template monomorphic::array make( T (&a)[size] ); //! @endcode template inline typename BOOST_TEST_ENABLE_IF::value,DataSet>::type make(DataSet&& ds) { return std::forward( ds ); } // warning: doxygen is apparently unable to handle @overload from different files, so if the overloads // below are not declared with @overload in THIS file, they do not appear in the documentation. // fwrd declaration for singletons //! @overload boost::unit_test::data::make() template inline typename BOOST_TEST_ENABLE_IF::value && !monomorphic::is_dataset::value && !boost::is_array< typename boost::remove_reference::type >::value, monomorphic::singleton >::type make( T&& v ); //! @overload boost::unit_test::data::make() template inline typename BOOST_TEST_ENABLE_IF::value, monomorphic::collection >::type make( C&& c ); #else // !BOOST_NO_CXX11_RVALUE_REFERENCES //! @overload boost::unit_test:data::make() template inline typename BOOST_TEST_ENABLE_IF::value,DataSet const&>::type make(DataSet const& ds) { return ds; } // fwrd declaration for singletons #if !(defined(BOOST_MSVC) && (BOOST_MSVC < 1600)) //! @overload boost::unit_test::data::make() template inline typename BOOST_TEST_ENABLE_IF::value && !monomorphic::is_dataset::value && !boost::is_array< typename boost::remove_reference::type >::value, monomorphic::singleton >::type make( T const& v ); #endif // fwrd declaration for collections //! @overload boost::unit_test::data::make() template inline typename BOOST_TEST_ENABLE_IF::value, monomorphic::collection >::type make( C const& c ); //____________________________________________________________________________// #endif // !BOOST_NO_CXX11_RVALUE_REFERENCES // fwrd declarations //! @overload boost::unit_test::data::make() template inline monomorphic::array< typename boost::remove_const::type > make( T (&a)[size] ); // apparently some compilers (eg clang-3.4 on linux) have trouble understanding // the previous line for T being const //! @overload boost::unit_test::data::make() template inline monomorphic::array< typename boost::remove_const::type > make( T const (&)[size] ); template inline monomorphic::array< typename boost::remove_const::type > make( T a[size] ); //! @overload boost::unit_test::data::make() inline monomorphic::singleton make( char* str ); //! @overload boost::unit_test::data::make() inline monomorphic::singleton make( char const* str ); //____________________________________________________________________________// namespace result_of { #ifndef BOOST_NO_CXX11_DECLTYPE //! Result of the make call. template struct make { typedef decltype(data::make(boost::declval())) type; }; #else // explicit specialisation, cumbersome template struct make; template struct make< DataSet const&, typename BOOST_TEST_ENABLE_IF::value>::type > { typedef DataSet const& type; }; template struct make< T, typename BOOST_TEST_ENABLE_IF< (!is_forward_iterable::value && !monomorphic::is_dataset::value && !boost::is_array< typename boost::remove_reference::type >::value) >::type > { typedef monomorphic::singleton type; }; template struct make< C, typename BOOST_TEST_ENABLE_IF< is_forward_iterable::value>::type > { typedef monomorphic::collection type; }; #if 1 template struct make { typedef monomorphic::array::type> type; }; #endif template struct make { typedef monomorphic::array::type> type; }; template struct make { typedef monomorphic::array::type> type; }; template <> struct make { typedef monomorphic::singleton type; }; template <> struct make { typedef monomorphic::singleton type; }; #endif // BOOST_NO_CXX11_DECLTYPE } // namespace result_of //____________________________________________________________________________// } // namespace data } // namespace unit_test } // namespace boost #include #endif // BOOST_TEST_DATA_MONOMORPHIC_FWD_HPP_102212GER