Warning, file /include/boost/test/data/monomorphic/initializer_list.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_TEST_DATA_MONOMORPHIC_INITIALIZATION_LIST_HPP_091515GER
0013 #define BOOST_TEST_DATA_MONOMORPHIC_INITIALIZATION_LIST_HPP_091515GER
0014
0015
0016 #include <boost/test/data/config.hpp>
0017 #include <boost/test/data/monomorphic/fwd.hpp>
0018
0019 #include <boost/core/ignore_unused.hpp>
0020
0021 #include <vector>
0022
0023 #include <boost/test/detail/suppress_warnings.hpp>
0024
0025
0026
0027 namespace boost {
0028 namespace unit_test {
0029 namespace data {
0030 namespace monomorphic {
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 template<typename T>
0042 class init_list {
0043 public:
0044 static const int arity = 1;
0045
0046 typedef typename std::vector<T>::const_iterator iterator;
0047
0048
0049 init_list( std::initializer_list<T> il )
0050 : m_data( il )
0051 {}
0052
0053 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0054 !defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
0055
0056 template <class ...Args>
0057 init_list( Args&& ... args ) {
0058 int dummy[] = { 0, (m_data.emplace_back(std::forward<Args&&>(args)), 0)... };
0059 boost::ignore_unused(dummy);
0060 }
0061 #endif
0062
0063
0064 data::size_t size() const { return m_data.size(); }
0065 iterator begin() const { return m_data.begin(); }
0066
0067 private:
0068
0069 std::vector<T> m_data;
0070 };
0071
0072
0073 template <>
0074 class init_list<bool> {
0075 public:
0076 typedef bool sample;
0077
0078 static const int arity = 1;
0079
0080
0081 init_list( std::initializer_list<bool>&& il )
0082 : m_data( std::forward<std::initializer_list<bool>>( il ) )
0083 {}
0084
0085 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0086 !defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
0087
0088 template <class ...Args>
0089 init_list( Args&& ... args ) : m_data{ args... }
0090 { }
0091 #endif
0092
0093 struct non_proxy_iterator {
0094 std::vector<bool>::const_iterator iterator;
0095 non_proxy_iterator(std::vector<bool>::const_iterator &&it)
0096 : iterator(std::forward<std::vector<bool>::const_iterator>(it))
0097 {}
0098
0099 bool operator*() const {
0100 return *iterator;
0101 }
0102
0103 non_proxy_iterator& operator++() {
0104 ++iterator;
0105 return *this;
0106 }
0107 };
0108
0109 typedef non_proxy_iterator iterator;
0110
0111
0112 data::size_t size() const { return m_data.size(); }
0113 iterator begin() const { return m_data.begin(); }
0114
0115 private:
0116
0117 std::vector<bool> m_data;
0118 };
0119
0120
0121
0122
0123 template<typename T>
0124 struct is_dataset<init_list<T>> : mpl::true_ {};
0125
0126 }
0127
0128
0129
0130
0131 template<typename T>
0132 inline monomorphic::init_list<T>
0133 make( std::initializer_list<T>&& il )
0134 {
0135 return monomorphic::init_list<T>( std::forward<std::initializer_list<T>>( il ) );
0136 }
0137
0138 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0139 !defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
0140 template<class T, class ...Args>
0141 inline typename std::enable_if<
0142 !monomorphic::has_dataset<T, Args...>::value,
0143 monomorphic::init_list<T>
0144 >::type
0145 make( T&& arg0, Args&&... args )
0146 {
0147 return monomorphic::init_list<T>( std::forward<T>(arg0), std::forward<Args>( args )... );
0148 }
0149 #endif
0150
0151
0152 }
0153 }
0154 }
0155
0156 #include <boost/test/detail/enable_warnings.hpp>
0157
0158 #endif
0159