]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/include/boost/test/data/monomorphic/collection.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / include / boost / test / data / monomorphic / collection.hpp
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)
5
6 // See http://www.boost.org/libs/test for the library home page.
7 //
8 ///@file
9 ///Defines monomorphic dataset based on forward iterable sequence
10 // ***************************************************************************
11
12 #ifndef BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER
13 #define BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER
14
15 // Boost.Test
16 #include <boost/test/data/config.hpp>
17 #include <boost/test/data/monomorphic/fwd.hpp>
18
19 #include <boost/test/detail/suppress_warnings.hpp>
20
21 //____________________________________________________________________________//
22
23 namespace boost {
24 namespace unit_test {
25 namespace data {
26 namespace monomorphic {
27
28 // ************************************************************************** //
29 // ************** collection ************** //
30 // ************************************************************************** //
31
32
33 //!@brief Dataset from a forward iterable container (collection)
34 //!
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.
38 template<typename C>
39 class collection {
40 typedef typename boost::decay<C>::type col_type;
41 public:
42 typedef typename col_type::value_type sample;
43
44 enum { arity = 1 };
45
46 typedef typename col_type::const_iterator iterator;
47
48 //! Constructor consumed a temporary collection or stores a reference
49 explicit collection( C&& col ) : m_col( std::forward<C>(col) ) {}
50
51 //! Move constructor
52 collection( collection&& c ) : m_col( std::forward<C>( c.m_col ) ) {}
53
54 //! Returns the underlying collection
55 C const& col() const { return m_col; }
56
57 //! dataset interface
58 data::size_t size() const { return m_col.size(); }
59 iterator begin() const { return m_col.begin(); }
60
61 private:
62 // Data members
63 C m_col;
64 };
65
66 //____________________________________________________________________________//
67
68 //! A collection from a forward iterable container is a dataset.
69 template<typename C>
70 struct is_dataset<collection<C>> : mpl::true_ {};
71
72 } // namespace monomorphic
73
74 //____________________________________________________________________________//
75
76 //! @overload boost::unit_test::data::make()
77 template<typename C>
78 inline typename std::enable_if<is_forward_iterable<C>::value,monomorphic::collection<C>>::type
79 make( C&& c )
80 {
81 return monomorphic::collection<C>( std::forward<C>(c) );
82 }
83
84 } // namespace data
85 } // namespace unit_test
86 } // namespace boost
87
88 #include <boost/test/detail/enable_warnings.hpp>
89
90 #endif // BOOST_TEST_DATA_MONOMORPHIC_COLLECTION_HPP_102211GER
91