mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-25 01:57:15 +02:00
Merge from trunk
[SVN r81060]
This commit is contained in:
@ -8,6 +8,10 @@
|
|||||||
# bring in rules for testing
|
# bring in rules for testing
|
||||||
import testing ;
|
import testing ;
|
||||||
|
|
||||||
|
project
|
||||||
|
: requirements
|
||||||
|
;
|
||||||
|
|
||||||
{
|
{
|
||||||
test-suite fusion :
|
test-suite fusion :
|
||||||
|
|
||||||
@ -76,6 +80,7 @@ import testing ;
|
|||||||
[ run sequence/deque_iterator.cpp : : : : ]
|
[ run sequence/deque_iterator.cpp : : : : ]
|
||||||
[ run sequence/deque_make.cpp : : : : ]
|
[ run sequence/deque_make.cpp : : : : ]
|
||||||
[ run sequence/deque_misc.cpp : : : : ]
|
[ run sequence/deque_misc.cpp : : : : ]
|
||||||
|
[ run sequence/deque_move.cpp : : : : ]
|
||||||
[ run sequence/deque_mutate.cpp : : : : ]
|
[ run sequence/deque_mutate.cpp : : : : ]
|
||||||
[ run sequence/deque_tie.cpp : : : : ]
|
[ run sequence/deque_tie.cpp : : : : ]
|
||||||
[ run sequence/deque_value_at.cpp : : : : ]
|
[ run sequence/deque_value_at.cpp : : : : ]
|
||||||
@ -109,6 +114,7 @@ import testing ;
|
|||||||
[ run sequence/vector_iterator.cpp : : : : ]
|
[ run sequence/vector_iterator.cpp : : : : ]
|
||||||
[ run sequence/vector_make.cpp : : : : ]
|
[ run sequence/vector_make.cpp : : : : ]
|
||||||
[ run sequence/vector_misc.cpp : : : : ]
|
[ run sequence/vector_misc.cpp : : : : ]
|
||||||
|
[ run sequence/vector_move.cpp : : : : ]
|
||||||
[ run sequence/vector_mutate.cpp : : : : ]
|
[ run sequence/vector_mutate.cpp : : : : ]
|
||||||
[ run sequence/vector_n.cpp : : : : ]
|
[ run sequence/vector_n.cpp : : : : ]
|
||||||
[ run sequence/vector_tie.cpp : : : : ]
|
[ run sequence/vector_tie.cpp : : : : ]
|
||||||
|
@ -57,7 +57,7 @@ test()
|
|||||||
|
|
||||||
FUSION_SEQUENCE<> empty0;
|
FUSION_SEQUENCE<> empty0;
|
||||||
|
|
||||||
#ifndef TR1_TUPLE_TEST
|
#ifndef NO_CONSTRUCT_FROM_NIL
|
||||||
FUSION_SEQUENCE<> empty1(empty);
|
FUSION_SEQUENCE<> empty1(empty);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
32
test/sequence/deque_move.cpp
Normal file
32
test/sequence/deque_move.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2012 Joel de Guzman
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
==============================================================================*/
|
||||||
|
#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES // $$$ JDG temp $$$
|
||||||
|
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
|
|
||||||
|
#include <boost/fusion/container/deque/deque.hpp>
|
||||||
|
|
||||||
|
#define FUSION_SEQUENCE boost::fusion::deque
|
||||||
|
#include "move.hpp"
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
|
test();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
120
test/sequence/move.hpp
Normal file
120
test/sequence/move.hpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2012 Joel de Guzman
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
==============================================================================*/
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
|
#error "Valid only on compilers that support rvalues"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
namespace test_detail
|
||||||
|
{
|
||||||
|
int copies = 0;
|
||||||
|
|
||||||
|
void incr_copy()
|
||||||
|
{
|
||||||
|
copies++;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct x
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
x() : i(123) {}
|
||||||
|
|
||||||
|
x(x&& rhs) : i(rhs.i) {}
|
||||||
|
|
||||||
|
x& operator=(x&& rhs)
|
||||||
|
{
|
||||||
|
i = rhs.i;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
x(x const& rhs)
|
||||||
|
{
|
||||||
|
incr_copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
x& operator=(x const& rhs)
|
||||||
|
{
|
||||||
|
incr_copy();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<x> vector_type;
|
||||||
|
extern bool disable_rvo; // to disable RVO
|
||||||
|
|
||||||
|
vector_type
|
||||||
|
generate_vec()
|
||||||
|
{
|
||||||
|
vector_type v;
|
||||||
|
v.push_back(x());
|
||||||
|
if (disable_rvo)
|
||||||
|
return v;
|
||||||
|
return vector_type();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T move_me(T && val)
|
||||||
|
{
|
||||||
|
T r(std::move(val));
|
||||||
|
if (disable_rvo)
|
||||||
|
return r;
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef FUSION_SEQUENCE<std::vector<x>> return_type;
|
||||||
|
|
||||||
|
return_type
|
||||||
|
generate()
|
||||||
|
{
|
||||||
|
return_type r(generate_vec());
|
||||||
|
if (disable_rvo)
|
||||||
|
return r;
|
||||||
|
return return_type();
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef FUSION_SEQUENCE<std::vector<x>, x> return_type2;
|
||||||
|
|
||||||
|
return_type2
|
||||||
|
generate2()
|
||||||
|
{
|
||||||
|
return_type2 r(generate_vec(), x());
|
||||||
|
if (disable_rvo)
|
||||||
|
return r;
|
||||||
|
return return_type2();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
using namespace boost::fusion;
|
||||||
|
using namespace test_detail;
|
||||||
|
|
||||||
|
return_type v = move_me(generate());
|
||||||
|
BOOST_TEST(copies == 0);
|
||||||
|
|
||||||
|
return_type2 v2 = move_me(generate2());
|
||||||
|
BOOST_TEST(copies == 0);
|
||||||
|
|
||||||
|
v2 = move_me(generate2());
|
||||||
|
BOOST_TEST(copies == 0);
|
||||||
|
|
||||||
|
std::cout << "Copies: " << copies << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_detail
|
||||||
|
{
|
||||||
|
bool disable_rvo = true;
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
#include <boost/fusion/tuple/tuple.hpp>
|
#include <boost/fusion/tuple/tuple.hpp>
|
||||||
#include <boost/fusion/adapted/mpl.hpp>
|
#include <boost/fusion/adapted/mpl.hpp>
|
||||||
|
|
||||||
#define TR1_TUPLE_TEST
|
#define NO_CONSTRUCT_FROM_NIL
|
||||||
#define FUSION_SEQUENCE tuple
|
#define FUSION_SEQUENCE tuple
|
||||||
#define FUSION_AT get
|
#define FUSION_AT get
|
||||||
#include "construction.hpp"
|
#include "construction.hpp"
|
||||||
|
31
test/sequence/vector_move.cpp
Normal file
31
test/sequence/vector_move.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2012 Joel de Guzman
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
==============================================================================*/
|
||||||
|
#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES // $$$ JDG temp $$$
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
|
|
||||||
|
#include <boost/fusion/container/vector/vector.hpp>
|
||||||
|
|
||||||
|
#define FUSION_SEQUENCE boost::fusion::vector
|
||||||
|
#include "move.hpp"
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
|
test();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user