![]() |
|
|||
File indexing completed on 2025-07-11 08:27:26
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 ///Defines monomorphic dataset based on forward iterable sequence 0010 // *************************************************************************** 0011 0012 #ifndef BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER 0013 #define BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER 0014 0015 // Boost.Test 0016 #include <boost/test/data/config.hpp> 0017 #include <boost/test/data/monomorphic/fwd.hpp> 0018 0019 #include <boost/test/detail/suppress_warnings.hpp> 0020 0021 //____________________________________________________________________________// 0022 0023 namespace boost { 0024 namespace unit_test { 0025 namespace data { 0026 namespace monomorphic { 0027 0028 // ************************************************************************** // 0029 // ************** collection ************** // 0030 // ************************************************************************** // 0031 0032 0033 //!@brief Dataset from a forward iterable container (collection) 0034 //! 0035 //! This dataset is applicable to any container implementing a forward iterator. Note that 0036 //! container with one element will be considered as singletons. 0037 //! This dataset is constructible with the @ref boost::unit_test::data::make function. 0038 template<typename C> 0039 class collection { 0040 typedef typename boost::decay<C>::type col_type; 0041 public: 0042 typedef typename col_type::value_type sample; 0043 0044 static const int arity = 1; 0045 0046 typedef typename col_type::const_iterator iterator; 0047 0048 //! Constructor consumed a temporary collection or stores a reference 0049 explicit collection( C&& col ) : m_col( std::forward<C>(col) ) {} 0050 0051 //! Move constructor 0052 collection( collection&& c ) : m_col( std::forward<C>( c.m_col ) ) {} 0053 0054 //! Returns the underlying collection 0055 C const& col() const { return m_col; } 0056 0057 //! dataset interface 0058 data::size_t size() const { return m_col.size(); } 0059 iterator begin() const { return m_col.begin(); } 0060 0061 private: 0062 // Data members 0063 C m_col; 0064 }; 0065 0066 //____________________________________________________________________________// 0067 0068 //! A collection from a forward iterable container is a dataset. 0069 template<typename C> 0070 struct is_dataset<collection<C>> : mpl::true_ {}; 0071 0072 } // namespace monomorphic 0073 0074 //____________________________________________________________________________// 0075 0076 //! @overload boost::unit_test::data::make() 0077 template<typename C> 0078 inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type 0079 make( C&& c ) 0080 { 0081 return monomorphic::collection<C>( std::forward<C>(c) ); 0082 } 0083 0084 } // namespace data 0085 } // namespace unit_test 0086 } // namespace boost 0087 0088 #include <boost/test/detail/enable_warnings.hpp> 0089 0090 #endif // BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER 0091
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |