Warning, file /include/boost/test/data/monomorphic/delayed.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_DELAYED_HPP_062018GER
0013 #define BOOST_TEST_DATA_MONOMORPHIC_DELAYED_HPP_062018GER
0014
0015
0016 #include <boost/test/data/config.hpp>
0017 #include <boost/test/data/monomorphic/fwd.hpp>
0018 #include <boost/test/data/index_sequence.hpp>
0019
0020 #include <boost/core/ref.hpp>
0021
0022 #include <algorithm>
0023 #include <memory>
0024
0025 #include <boost/test/detail/suppress_warnings.hpp>
0026
0027
0028
0029 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0030 !defined(BOOST_NO_CXX11_HDR_TUPLE)
0031
0032 namespace boost {
0033 namespace unit_test {
0034 namespace data {
0035 namespace monomorphic {
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 template <class dataset_t, class ...Args>
0048 class delayed_dataset
0049 {
0050 public:
0051 static const int arity = dataset_t::arity;
0052 using iterator = decltype(std::declval<dataset_t>().begin());
0053
0054 delayed_dataset(Args... args)
0055 : m_args(std::make_tuple(std::forward<Args>(args)...))
0056 {}
0057
0058
0059 delayed_dataset(delayed_dataset&& b)
0060 : m_args(std::move(b.m_args))
0061 , m_dataset(std::move(b.m_dataset))
0062 {}
0063
0064 boost::unit_test::data::size_t size() const {
0065 return this->get().size();
0066 }
0067
0068
0069 iterator begin() const {
0070 return this->get().begin();
0071 }
0072
0073 private:
0074
0075 dataset_t& get() const {
0076 if(!m_dataset) {
0077 m_dataset = create(boost::unit_test::data::index_sequence_for<Args...>());
0078 }
0079 return *m_dataset;
0080 }
0081
0082 template<std::size_t... I>
0083 std::unique_ptr<dataset_t>
0084 create(boost::unit_test::data::index_sequence<I...>) const
0085 {
0086 return std::unique_ptr<dataset_t>{new dataset_t(std::get<I>(m_args)...)};
0087 }
0088
0089 std::tuple<typename std::decay<Args>::type...> m_args;
0090 mutable std::unique_ptr<dataset_t> m_dataset;
0091 };
0092
0093
0094
0095
0096 template <class dataset_t, class ...Args>
0097 struct is_dataset< delayed_dataset<dataset_t, Args...> > : boost::mpl::true_ {};
0098
0099
0100
0101 }
0102
0103
0104
0105 template<class dataset_t, class ...Args>
0106 inline typename std::enable_if<
0107 monomorphic::is_dataset< dataset_t >::value,
0108 monomorphic::delayed_dataset<dataset_t, Args...>
0109 >::type
0110 make_delayed(Args... args)
0111 {
0112 return monomorphic::delayed_dataset<dataset_t, Args...>( std::forward<Args>(args)... );
0113 }
0114
0115
0116 }
0117 }
0118 }
0119
0120 #endif
0121
0122 #include <boost/test/detail/enable_warnings.hpp>
0123
0124 #endif