]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae
FG
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
23namespace boost {
24namespace unit_test {
25namespace data {
26namespace 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.
38template<typename C>
39class collection {
40 typedef typename boost::decay<C>::type col_type;
41public:
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
61private:
62 // Data members
63 C m_col;
64};
65
66//____________________________________________________________________________//
67
68//! A collection from a forward iterable container is a dataset.
69template<typename C>
70struct is_dataset<collection<C>> : mpl::true_ {};
71
72} // namespace monomorphic
73
74//____________________________________________________________________________//
75
76//! @overload boost::unit_test::data::make()
77template<typename C>
78inline typename std::enable_if<is_forward_iterable<C>::value,monomorphic::collection<C>>::type
79make( 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