|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81295 - in trunk/boost/test/data: . monomorphic monomorphic/generators
From: gennadiy.rozental_at_[hidden]
Date: 2012-11-11 07:06:17
Author: rogeeff
Date: 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
New Revision: 81295
URL: http://svn.boost.org/trac/boost/changeset/81295
Log:
various portability fixes to allow data driven test cases (partially) on pre c++11 compilers
Text files modified:
trunk/boost/test/data/config.hpp | 3 +
trunk/boost/test/data/monomorphic/array.hpp | 5 +-
trunk/boost/test/data/monomorphic/collection.hpp | 25 +++++++++++----
trunk/boost/test/data/monomorphic/dataset.hpp | 17 ++++++----
trunk/boost/test/data/monomorphic/fwd.hpp | 65 +++++++++++++++++++++++++++++++++------
trunk/boost/test/data/monomorphic/generate.hpp | 17 ++++++++-
trunk/boost/test/data/monomorphic/generators/random.hpp | 11 ++++--
trunk/boost/test/data/monomorphic/generators/xrange.hpp | 3 +
trunk/boost/test/data/monomorphic/grid.hpp | 24 +++++++-------
trunk/boost/test/data/monomorphic/join.hpp | 51 +++++++++++++++++++++---------
trunk/boost/test/data/monomorphic/singleton.hpp | 44 +++++++++++++++++++-------
trunk/boost/test/data/monomorphic/zip.hpp | 24 +++++++-------
trunk/boost/test/data/test_case.hpp | 23 ++++++++++++-
13 files changed, 223 insertions(+), 89 deletions(-)
Modified: trunk/boost/test/data/config.hpp
==============================================================================
--- trunk/boost/test/data/config.hpp (original)
+++ trunk/boost/test/data/config.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -18,6 +18,9 @@
// Boost.Test
#include <boost/test/detail/config.hpp>
+// STL
+#include <stdexcept> // for std::logic_error
+
//____________________________________________________________________________//
#define BOOST_TEST_DS_ERROR( msg ) throw std::logic_error( msg )
Modified: trunk/boost/test/data/monomorphic/array.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/array.hpp (original)
+++ trunk/boost/test/data/monomorphic/array.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -17,7 +17,6 @@
// Boost.Test
#include <boost/test/data/config.hpp>
-#include <boost/test/data/size.hpp>
#include <boost/test/data/monomorphic/dataset.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -66,7 +65,7 @@
// dataset interface
virtual data::size_t size() const { return m_size; }
- virtual iter_ptr begin() const { return std::make_shared<iterator>( m_arr, m_size ); }
+ virtual iter_ptr begin() const { return boost::make_shared<iterator>( m_arr, m_size ); }
private:
// Data members
@@ -77,7 +76,7 @@
//____________________________________________________________________________//
template<typename T>
-struct is_dataset<array<T>> : std::true_type {};
+struct is_dataset<array<T> > : mpl::true_ {};
} // namespace monomorphic
Modified: trunk/boost/test/data/monomorphic/collection.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/collection.hpp (original)
+++ trunk/boost/test/data/monomorphic/collection.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -33,8 +33,8 @@
// ************************************************************************** //
template<typename C>
-class collection : public monomorphic::dataset<typename std::decay<C>::type::value_type> {
- typedef typename std::decay<C>::type col_type;
+class collection : public monomorphic::dataset<typename boost::decay<C>::type::value_type> {
+ typedef typename boost::decay<C>::type col_type;
typedef typename col_type::value_type T;
typedef monomorphic::dataset<T> base;
typedef typename base::iter_ptr iter_ptr;
@@ -59,18 +59,22 @@
public:
enum { arity = 1 };
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
// Constructor
- explicit collection( C&& col ) : m_col( std::forward<C>(col) ) {}
+ explicit collection( C&& col ) : m_col( std::forward<C>(col) ) {}
// Move constructor
collection( collection&& c ) : m_col( std::forward<C>( c.m_col ) ) {}
+#else
+ explicit collection( C const& col ) : m_col( col ) {}
+#endif
// Access methods
- C const& col() const { return m_col; }
+ C const& col() const { return m_col; }
// dataset interface
virtual data::size_t size() const { return m_col.size(); }
- virtual iter_ptr begin() const { return std::make_shared<iterator>( *this ); }
+ virtual iter_ptr begin() const { return boost::make_shared<iterator>( *this ); }
private:
// Data members
@@ -80,16 +84,23 @@
//____________________________________________________________________________//
template<typename C>
-struct is_dataset<collection<C>> : std::true_type {};
+struct is_dataset<collection<C> > : mpl::true_ {};
} // namespace monomorphic
template<typename C>
-inline monomorphic::collection<typename std::enable_if<is_forward_iterable<C>::value,C>::type>
+inline monomorphic::collection<typename BOOST_TEST_ENABLE_IF<is_forward_iterable<C>::value,C>::type>
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
make( C&& c )
{
return monomorphic::collection<C>( std::forward<C>(c) );
}
+#else
+make( C const& c )
+{
+ return monomorphic::collection<C>( c );
+}
+#endif
//____________________________________________________________________________//
Modified: trunk/boost/test/data/monomorphic/dataset.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/dataset.hpp (original)
+++ trunk/boost/test/data/monomorphic/dataset.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -17,13 +17,13 @@
// Boost.Test
#include <boost/test/data/config.hpp>
-#include <boost/test/data/size.hpp>
#include <boost/test/data/monomorphic/fwd.hpp>
// STL
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
#include <tuple>
-#include <memory>
-#include <stdexcept>
+#endif
+//#include <stdexcept>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -53,6 +53,7 @@
//____________________________________________________________________________//
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
// !! ?? reimplement using variadics
template<typename T1, typename T2>
struct traits<std::tuple<T1,T2>> {
@@ -84,6 +85,8 @@
//____________________________________________________________________________//
+#endif
+
// ************************************************************************** //
// ************** monomorphic::dataset ************** //
// ************************************************************************** //
@@ -106,7 +109,7 @@
virtual void operator++() = 0;
};
- typedef std::shared_ptr<iterator> iter_ptr;
+ typedef boost::shared_ptr<iterator> iter_ptr;
// dataset size
virtual data::size_t size() const = 0;
@@ -126,10 +129,10 @@
Action const& act,
data::size_t number_of_samples = BOOST_TEST_DS_INFINITE_SIZE )
{
- auto size = (std::min)( ds.size(), number_of_samples );
+ data::size_t size = (std::min)( ds.size(), number_of_samples );
BOOST_TEST_DS_ASSERT( !size.is_inf(), "Dataset has infinite size. Please specify the number of samples" );
- auto it = ds.begin();
+ typename monomorphic::dataset<SampleType>::iter_ptr it = ds.begin();
while( size-- > 0 ) {
monomorphic::traits<SampleType>::invoke_action( **it, act );
@@ -140,7 +143,7 @@
//____________________________________________________________________________//
template<typename SampleType, typename Action>
-inline typename std::enable_if<!monomorphic::is_dataset<SampleType>::value,void>::type
+inline typename BOOST_TEST_ENABLE_IF<!monomorphic::is_dataset<SampleType>::value,void>::type
for_each_sample( SampleType const& samples,
Action const& act,
data::size_t number_of_samples = BOOST_TEST_DS_INFINITE_SIZE )
Modified: trunk/boost/test/data/monomorphic/fwd.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/fwd.hpp (original)
+++ trunk/boost/test/data/monomorphic/fwd.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -22,11 +22,15 @@
#include <boost/test/utils/is_forward_iterable.hpp>
// Boost
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+#include <boost/utility/enable_if.hpp>
+#else
#include <boost/utility/declval.hpp>
-
-// STL
-#include <list>
-#include <vector>
+#endif
+#include <boost/mpl/bool.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/type_traits/decay.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -53,12 +57,18 @@
template<typename T>
class array;
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+# define BOOST_TEST_ENABLE_IF std::enable_if
+#else
+# define BOOST_TEST_ENABLE_IF boost::enable_if_c
+#endif
+
// ************************************************************************** //
// ************** monomorphic::is_dataset ************** //
// ************************************************************************** //
template<typename DS>
-struct is_dataset : std::false_type {};
+struct is_dataset : mpl::false_ {};
//____________________________________________________________________________//
@@ -78,8 +88,10 @@
// ************** data::make ************** //
// ************************************************************************** //
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+
template<typename DS>
-inline typename std::enable_if<monomorphic::is_dataset<DS>::value,DS>::type
+inline typename BOOST_TEST_ENABLE_IF<monomorphic::is_dataset<DS>::value,DS>::type
make(DS&& ds)
{
return std::forward<DS>( ds );
@@ -88,19 +100,48 @@
//____________________________________________________________________________//
template<typename T>
-inline typename std::enable_if<!is_forward_iterable<T>::value &&
- !monomorphic::is_dataset<T>::value,
- monomorphic::singleton<T> >::type
+inline typename BOOST_TEST_ENABLE_IF<!is_forward_iterable<T>::value &&
+ !monomorphic::is_dataset<T>::value,
+ monomorphic::singleton<T>
+>::type
make( T&& v );
//____________________________________________________________________________//
template<typename C>
-inline monomorphic::collection<typename std::enable_if<unit_test::is_forward_iterable<C>::value,C>::type>
+inline monomorphic::collection<typename BOOST_TEST_ENABLE_IF<unit_test::is_forward_iterable<C>::value,C>::type>
make( C&& c );
//____________________________________________________________________________//
+#else
+
+template<typename DS>
+inline typename BOOST_TEST_ENABLE_IF<monomorphic::is_dataset<DS>::value,DS const&>::type
+make(DS const& ds)
+{
+ return ds;
+}
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline typename BOOST_TEST_ENABLE_IF<!is_forward_iterable<T>::value &&
+ !monomorphic::is_dataset<T>::value,
+ monomorphic::singleton<T>
+>::type
+make( T const& v );
+
+//____________________________________________________________________________//
+
+template<typename C>
+inline monomorphic::collection<typename BOOST_TEST_ENABLE_IF<unit_test::is_forward_iterable<C>::value,C>::type>
+make( C const& c );
+
+//____________________________________________________________________________//
+
+#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
+
template<typename T, std::size_t size>
inline monomorphic::array<T>
make( T (&a)[size] );
@@ -117,6 +158,8 @@
//____________________________________________________________________________//
+#ifndef BOOST_NO_CXX11_DECLTYPE
+
namespace result_of {
template<typename DS>
@@ -127,6 +170,8 @@
} // namespace result_of
+#endif // BOOST_NO_CXX11_DECLTYPE
+
//____________________________________________________________________________//
} // namespace data
Modified: trunk/boost/test/data/monomorphic/generate.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/generate.hpp (original)
+++ trunk/boost/test/data/monomorphic/generate.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -17,7 +17,6 @@
// Boost.Test
#include <boost/test/data/config.hpp>
-#include <boost/test/data/size.hpp>
#include <boost/test/data/monomorphic/dataset.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -58,14 +57,26 @@
enum { arity = 1 };
typedef Generator generator_type;
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
// Constructor
explicit generated_by( Generator&& G )
: m_generator( std::forward<Generator>(G) )
{}
+ // Move constructor
+ generated_by( generated_by&& rhs )
+ : m_generator( std::forward<Generator>(rhs.m_generator) )
+ {}
+#else
+ // Constructor
+ explicit generated_by( Generator const& G )
+ : m_generator( G )
+ {}
+#endif
+
// Access methods
data::size_t size() const { return m_generator.capacity(); }
- virtual iter_ptr begin() const { return std::make_shared<iterator>( const_cast<Generator&>(m_generator) ); }
+ virtual iter_ptr begin() const { return boost::make_shared<iterator>( boost::ref(const_cast<Generator&>(m_generator)) ); }
private:
// Data members
@@ -75,7 +86,7 @@
//____________________________________________________________________________//
template<typename Generator>
-struct is_dataset<generated_by<Generator>> : std::true_type {};
+struct is_dataset<generated_by<Generator> > : mpl::true_ {};
//____________________________________________________________________________//
Modified: trunk/boost/test/data/monomorphic/generators/random.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/generators/random.hpp (original)
+++ trunk/boost/test/data/monomorphic/generators/random.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -18,11 +18,11 @@
// Boost.Test
#include <boost/test/data/config.hpp>
+#ifndef BOOST_NO_0X_HDR_RANDOM
+
#include <boost/test/data/monomorphic/generate.hpp>
#include <boost/test/data/monomorphic/generators/keywords.hpp>
-// Boost
-
// STL
#include <random>
@@ -46,8 +46,8 @@
template<typename SampleType>
struct default_distribution {
typedef typename mpl::if_<std::is_integral<SampleType>,
- std::uniform_int_distribution<SampleType>,
- std::uniform_real_distribution<SampleType>>::type type;
+ std::uniform_int_distribution<SampleType>,
+ std::uniform_real_distribution<SampleType> >::type type;
};
} // namespace ds_detail
@@ -158,4 +158,7 @@
#include <boost/test/detail/enable_warnings.hpp>
+#endif // BOOST_NO_0X_HDR_RANDOM
+
+
#endif // BOOST_TEST_DATA_MONOMORPHIC_GENERATORS_RANDOM_HPP_101512GER
Modified: trunk/boost/test/data/monomorphic/generators/xrange.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/generators/xrange.hpp (original)
+++ trunk/boost/test/data/monomorphic/generators/xrange.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -28,6 +28,7 @@
// STL
#include <limits>
+#include <cmath>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -120,7 +121,7 @@
//____________________________________________________________________________//
template<typename SampleType, typename Params>
-inline monomorphic::generated_by<monomorphic::xrange_t<SampleType>>
+inline monomorphic::generated_by<monomorphic::xrange_t<SampleType> >
xrange( Params const& params )
{
return monomorphic::ds_detail::make_xrange<SampleType>::_( params );
Modified: trunk/boost/test/data/monomorphic/grid.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/grid.hpp (original)
+++ trunk/boost/test/data/monomorphic/grid.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -17,13 +17,12 @@
#ifndef BOOST_TEST_DATA_MONOMORPHIC_GRID_HPP_101512GER
#define BOOST_TEST_DATA_MONOMORPHIC_GRID_HPP_101512GER
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
+
// Boost.Test
#include <boost/test/data/config.hpp>
#include <boost/test/data/monomorphic/dataset.hpp>
-// Boost
-#include <boost/utility/enable_if.hpp>
-
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
@@ -85,10 +84,10 @@
// ************************************************************************** //
template<typename DS1, typename DS2>
-class grid : public monomorphic::dataset<typename ds_detail::grid_traits<typename std::decay<DS1>::type::data_type,
- typename std::decay<DS2>::type::data_type>::type> {
- typedef typename std::decay<DS1>::type::data_type T1;
- typedef typename std::decay<DS2>::type::data_type T2;
+class grid : public monomorphic::dataset<typename ds_detail::grid_traits<typename boost::decay<DS1>::type::data_type,
+ typename boost::decay<DS2>::type::data_type>::type> {
+ typedef typename boost::decay<DS1>::type::data_type T1;
+ typedef typename boost::decay<DS2>::type::data_type T2;
typedef typename monomorphic::dataset<T1>::iter_ptr ds1_iter_ptr;
typedef typename monomorphic::dataset<T2>::iter_ptr ds2_iter_ptr;
@@ -131,7 +130,7 @@
};
public:
- enum { arity = std::decay<DS1>::type::arity + std::decay<DS2>::type::arity };
+ enum { arity = boost::decay<DS1>::type::arity + boost::decay<DS2>::type::arity };
// Constructor
grid( DS1&& ds1, DS2&& ds2 )
@@ -147,7 +146,7 @@
// dataset interface
virtual data::size_t size() const { return m_ds1.size() * m_ds2.size(); }
- virtual iter_ptr begin() const { return std::make_shared<iterator>( m_ds1.begin(), m_ds2 ); }
+ virtual iter_ptr begin() const { return boost::make_shared<iterator>( m_ds1.begin(), m_ds2 ); }
private:
// Data members
@@ -158,15 +157,14 @@
//____________________________________________________________________________//
template<typename DS1, typename DS2>
-struct is_dataset<grid<DS1,DS2>> : std::true_type {};
+struct is_dataset<grid<DS1,DS2> > : mpl::true_ {};
//____________________________________________________________________________//
namespace result_of {
template<typename DS1Gen, typename DS2Gen>
-struct grid
-{
+struct grid {
typedef monomorphic::grid<typename DS1Gen::type,typename DS2Gen::type> type;
};
@@ -217,5 +215,7 @@
#include <boost/test/detail/enable_warnings.hpp>
+#endif // BOOST_NO_CXX11_HDR_TUPLE
+
#endif // BOOST_TEST_DATA_MONOMORPHIC_GRID_HPP_101512GER
Modified: trunk/boost/test/data/monomorphic/join.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/join.hpp (original)
+++ trunk/boost/test/data/monomorphic/join.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -17,12 +17,8 @@
// Boost.Test
#include <boost/test/data/config.hpp>
-#include <boost/test/data/size.hpp>
#include <boost/test/data/monomorphic/dataset.hpp>
-// Boost
-#include <boost/utility/enable_if.hpp>
-
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
@@ -37,16 +33,21 @@
// ************************************************************************** //
template<typename DS1, typename DS2>
-class join : public monomorphic::dataset<typename std::decay<DS1>::type::data_type> {
- typedef typename std::decay<DS1>::type::data_type T;
+class join : public monomorphic::dataset<typename boost::decay<DS1>::type::data_type> {
+ typedef typename boost::decay<DS1>::type::data_type T;
typedef monomorphic::dataset<T> base;
typedef typename base::iter_ptr iter_ptr;
struct iterator : public base::iterator {
// Constructor
explicit iterator( iter_ptr it1, iter_ptr it2, data::size_t first_size )
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
: m_it1( std::move(it1) )
, m_it2( std::move(it2) )
+#else
+ : m_it1( it1 )
+ , m_it2( it2 )
+#endif
, m_first_size( first_size )
{}
@@ -62,8 +63,9 @@
};
public:
- enum { arity = std::decay<DS1>::type::arity };
+ enum { arity = boost::decay<DS1>::type::arity };
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
// Constructor
join( DS1&& ds1, DS2&& ds2 )
: m_ds1( std::forward<DS1>( ds1 ) )
@@ -75,12 +77,19 @@
: m_ds1( std::forward<DS1>( j.m_ds1 ) )
, m_ds2( std::forward<DS2>( j.m_ds2 ) )
{}
+#else
+ // Constructor
+ join( DS1 const& ds1, DS2 const& ds2 )
+ : m_ds1( ds1 )
+ , m_ds2( ds2 )
+ {}
+#endif
// dataset interface
virtual data::size_t size() const { return m_ds1.size() + m_ds2.size(); }
- virtual iter_ptr begin() const { return std::make_shared<iterator>( m_ds1.begin(),
- m_ds2.begin(),
- m_ds1.size() ); }
+ virtual iter_ptr begin() const { return boost::make_shared<iterator>( m_ds1.begin(),
+ m_ds2.begin(),
+ m_ds1.size() ); }
private:
// Data members
@@ -91,15 +100,14 @@
//____________________________________________________________________________//
template<typename DS1, typename DS2>
-struct is_dataset<join<DS1,DS2>> : std::true_type {};
+struct is_dataset<join<DS1,DS2> > : mpl::true_ {};
//____________________________________________________________________________//
namespace result_of {
template<typename DS1Gen, typename DS2Gen>
-struct join
-{
+struct join {
typedef monomorphic::join<typename DS1Gen::type,typename DS2Gen::type> type;
};
@@ -109,18 +117,27 @@
template<typename DS1, typename DS2>
inline typename boost::lazy_enable_if_c<is_dataset<DS1>::value && is_dataset<DS2>::value,
- result_of::join<mpl::identity<DS1>,mpl::identity<DS2>>
+ result_of::join<mpl::identity<DS1>,mpl::identity<DS2> >
>::type
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
operator+( DS1&& ds1, DS2&& ds2 )
{
return join<DS1,DS2>( std::forward<DS1>( ds1 ), std::forward<DS2>( ds2 ) );
}
+#else
+operator+( DS1 const& ds1, DS2 const& ds2 )
+{
+ return join<DS1,DS2>( ds1, ds2 );
+}
+#endif
//____________________________________________________________________________//
+#ifndef BOOST_NO_CXX11_DECLTYPE
+
template<typename DS1, typename DS2>
inline typename boost::lazy_enable_if_c<is_dataset<DS1>::value && !is_dataset<DS2>::value,
- result_of::join<mpl::identity<DS1>,data::result_of::make<DS2>>
+ result_of::join<mpl::identity<DS1>,data::result_of::make<DS2> >
>::type
operator+( DS1&& ds1, DS2&& ds2 )
{
@@ -131,7 +148,7 @@
template<typename DS1, typename DS2>
inline typename boost::lazy_enable_if_c<!is_dataset<DS1>::value && is_dataset<DS2>::value,
- result_of::join<data::result_of::make<DS1>,mpl::identity<DS2>>
+ result_of::join<data::result_of::make<DS1>,mpl::identity<DS2> >
>::type
operator+( DS1&& ds1, DS2&& ds2 )
{
@@ -140,6 +157,8 @@
//____________________________________________________________________________//
+#endif
+
} // namespace monomorphic
} // namespace data
Modified: trunk/boost/test/data/monomorphic/singleton.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/singleton.hpp (original)
+++ trunk/boost/test/data/monomorphic/singleton.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -17,7 +17,6 @@
// Boost.Test
#include <boost/test/data/config.hpp>
-#include <boost/test/data/size.hpp>
#include <boost/test/data/monomorphic/dataset.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -35,8 +34,8 @@
// Models single element data set
template<typename T>
-class singleton : public monomorphic::dataset<typename std::decay<T>::type> {
- typedef monomorphic::dataset<typename std::decay<T>::type> base;
+class singleton : public monomorphic::dataset<typename boost::decay<T>::type> {
+ typedef monomorphic::dataset<typename boost::decay<T>::type> base;
typedef typename base::iter_ptr iter_ptr;
struct iterator : public base::iterator {
@@ -55,18 +54,23 @@
public:
enum { arity = 1 };
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
// Constructor
- explicit singleton( T&& value ) : m_value( std::forward<T>( value ) ) {}
+ explicit singleton( T&& value ) : m_value( std::forward<T>( value ) ) {}
// Move constructor
singleton( singleton&& s ) : m_value( std::forward<T>( s.m_value ) ) {}
+#else
+ // Constructor
+ explicit singleton( T const& value ) : m_value( value ) {}
+#endif
// Access methods
- T const& value() const { return m_value; }
+ T const& value() const { return m_value; }
// dataset interface
virtual data::size_t size() const { return 1; }
- virtual iter_ptr begin() const { return std::make_shared<iterator>( *this ); }
+ virtual iter_ptr begin() const { return boost::make_shared<iterator>( *this ); }
private:
// Data members
@@ -76,25 +80,37 @@
//____________________________________________________________________________//
template<typename T>
-struct is_dataset<singleton<T>> : std::true_type {};
+struct is_dataset<singleton<T> > : mpl::true_ {};
} // namespace monomorphic
template<typename T>
-inline typename std::enable_if<!is_forward_iterable<T>::value &&
- !monomorphic::is_dataset<T>::value,
- monomorphic::singleton<T> >::type
+inline typename BOOST_TEST_ENABLE_IF<!is_forward_iterable<T>::value &&
+ !monomorphic::is_dataset<T>::value,
+ monomorphic::singleton<T>
+>::type
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
make( T&& v )
{
return monomorphic::singleton<T>( std::forward<T>( v ) );
}
+#else
+make( T const& v )
+{
+ return monomorphic::singleton<T>( v );
+}
+#endif
//____________________________________________________________________________//
inline monomorphic::singleton<char*>
make( char* str )
{
- return monomorphic::singleton<char*>( std::forward<char*>( str ) );
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ return monomorphic::singleton<char*>( std::move(str) );
+#else
+ return monomorphic::singleton<char*>( str );
+#endif
}
//____________________________________________________________________________//
@@ -102,7 +118,11 @@
inline monomorphic::singleton<char const*>
make( char const* str )
{
- return monomorphic::singleton<char const*>( std::forward<char const*>( str ) );
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ return monomorphic::singleton<char const*>( std::move(str) );
+#else
+ return monomorphic::singleton<char const*>( str );
+#endif
}
//____________________________________________________________________________//
Modified: trunk/boost/test/data/monomorphic/zip.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/zip.hpp (original)
+++ trunk/boost/test/data/monomorphic/zip.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -15,13 +15,12 @@
#ifndef BOOST_TEST_DATA_MONOMORPHIC_ZIP_HPP_102211GER
#define BOOST_TEST_DATA_MONOMORPHIC_ZIP_HPP_102211GER
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
+
// Boost.Test
#include <boost/test/data/config.hpp>
#include <boost/test/data/monomorphic/dataset.hpp>
-// Boost
-#include <boost/utility/enable_if.hpp>
-
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
@@ -83,10 +82,10 @@
// ************************************************************************** //
template<typename DS1, typename DS2>
-class zip : public monomorphic::dataset<typename ds_detail::zip_traits<typename std::decay<DS1>::type::data_type,
- typename std::decay<DS2>::type::data_type>::type> {
- typedef typename std::decay<DS1>::type::data_type T1;
- typedef typename std::decay<DS2>::type::data_type T2;
+class zip : public monomorphic::dataset<typename ds_detail::zip_traits<typename boost::decay<DS1>::type::data_type,
+ typename boost::decay<DS2>::type::data_type>::type> {
+ typedef typename boost::decay<DS1>::type::data_type T1;
+ typedef typename boost::decay<DS2>::type::data_type T2;
typedef typename monomorphic::dataset<T1>::iter_ptr ds1_iter_ptr;
typedef typename monomorphic::dataset<T2>::iter_ptr ds2_iter_ptr;
@@ -115,7 +114,7 @@
};
public:
- enum { arity = std::decay<DS1>::type::arity + std::decay<DS2>::type::arity };
+ enum { arity = boost::decay<DS1>::type::arity + boost::decay<DS2>::type::arity };
// Constructor
zip( DS1&& ds1, DS2&& ds2, data::size_t size )
@@ -133,7 +132,7 @@
// dataset interface
virtual data::size_t size() const { return m_size; }
- virtual iter_ptr begin() const { return std::make_shared<iterator>( m_ds1.begin(), m_ds2.begin() ); }
+ virtual iter_ptr begin() const { return boost::make_shared<iterator>( m_ds1.begin(), m_ds2.begin() ); }
private:
// Data members
@@ -145,7 +144,7 @@
//____________________________________________________________________________//
template<typename DS1, typename DS2>
-struct is_dataset<zip<DS1,DS2>> : std::true_type {};
+struct is_dataset<zip<DS1,DS2> > : mpl::true_ {};
//____________________________________________________________________________//
@@ -177,8 +176,7 @@
namespace result_of {
template<typename DS1Gen, typename DS2Gen>
-struct zip
-{
+struct zip {
typedef monomorphic::zip<typename DS1Gen::type,typename DS2Gen::type> type;
};
@@ -227,5 +225,7 @@
#include <boost/test/detail/enable_warnings.hpp>
+#endif // BOOST_NO_CXX11_HDR_TUPLE
+
#endif // BOOST_TEST_DATA_MONOMORPHIC_ZIP_HPP_102211GER
Modified: trunk/boost/test/data/test_case.hpp
==============================================================================
--- trunk/boost/test/data/test_case.hpp (original)
+++ trunk/boost/test/data/test_case.hpp 2012-11-11 07:06:15 EST (Sun, 11 Nov 2012)
@@ -33,6 +33,8 @@
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/comparison/equal.hpp>
+#include <boost/bind.hpp>
+
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
@@ -51,15 +53,23 @@
class test_case_gen : public test_unit_generator {
public:
// Constructor
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DS&& ds )
: m_tc_name( ut_detail::normalize_test_case_name( tc_name ) )
{
- data::for_each_sample( ds, *this );
+ data::for_each_sample( std::forward<DS>( ds ), *this );
}
test_case_gen( test_case_gen&& gen )
: m_tc_name( gen.m_tc_name )
, m_test_cases( std::move(gen.m_test_cases) )
{}
+#else
+ test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DS const& ds )
+ : m_tc_name( ut_detail::normalize_test_case_name( tc_name ) )
+ {
+ data::for_each_sample( ds, *this );
+ }
+#endif
virtual test_unit* next() const
{
@@ -78,7 +88,7 @@
void operator()( BOOST_PP_ENUM_BINARY_PARAMS(arity, Arg, const& arg) ) const \
{ \
m_test_cases.push_back( new test_case( m_tc_name, m_tc_file, m_tc_line, \
- std::bind( &TestCase::template test_method<BOOST_PP_ENUM_PARAMS(arity,Arg)>, \
+ boost::bind( &TestCase::template test_method<BOOST_PP_ENUM_PARAMS(arity,Arg)>, \
BOOST_PP_ENUM_PARAMS(arity, arg) ) ) ); \
} \
@@ -94,12 +104,21 @@
//____________________________________________________________________________//
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template<typename TestCase,typename DS>
test_case_gen<TestCase,DS>
make_test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DS&& ds )
{
return test_case_gen<TestCase,DS>( tc_name, tc_file, tc_line, std::forward<DS>(ds) );
}
+#else
+template<typename TestCase,typename DS>
+test_case_gen<TestCase,DS>
+make_test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DS const& ds )
+{
+ return test_case_gen<TestCase,DS>( tc_name, tc_file, tc_line, ds );
+}
+#endif
//____________________________________________________________________________//
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk