]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/test/data/monomorphic/initializer_list.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / test / data / monomorphic / initializer_list.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 C++11 initializer_list template
10 // ***************************************************************************
11
12 #ifndef BOOST_TEST_DATA_MONOMORPHIC_INITIALIZATION_LIST_HPP_091515GER
13 #define BOOST_TEST_DATA_MONOMORPHIC_INITIALIZATION_LIST_HPP_091515GER
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 // ************** array ************** //
30 // ************************************************************************** //
31
32 /// Dataset view of a C array
33 template<typename T>
34 class init_list {
35 public:
36 typedef T sample;
37
38 enum { arity = 1 };
39
40 typedef T const* iterator;
41
42 //! Constructor swallows initializer_list
43 init_list( std::initializer_list<T>&& il )
44 : m_data( std::forward<std::initializer_list<T>>( il ) )
45 {}
46
47 //! dataset interface
48 data::size_t size() const { return m_data.size(); }
49 iterator begin() const { return m_data.begin(); }
50
51 private:
52 // Data members
53 std::initializer_list<T> m_data;
54 };
55
56 //____________________________________________________________________________//
57
58 //! An array dataset is a dataset
59 template<typename T>
60 struct is_dataset<init_list<T>> : mpl::true_ {};
61
62 } // namespace monomorphic
63
64 //____________________________________________________________________________//
65
66 //! @overload boost::unit_test::data::make()
67 template<typename T>
68 inline monomorphic::init_list<T>
69 make( std::initializer_list<T>&& il )
70 {
71 return monomorphic::init_list<T>( std::forward<std::initializer_list<T>>( il ) );
72 }
73
74 } // namespace data
75 } // namespace unit_test
76 } // namespace boost
77
78 #include <boost/test/detail/enable_warnings.hpp>
79
80 #endif // BOOST_TEST_DATA_MONOMORPHIC_INITIALIZATION_LIST_HPP_091515GER
81