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 ///Defines monomorphic dataset based on forward iterable sequence
10 // ***************************************************************************
12 #ifndef BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER
13 #define BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER
16 #include <boost/test/data/config.hpp>
17 #include <boost/test/data/monomorphic/fwd.hpp>
19 #include <boost/test/detail/suppress_warnings.hpp>
21 //____________________________________________________________________________//
26 namespace monomorphic {
28 // ************************************************************************** //
29 // ************** collection ************** //
30 // ************************************************************************** //
33 //!@brief Dataset from a forward iterable container (collection)
35 //! This dataset is applicable to any container implementing a forward iterator. Note that
36 //! container with one element will be considered as singletons.
37 //! This dataset is constructible with the @ref boost::unit_test::data::make function.
40 typedef typename boost::decay<C>::type col_type;
42 typedef typename col_type::value_type sample;
46 typedef typename col_type::const_iterator iterator;
48 //! Constructor consumed a temporary collection or stores a reference
49 explicit collection( C&& col ) : m_col( std::forward<C>(col) ) {}
52 collection( collection&& c ) : m_col( std::forward<C>( c.m_col ) ) {}
54 //! Returns the underlying collection
55 C const& col() const { return m_col; }
58 data::size_t size() const { return m_col.size(); }
59 iterator begin() const { return m_col.begin(); }
66 //____________________________________________________________________________//
68 //! A collection from a forward iterable container is a dataset.
70 struct is_dataset<collection<C>> : mpl::true_ {};
72 } // namespace monomorphic
74 //____________________________________________________________________________//
76 //! @overload boost::unit_test::data::make()
78 inline typename std::enable_if<is_forward_iterable<C>::value,monomorphic::collection<C>>::type
81 return monomorphic::collection<C>( std::forward<C>(c) );
85 } // namespace unit_test
88 #include <boost/test/detail/enable_warnings.hpp>
90 #endif // BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER