Warning, file /include/boost/test/data/monomorphic/grid.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
0013
0014 #ifndef BOOST_TEST_DATA_MONOMORPHIC_GRID_HPP_101512GER
0015 #define BOOST_TEST_DATA_MONOMORPHIC_GRID_HPP_101512GER
0016
0017
0018 #include <boost/test/data/config.hpp>
0019
0020 #if !defined(BOOST_TEST_NO_GRID_COMPOSITION_AVAILABLE) || defined(BOOST_TEST_DOXYGEN_DOC__)
0021
0022 #include <boost/test/data/monomorphic/fwd.hpp>
0023 #include <boost/test/data/monomorphic/sample_merge.hpp>
0024
0025 #include <boost/core/enable_if.hpp>
0026 #include <boost/mpl/identity.hpp>
0027
0028 #include <boost/test/detail/suppress_warnings.hpp>
0029
0030
0031
0032 namespace boost {
0033 namespace unit_test {
0034 namespace data {
0035 namespace monomorphic {
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 template<typename DataSet1, typename DataSet2>
0046 class grid {
0047 typedef typename boost::decay<DataSet1>::type dataset1_decay;
0048 typedef typename boost::decay<DataSet2>::type dataset2_decay;
0049
0050 typedef typename dataset1_decay::iterator dataset1_iter;
0051 typedef typename dataset2_decay::iterator dataset2_iter;
0052
0053 public:
0054
0055 struct iterator {
0056
0057 explicit iterator( dataset1_iter iter1, DataSet2 const& ds2 )
0058 : m_iter1( std::move( iter1 ) )
0059 , m_iter2( ds2.begin() )
0060 , m_ds2( &ds2 )
0061 , m_ds2_pos( 0 )
0062 {}
0063
0064 using iterator_sample = decltype(
0065 sample_merge( *std::declval<dataset1_iter>(),
0066 *std::declval<dataset2_iter>()) );
0067
0068
0069 auto operator*() const -> iterator_sample {
0070 return sample_merge( *m_iter1, *m_iter2 );
0071 }
0072 void operator++()
0073 {
0074 ++m_ds2_pos;
0075 if( m_ds2_pos != m_ds2->size() )
0076 ++m_iter2;
0077 else {
0078 m_ds2_pos = 0;
0079 ++m_iter1;
0080 m_iter2 = std::move( m_ds2->begin() );
0081 }
0082 }
0083
0084 private:
0085
0086 dataset1_iter m_iter1;
0087 dataset2_iter m_iter2;
0088 dataset2_decay const* m_ds2;
0089 data::size_t m_ds2_pos;
0090 };
0091
0092 public:
0093 static const int arity = boost::decay<DataSet1>::type::arity + boost::decay<DataSet2>::type::arity;
0094
0095
0096 grid( DataSet1&& ds1, DataSet2&& ds2 )
0097 : m_ds1( std::forward<DataSet1>( ds1 ) )
0098 , m_ds2( std::forward<DataSet2>( ds2 ) )
0099 {}
0100
0101
0102 grid( grid&& j )
0103 : m_ds1( std::forward<DataSet1>( j.m_ds1 ) )
0104 , m_ds2( std::forward<DataSet2>( j.m_ds2 ) )
0105 {}
0106
0107
0108 data::size_t size() const {
0109 BOOST_TEST_DS_ASSERT( !m_ds1.size().is_inf() && !m_ds2.size().is_inf(), "Grid axes can't have infinite size" );
0110 return m_ds1.size() * m_ds2.size();
0111 }
0112 iterator begin() const { return iterator( m_ds1.begin(), m_ds2 ); }
0113
0114 private:
0115
0116 DataSet1 m_ds1;
0117 DataSet2 m_ds2;
0118 };
0119
0120
0121
0122
0123 template<typename DataSet1, typename DataSet2>
0124 struct is_dataset<grid<DataSet1,DataSet2>> : mpl::true_ {};
0125
0126
0127
0128 namespace result_of {
0129
0130
0131 template<typename DS1Gen, typename DS2Gen>
0132 struct grid {
0133 typedef monomorphic::grid<typename DS1Gen::type,typename DS2Gen::type> type;
0134 };
0135
0136 }
0137
0138
0139
0140
0141 template<typename DataSet1, typename DataSet2>
0142 inline typename boost::lazy_enable_if_c<is_dataset<DataSet1>::value && is_dataset<DataSet2>::value,
0143 result_of::grid<mpl::identity<DataSet1>,mpl::identity<DataSet2>>
0144 >::type
0145 operator*( DataSet1&& ds1, DataSet2&& ds2 )
0146 {
0147 return grid<DataSet1,DataSet2>( std::forward<DataSet1>( ds1 ), std::forward<DataSet2>( ds2 ) );
0148 }
0149
0150
0151
0152
0153 template<typename DataSet1, typename DataSet2>
0154 inline typename boost::lazy_enable_if_c<is_dataset<DataSet1>::value && !is_dataset<DataSet2>::value,
0155 result_of::grid<mpl::identity<DataSet1>,data::result_of::make<DataSet2>>
0156 >::type
0157 operator*( DataSet1&& ds1, DataSet2&& ds2 )
0158 {
0159 return std::forward<DataSet1>(ds1) * data::make(std::forward<DataSet2>(ds2));
0160 }
0161
0162
0163
0164
0165 template<typename DataSet1, typename DataSet2>
0166 inline typename boost::lazy_enable_if_c<!is_dataset<DataSet1>::value && is_dataset<DataSet2>::value,
0167 result_of::grid<data::result_of::make<DataSet1>,mpl::identity<DataSet2>>
0168 >::type
0169 operator*( DataSet1&& ds1, DataSet2&& ds2 )
0170 {
0171 return data::make(std::forward<DataSet1>(ds1)) * std::forward<DataSet2>(ds2);
0172 }
0173
0174 }
0175
0176 }
0177 }
0178 }
0179
0180 #include <boost/test/detail/enable_warnings.hpp>
0181
0182 #endif
0183
0184 #endif
0185