diff options
Diffstat (limited to 'src/boost/libs/phoenix/test/boost_bind_compatibility')
40 files changed, 4952 insertions, 0 deletions
diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_and_or_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_and_or_test.cpp new file mode 100644 index 000000000..e0f5767d4 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_and_or_test.cpp @@ -0,0 +1,77 @@ +/*============================================================================== + Copyright (c) 2008 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/operator.hpp> + +#include <iostream> +#include <boost/detail/lightweight_test.hpp> + +bool +f(bool x) +{ + return x; +} + +bool +g(bool x) +{ + return !x; +} + +bool +h() +{ + BOOST_ERROR("Short-circuit evaluation failure"); + return false; +} + +template <typename F, typename A1, typename A2, typename R> +void +tester(F f, A1 a1, A2 a2, R r) +{ + BOOST_TEST(f(a1, a2) == r); +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + using boost::phoenix::placeholders::_2; + + // && + + tester(bind(f, true) && bind(g, true), false, false, f(true) && g(true)); + tester(bind(f, true) && bind(g, false), false, false, f(true) && g(false)); + + tester(bind(f, false) && bind(h), false, false, f(false) && h()); + + tester(bind(f, _1) && bind(g, _2), true, true, f(true) && g(true)); + tester(bind(f, _1) && bind(g, _2), true, false, f(true) && g(false)); + + tester(bind(f, _1) && bind(h), false, false, f(false) && h()); + + // || + + tester(bind(f, false) || bind(g, true), false, false, f(false) || g(true)); + + tester(bind(f, false) || bind(g, false), false, false, f(false) || g(false)); + + tester(bind(f, true) || bind(h), false, false, f(true) || h()); + + tester(bind(f, _1) || bind(g, _2), false, true, f(false) || g(true)); + tester(bind(f, _1) || bind(g, _2), false, false, f(false) || g(false)); + + tester(bind(f, _1) || bind(h), true, false, f(true) || h()); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cdecl_mf_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cdecl_mf_test.cpp new file mode 100644 index 000000000..79e7577da --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cdecl_mf_test.cpp @@ -0,0 +1,146 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <boost/ref.hpp> + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int __cdecl f0() { f1(17); return 0; } + int __cdecl g0() const { g1(17); return 0; } + + int __cdecl f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int __cdecl g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int __cdecl f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int __cdecl g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int __cdecl f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int __cdecl g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int __cdecl f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int __cdecl g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int __cdecl f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int __cdecl g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int __cdecl f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int __cdecl g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int __cdecl f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int __cdecl g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int __cdecl f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int __cdecl g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + bind(&X::f0, &x)(); + bind(&X::f0, ref(x))(); + + bind(&X::g0, &x)(); + bind(&X::g0, x)(); + bind(&X::g0, ref(x))(); + + // 1 + + bind(&X::f1, &x, 1)(); + bind(&X::f1, ref(x), 1)(); + + bind(&X::g1, &x, 1)(); + bind(&X::g1, x, 1)(); + bind(&X::g1, ref(x), 1)(); + + // 2 + + bind(&X::f2, &x, 1, 2)(); + bind(&X::f2, ref(x), 1, 2)(); + + bind(&X::g2, &x, 1, 2)(); + bind(&X::g2, x, 1, 2)(); + bind(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3)(); + bind(&X::f3, ref(x), 1, 2, 3)(); + + bind(&X::g3, &x, 1, 2, 3)(); + bind(&X::g3, x, 1, 2, 3)(); + bind(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4)(); + bind(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind(&X::g4, &x, 1, 2, 3, 4)(); + bind(&X::g4, x, 1, 2, 3, 4)(); + bind(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind(&X::g5, x, 1, 2, 3, 4, 5)(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_const_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_const_test.cpp new file mode 100644 index 000000000..7c1daabc2 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_const_test.cpp @@ -0,0 +1,184 @@ +/*============================================================================== + Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd. + Copyright (c) 2001 David Abrahams + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long f_0() +{ + return 17041L; +} + +long f_1(long a) +{ + return a; +} + +long f_2(long a, long b) +{ + return a + 10 * b; +} + +long f_3(long a, long b, long c) +{ + return a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long f_6(long a, long b, long c, long d, long e, long f) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +long global_result; + +void fv_0() +{ + global_result = 17041L; +} + +void fv_1(long a) +{ + global_result = a; +} + +void fv_2(long a, long b) +{ + global_result = a + 10 * b; +} + +void fv_3(long a, long b, long c) +{ + global_result = a + 10 * b + 100 * c; +} + +void fv_4(long a, long b, long c, long d) +{ + global_result = a + 10 * b + 100 * c + 1000 * d; +} + +void fv_5(long a, long b, long c, long d, long e) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +void fv_6(long a, long b, long c, long d, long e, long f) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +void fv_7(long a, long b, long c, long d, long e, long f, long g) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +void fv_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +template<class F, class A> long tester(F const & f, A const & a) +{ + return f(a); +} + +template<class F, class A> long testerv(F const & f, A const & a) +{ + f(a); + return global_result; +} + +void function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + int const i = 1; + + BOOST_TEST( tester( bind(f_0), i ) == 17041L ); + BOOST_TEST( tester( bind(f_1, _1), i ) == 1L ); + BOOST_TEST( tester( bind(f_2, _1, 2), i ) == 21L ); + BOOST_TEST( tester( bind(f_3, _1, 2, 3), i ) == 321L ); + BOOST_TEST( tester( bind(f_4, _1, 2, 3, 4), i ) == 4321L ); + BOOST_TEST( tester( bind(f_5, _1, 2, 3, 4, 5), i ) == 54321L ); + BOOST_TEST( tester( bind(f_6, _1, 2, 3, 4, 5, 6), i ) == 654321L ); + BOOST_TEST( tester( bind(f_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L ); + BOOST_TEST( tester( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L ); + BOOST_TEST( tester( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L ); + + BOOST_TEST( testerv( bind(fv_0), i ) == 17041L ); + BOOST_TEST( testerv( bind(fv_1, _1), i ) == 1L ); + BOOST_TEST( testerv( bind(fv_2, _1, 2), i ) == 21L ); + BOOST_TEST( testerv( bind(fv_3, _1, 2, 3), i ) == 321L ); + BOOST_TEST( testerv( bind(fv_4, _1, 2, 3, 4), i ) == 4321L ); + BOOST_TEST( testerv( bind(fv_5, _1, 2, 3, 4, 5), i ) == 54321L ); + BOOST_TEST( testerv( bind(fv_6, _1, 2, 3, 4, 5, 6), i ) == 654321L ); + BOOST_TEST( testerv( bind(fv_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L ); + BOOST_TEST( testerv( bind(fv_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L ); + BOOST_TEST( testerv( bind(fv_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cv_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cv_test.cpp new file mode 100644 index 000000000..6a3326374 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cv_test.cpp @@ -0,0 +1,165 @@ +/*============================================================================== + Copyright (c) 2004 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + typedef int result_type; + + int operator()() + { + return 17041; + } + + int operator()() const + { + return -17041; + } + + int operator()(int x1) + { + return x1; + } + + int operator()(int x1) const + { + return -x1; + } + + int operator()(int x1, int x2) + { + return x1+x2; + } + + int operator()(int x1, int x2) const + { + return -(x1+x2); + } + + int operator()(int x1, int x2, int x3) + { + return x1+x2+x3; + } + + int operator()(int x1, int x2, int x3) const + { + return -(x1+x2+x3); + } + + int operator()(int x1, int x2, int x3, int x4) + { + return x1+x2+x3+x4; + } + + int operator()(int x1, int x2, int x3, int x4) const + { + return -(x1+x2+x3+x4); + } + + int operator()(int x1, int x2, int x3, int x4, int x5) + { + return x1+x2+x3+x4+x5; + } + + int operator()(int x1, int x2, int x3, int x4, int x5) const + { + return -(x1+x2+x3+x4+x5); + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6) + { + return x1+x2+x3+x4+x5+x6; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6) const + { + return -(x1+x2+x3+x4+x5+x6); + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) + { + return x1+x2+x3+x4+x5+x6+x7; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) const + { + return -(x1+x2+x3+x4+x5+x6+x7); + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) + { + return x1+x2+x3+x4+x5+x6+x7+x8; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) const + { + return -(x1+x2+x3+x4+x5+x6+x7+x8); + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) + { + return x1+x2+x3+x4+x5+x6+x7+x8+x9; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) const + { + return -(x1+x2+x3+x4+x5+x6+x7+x8+x9); + } +}; + +template<class F> void test(F f, int r) +{ + F const & cf = f; + BOOST_TEST( cf() == -r ); + BOOST_TEST( f() == r ); + +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::cref; + + test( bind(X()), 17041); + test( bind(X(), 1), 1); + test( bind(X(), 1, 2), 1+2); + test( bind(X(), 1, 2, 3), 1+2+3); + test( bind(X(), 1, 2, 3, 4), 1+2+3+4); + test( bind(X(), 1, 2, 3, 4, 5), 1+2+3+4+5); + test( bind(X(), 1, 2, 3, 4, 5, 6), 1+2+3+4+5+6); + test( bind(X(), 1, 2, 3, 4, 5, 6, 7), 1+2+3+4+5+6+7); + test( bind(X(), 1, 2, 3, 4, 5, 6, 7, 8), 1+2+3+4+5+6+7+8); + test( bind(X(), 1, 2, 3, 4, 5, 6, 7, 8, 9), 1+2+3+4+5+6+7+8+9); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm1_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm1_test.cpp new file mode 100644 index 000000000..68f50c070 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm1_test.cpp @@ -0,0 +1,77 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int m; +}; + +X f( int v ) +{ + X r = { v }; + return r; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + X x = { 17041 }; + X * px = &x; + + BOOST_TEST( bind( &X::m, _1 )( x ) == 17041 ); + BOOST_TEST( bind( &X::m, _1 )( px ) == 17041 ); + + BOOST_TEST( bind( &X::m, x )() == 17041 ); + BOOST_TEST( bind( &X::m, px )() == 17041 ); + BOOST_TEST( bind( &X::m, ref(x) )() == 17041 ); + + + X const cx = x; + X const * pcx = &cx; + + BOOST_TEST( bind( &X::m, _1 )( cx ) == 17041 ); + BOOST_TEST( bind( &X::m, _1 )( pcx ) == 17041 ); + + BOOST_TEST( bind( &X::m, cx )() == 17041 ); + BOOST_TEST( bind( &X::m, pcx )() == 17041 ); + BOOST_TEST( bind( &X::m, ref(cx) )() == 17041 ); + + int const v = 42; + // Change bind_dm_test.cpp to bind to _1 twice. + BOOST_TEST( bind( &X::m, _1)( bind( f, _1 )( v ) ) == v ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm2_test.cpp new file mode 100644 index 000000000..43680def5 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm2_test.cpp @@ -0,0 +1,74 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> +#include <string> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int m; +}; + +struct Y +{ + char m[ 64 ]; +}; + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + X x = { 0 }; + X * px = &x; + + bind( &X::m, _1 )( px ) = 42; + + BOOST_TEST( x.m == 42 ); + + bind( &X::m, ref(x) )() = 17041; + + BOOST_TEST( x.m == 17041 ); + + X const * pcx = &x; + + BOOST_TEST( bind( &X::m, _1 )( pcx ) == 17041L ); + BOOST_TEST( bind( &X::m, pcx )() == 17041L ); + + Y y = { "test" }; + std::string v( "test" ); + + BOOST_TEST( bind( &Y::m, &y )() == v ); + BOOST_TEST( bind( &Y::m, &y )() == v ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm3_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm3_test.cpp new file mode 100644 index 000000000..d50a4eaf8 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm3_test.cpp @@ -0,0 +1,55 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <utility> + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + typedef std::pair<int, int> pair_type; + + pair_type pair( 10, 20 ); + +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1600) && (BOOST_MSVC < 1700) +// bind is being confused with 'std::tr1::_Bind' to be found here +// C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxbind1(485) + int const & x = boost::phoenix::bind( &pair_type::first, _1 )( pair ); +#else + int const & x = bind( &pair_type::first, _1 )( pair ); +#endif + + BOOST_TEST( &pair.first == &x ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm_test.cpp new file mode 100644 index 000000000..5de4fc024 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm_test.cpp @@ -0,0 +1,88 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + Copyright (c) 2015 John Fletcher + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int m; +}; + +X f( int v ) +{ + X r = { v }; + return r; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + X x = { 17041 }; + X * px = &x; + + BOOST_TEST( bind( &X::m, _1 )( x ) == 17041 ); + BOOST_TEST( bind( &X::m, _1 )( px ) == 17041 ); + + BOOST_TEST( bind( &X::m, x )() == 17041 ); + BOOST_TEST( bind( &X::m, px )() == 17041 ); + BOOST_TEST( bind( &X::m, ref(x) )() == 17041 ); + + + X const cx = x; + X const * pcx = &cx; + + BOOST_TEST( bind( &X::m, _1 )( cx ) == 17041 ); + BOOST_TEST( bind( &X::m, _1 )( pcx ) == 17041 ); + + BOOST_TEST( bind( &X::m, cx )() == 17041 ); + BOOST_TEST( bind( &X::m, pcx )() == 17041 ); + BOOST_TEST( bind( &X::m, ref(cx) )() == 17041 ); + + int const v = 42; + +// NOTE: The second case does not work with compiler optimization. +// This is a bug which has not yet been fixed. +// The current test for gcc 4.7.3 does use -O2 but does not +// satisfy this first part of the test for some unknown reason. +// So this is set to run the first case for all gcc 4.7 +#if (defined(__OPTIMIZE__) && __OPTIMIZE__) || \ + defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700) && (BOOST_GCC_VERSION < 40800) + // Change bind_dm_test.cpp to bind to _1 twice. + BOOST_TEST( bind( &X::m, _1)( bind( f, _1 )( v ) ) == v ); +#else + BOOST_TEST( bind( &X::m, bind( f, _1 ) )( v ) == v ); +#endif + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq2_test.cpp new file mode 100644 index 000000000..b7203f49d --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq2_test.cpp @@ -0,0 +1,52 @@ +/*============================================================================== + Copyright (c) 2004, 2005, 2009 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/function_equal.hpp> +#include <boost/detail/lightweight_test.hpp> + +void f( int ) +{ +} + +int g( int i ) +{ + return i + 5; +} + +template< class F > void test_self_equal( F f ) +{ +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + using boost::function_equal; +#endif + + BOOST_TEST( function_equal( f, f ) ); +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + test_self_equal( bind( f, _1 ) ); + test_self_equal( bind( g, _1 ) ); + test_self_equal( bind( f, bind( g, _1 ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq3_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq3_test.cpp new file mode 100644 index 000000000..7340b63c1 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq3_test.cpp @@ -0,0 +1,48 @@ +/*============================================================================== + Copyright (c) 2004, 2005, 2009 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/function_equal.hpp> +#include <boost/weak_ptr.hpp> +#include <boost/detail/lightweight_test.hpp> + +int f( boost::weak_ptr<void> wp ) +{ + return wp.use_count(); +} + +template< class F > void test_self_equal( F f ) +{ +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + using boost::function_equal; +#endif + + BOOST_TEST( function_equal( f, f ) ); +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + test_self_equal( bind( f, _1 ) ); + test_self_equal( bind( f, boost::weak_ptr<void>() ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp new file mode 100644 index 000000000..ba33d531c --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp @@ -0,0 +1,438 @@ +/*============================================================================== + Copyright (c) 2004, 2005, 2009 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +# include <boost/function_equal.hpp> +#endif + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int i_; + + explicit X(int i): i_(i) + { + } + + bool operator==(X const & rhs) const + { + return i_ == rhs.i_; + } +}; + +// f_* + +int f_0() +{ + return 0; +} + +int f_1(X) +{ + return 0; +} + +int f_2(X, X) +{ + return 0; +} + +int f_3(X, X, X) +{ + return 0; +} + +int f_4(X, X, X, X) +{ + return 0; +} + +int f_5(X, X, X, X, X) +{ + return 0; +} + +int f_6(X, X, X, X, X, X) +{ + return 0; +} + +int f_7(X, X, X, X, X, X, X) +{ + return 0; +} + +int f_8(X, X, X, X, X, X, X, X) +{ + return 0; +} + +int f_9(X, X, X, X, X, X, X, X, X) +{ + return 0; +} + +// fv_* + +void fv_0() +{ +} + +void fv_1(X) +{ +} + +void fv_2(X, X) +{ +} + +void fv_3(X, X, X) +{ +} + +void fv_4(X, X, X, X) +{ +} + +void fv_5(X, X, X, X, X) +{ +} + +void fv_6(X, X, X, X, X, X) +{ +} + +void fv_7(X, X, X, X, X, X, X) +{ +} + +void fv_8(X, X, X, X, X, X, X, X) +{ +} + +void fv_9(X, X, X, X, X, X, X, X, X) +{ +} + +template<class F> void test_eq(F f1, F f2) +{ +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + + using boost::function_equal; + +#endif + + BOOST_TEST( function_equal( f1, f2 ) ); +} + +template<class F> void test_ne(F f1, F f2) +{ +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + + using boost::function_equal; + +#endif + + BOOST_TEST( !function_equal( f1, f2 ) ); +} + +using boost::phoenix::bind; +using boost::phoenix::ref; +using boost::phoenix::placeholders::_1; +using boost::phoenix::placeholders::_2; +using boost::phoenix::placeholders::_3; +using boost::phoenix::placeholders::_4; +using boost::phoenix::placeholders::_5; +using boost::phoenix::placeholders::_6; +using boost::phoenix::placeholders::_7; +using boost::phoenix::placeholders::_8; +using boost::phoenix::placeholders::_9; + +// 0 + +template<class F> void test_0(F f) +{ + test_eq( bind(f), bind(f) ); +} + +// 1 + +template<class F, class V> void test_1_(F f, V v1, V v2) +{ + test_eq( bind(f, v1), bind(f, v1) ); + test_ne( bind(f, v1), bind(f, v2) ); +} + +template<class F> void test_1(F f) +{ + test_eq( bind(f, _1), bind(f, _1) ); + + test_1_( f, X(1), X(2) ); + + X a(0), b(0); + test_1_( f, ref(a), ref(b) ); +} + +// 2 + +template<class F, class V> void test_2_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1), bind(f, v1, v1) ); + test_ne( bind(f, v1, v1), bind(f, v1, v2) ); + test_ne( bind(f, v1, v1), bind(f, v2, v1) ); +} + +template<class F> void test_2(F f) +{ + test_eq( bind(f, _1, _2), bind(f, _1, _2) ); + + test_2_( f, X(1), X(2) ); + + X a(0), b(0); + test_2_( f, ref(a), ref(b) ); +} + +// 3 + +template<class F, class V> void test_3_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1), bind(f, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1), bind(f, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1), bind(f, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1), bind(f, v2, v1, v1) ); +} + +template<class F> void test_3(F f) +{ + test_eq( bind(f, _1, _2, _3), bind(f, _1, _2, _3) ); + + test_3_( f, X(1), X(2) ); + + X a(0), b(0); + test_3_( f, ref(a), ref(b) ); +} + +// 4 + +template<class F, class V> void test_4_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1), bind(f, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1), bind(f, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1), bind(f, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1), bind(f, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1), bind(f, v2, v1, v1, v1) ); +} + +template<class F> void test_4(F f) +{ + test_eq( bind(f, _1, _2, _3, _4), bind(f, _1, _2, _3, _4) ); + + test_4_( f, X(1), X(2) ); + + X a(0), b(0); + test_4_( f, ref(a), ref(b) ); +} + +// 5 + +template<class F, class V> void test_5_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1) ); +} + +template<class F> void test_5(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5), bind(f, _1, _2, _3, _4, _5) ); + + test_5_( f, X(1), X(2) ); + + X a(0), b(0); + test_5_( f, ref(a), ref(b) ); +} + +// 6 + +template<class F, class V> void test_6_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_6(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5, _6), bind(f, _1, _2, _3, _4, _5, _6) ); + + test_6_( f, X(1), X(2) ); + + X a(0), b(0); + test_6_( f, ref(a), ref(b) ); +} + +// 7 + +template<class F, class V> void test_7_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_7(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5, _6, _7), bind(f, _1, _2, _3, _4, _5, _6, _7) ); + + test_7_( f, X(1), X(2) ); + + X a(0), b(0); + test_7_( f, ref(a), ref(b) ); +} + +// 8 + +template<class F, class V> void test_8_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_8(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5, _6, _7, _8), bind(f, _1, _2, _3, _4, _5, _6, _7, _8) ); + + test_8_( f, X(1), X(2) ); + + X a(0), b(0); + test_8_( f, ref(a), ref(b) ); +} + +// 9 + +template<class F, class V> void test_9_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_9(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5, _6, _7, _8, _9), bind(f, _1, _2, _3, _4, _5, _6, _7, _8, _9) ); + + test_9_( f, X(1), X(2) ); + + X a(0), b(0); + test_9_( f, ref(a), ref(b) ); +} + +int main() +{ + // 0 + + test_0( f_0 ); + test_0( fv_0 ); + + // 1 + + test_1( f_1 ); + test_1( fv_1 ); + + // 2 + + test_2( f_2 ); + test_2( fv_2 ); + + // 3 + + test_3( f_3 ); + test_3( fv_3 ); + + // 4 + + test_4( f_4 ); + test_4( fv_4 ); + + // 5 + + test_5( f_5 ); + test_5( fv_5 ); + + // 6 + + test_6( f_6 ); + test_6( fv_6 ); + + // 7 + + test_7( f_7 ); + test_7( fv_7 ); + + // 8 + + test_8( f_8 ); + test_8( fv_8 ); + + // 9 + + test_9( f_9 ); + test_9( fv_9 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_mf_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_mf_test.cpp new file mode 100644 index 000000000..1c7a6baa9 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_mf_test.cpp @@ -0,0 +1,165 @@ +/*============================================================================== + Copyright (c) 2001 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#define BOOST_MEM_FN_ENABLE_FASTCALL + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + void __fastcall f0() { f1(17); } + void __fastcall g0() const { g1(17); } + + void __fastcall f1(int a1) { hash = (hash * 17041 + a1) % 32768; } + void __fastcall g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; } + + void __fastcall f2(int a1, int a2) { f1(a1); f1(a2); } + void __fastcall g2(int a1, int a2) const { g1(a1); g1(a2); } + + void __fastcall f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); } + void __fastcall g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); } + + void __fastcall f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); } + void __fastcall g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); } + + void __fastcall f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); } + void __fastcall g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); } + + void __fastcall f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } + void __fastcall g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } + + void __fastcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } + void __fastcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } + + void __fastcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } + void __fastcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + bind(&X::f0, &x)(); + bind(&X::f0, ref(x))(); + + bind(&X::g0, &x)(); + bind(&X::g0, x)(); + bind(&X::g0, ref(x))(); + + // 1 + + bind(&X::f1, &x, 1)(); + bind(&X::f1, ref(x), 1)(); + + bind(&X::g1, &x, 1)(); + bind(&X::g1, x, 1)(); + bind(&X::g1, ref(x), 1)(); + + // 2 + + bind(&X::f2, &x, 1, 2)(); + bind(&X::f2, ref(x), 1, 2)(); + + bind(&X::g2, &x, 1, 2)(); + bind(&X::g2, x, 1, 2)(); + bind(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3)(); + bind(&X::f3, ref(x), 1, 2, 3)(); + + bind(&X::g3, &x, 1, 2, 3)(); + bind(&X::g3, x, 1, 2, 3)(); + bind(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4)(); + bind(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind(&X::g4, &x, 1, 2, 3, 4)(); + bind(&X::g4, x, 1, 2, 3, 4)(); + bind(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind(&X::g5, x, 1, 2, 3, 4, 5)(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_test.cpp new file mode 100644 index 000000000..14033a5c7 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_test.cpp @@ -0,0 +1,110 @@ +/*============================================================================== + Copyright (c) 2002 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#define BOOST_BIND_ENABLE_FASTCALL + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long __fastcall f_0() +{ + return 17041L; +} + +long __fastcall f_1(long a) +{ + return a; +} + +long __fastcall f_2(long a, long b) +{ + return a + 10 * b; +} + +long __fastcall f_3(long a, long b, long c) +{ + return a + 10 * b + 100 * c; +} + +long __fastcall f_4(long a, long b, long c, long d) +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long __fastcall f_5(long a, long b, long c, long d, long e) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long __fastcall f_6(long a, long b, long c, long d, long e, long f) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long __fastcall f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long __fastcall f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long __fastcall f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using boost::phoenix::bind; + + int const i = 1; + + BOOST_TEST( bind(f_0)(i) == 17041L ); + BOOST_TEST( bind(f_1, _1)(i) == 1L ); + BOOST_TEST( bind(f_2, _1, 2)(i) == 21L ); + BOOST_TEST( bind(f_3, _1, 2, 3)(i) == 321L ); + BOOST_TEST( bind(f_4, _1, 2, 3, 4)(i) == 4321L ); + BOOST_TEST( bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L ); + BOOST_TEST( bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L ); + BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); + BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); + BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fn2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fn2_test.cpp new file mode 100644 index 000000000..8bb3cfe22 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fn2_test.cpp @@ -0,0 +1,171 @@ +/*============================================================================== + Copyright (c) 2005, 2008 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +long global_result; + +// long + +long f_0() +{ + return global_result = 17041L; +} + +long f_1(long a) +{ + return global_result = a; +} + +long f_2(long a, long b) +{ + return global_result = a + 10 * b; +} + +long f_3(long a, long b, long c) +{ + return global_result = a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long f_6(long a, long b, long c, long d, long e, long f) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +// void + +void fv_0() +{ + global_result = 17041L; +} + +void fv_1(long a) +{ + global_result = a; +} + +void fv_2(long a, long b) +{ + global_result = a + 10 * b; +} + +void fv_3(long a, long b, long c) +{ + global_result = a + 10 * b + 100 * c; +} + +void fv_4(long a, long b, long c, long d) +{ + global_result = a + 10 * b + 100 * c + 1000 * d; +} + +void fv_5(long a, long b, long c, long d, long e) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +void fv_6(long a, long b, long c, long d, long e, long f) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +void fv_7(long a, long b, long c, long d, long e, long f, long g) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +void fv_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using boost::phoenix::bind; + + bind( f_0 )(); BOOST_TEST( global_result == 17041L ); + bind( f_1, 1 )(); BOOST_TEST( global_result == 1L ); + bind( f_2, 1, 2 )(); BOOST_TEST( global_result == 21L ); + bind( f_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L ); + bind( f_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L ); + bind( f_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L ); + bind( f_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L ); + bind( f_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L ); + bind( f_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L ); + bind( f_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L ); + + bind( fv_0 )(); BOOST_TEST( global_result == 17041L ); + bind( fv_1, 1 )(); BOOST_TEST( global_result == 1L ); + bind( fv_2, 1, 2 )(); BOOST_TEST( global_result == 21L ); + bind( fv_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L ); + bind( fv_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L ); + bind( fv_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L ); + bind( fv_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L ); + bind( fv_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L ); + bind( fv_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L ); + bind( fv_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fnobj2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fnobj2_test.cpp new file mode 100644 index 000000000..c03b3e931 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fnobj2_test.cpp @@ -0,0 +1,79 @@ +/*============================================================================== + Copyright (c) 2005, 2008 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + mutable unsigned int hash; + + typedef int result_type; + + X(): hash(0) {} + + int operator()() const { operator()(17); return 0; } + int operator()(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + int operator()(int a1, int a2) const { operator()(a1); operator()(a2); return 0; } + int operator()(int a1, int a2, int a3) const { operator()(a1, a2); operator()(a3); return 0; } + int operator()(int a1, int a2, int a3, int a4) const { operator()(a1, a2, a3); operator()(a4); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5) const { operator()(a1, a2, a3, a4); operator()(a5); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5, int a6) const { operator()(a1, a2, a3, a4, a5); operator()(a6); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { operator()(a1, a2, a3, a4, a5, a6); operator()(a7); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { operator()(a1, a2, a3, a4, a5, a6, a7); operator()(a8); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) const { operator()(a1, a2, a3, a4, a5, a6, a7, a8); operator()(a9); return 0; } +}; + +void function_object_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + bind(ref(x) )(); + bind(ref(x), 1 )(); + bind(ref(x), 1, 2 )(); + bind(ref(x), 1, 2, 3 )(); + bind(ref(x), 1, 2, 3, 4 )(); + bind(ref(x), 1, 2, 3, 4, 5 )(); + bind(ref(x), 1, 2, 3, 4, 5, 6 )(); + bind(ref(x), 1, 2, 3, 4, 5, 6, 7)(); + bind(ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind(ref(x), 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); + + BOOST_TEST( x.hash == 9932 ); +} + +int main() +{ + function_object_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp new file mode 100644 index 000000000..1e9c4425d --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp @@ -0,0 +1,79 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/detail/lightweight_test.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> +#include <boost/function.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +int f( int x ) +{ + return x; +} + +int g( int x ) +{ + return x + 1; +} + +int main() +{ + using boost::phoenix::bind; + + boost::function0<int> fn; + + BOOST_TEST( !fn.contains( bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( bind( g, 1 ) ) ); + + fn = bind( f, 1 ); + + BOOST_TEST( fn() == 1 ); + + BOOST_TEST( fn.contains( bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( bind( g, 1 ) ) ); + + fn = bind( f, 2 ); + + BOOST_TEST( fn() == 2 ); + + BOOST_TEST( !fn.contains( bind( f, 1 ) ) ); + BOOST_TEST( fn.contains( bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( bind( g, 1 ) ) ); + + fn = bind( g, 1 ); + + BOOST_TEST( fn() == 2 ); + + BOOST_TEST( !fn.contains( bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( bind( f, 2 ) ) ); + BOOST_TEST( fn.contains( bind( g, 1 ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_interoperation_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_interoperation_test.cpp new file mode 100644 index 000000000..fdce19a57 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_interoperation_test.cpp @@ -0,0 +1,142 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + Copyright (c) 2015 John Fletcher + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/function.hpp> +#include <boost/bind.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/detail/lightweight_test.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> +#include <boost/function.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +int f1( int x ) +{ + return x; +} + +int f2( int x, int y ) +{ + return x + y; +} + +struct X +{ + mutable int n; + + X() : n(0) {} + + int f0() { n += f1(17); return n; } + int g0() const { n += g1(17); return n; } + + + int f1(int a1) { return a1; } + int g1(int a1) const { return a1; } +}; + +struct Y +{ + int m; +}; + +namespace phx = boost::phoenix; +using phx::placeholders::arg1; +using phx::placeholders::arg2; +using boost::phoenix::ref; + +void member_test() +{ + Y y = { 17041 }; + Y * py = &y; + + BOOST_TEST( boost::bind( &Y::m, _1 )( y ) == 17041 ); + BOOST_TEST( boost::bind( &Y::m, _1 )( py ) == 17041 ); + + BOOST_TEST( phx::bind( &Y::m, _1 )( y ) == 17041 ); + BOOST_TEST( phx::bind( &Y::m, _1 )( py ) == 17041 ); + + BOOST_TEST( phx::bind( &Y::m, arg1 )( y ) == 17041 ); + BOOST_TEST( phx::bind( &Y::m, arg1 )( py ) == 17041 ); + + BOOST_TEST( boost::bind( &Y::m, y )() == 17041 ); + BOOST_TEST( boost::bind( &Y::m, py )() == 17041 ); + //BOOST_TEST( boost::bind( &Y::m, ref(y) )() == 17041 ); + + BOOST_TEST( phx::bind( &Y::m, y )() == 17041 ); + BOOST_TEST( phx::bind( &Y::m, py )() == 17041 ); + BOOST_TEST( phx::bind( &Y::m, ref(y) )() == 17041 ); + + return; +} + +void member_function_test() +{ + + X x; + + // 0 + + BOOST_TEST(boost::bind(&X::f0, &x )() == 17); + //boost::bind(&X::f0, ref(x) )(); boost::bind does not work with phx::ref. + + BOOST_TEST(boost::bind(&X::g0, &x )() == 34); + BOOST_TEST(boost::bind(&X::g0, x )() == 51); + //boost::bind(&X::g0, ref(x) )(); + + BOOST_TEST(phx::bind(&X::f0, &x )() == 51); + BOOST_TEST(phx::bind(&X::f0, ref(x) )() == 68); + + BOOST_TEST(phx::bind(&X::g0, &x )() == 85); + BOOST_TEST(phx::bind(&X::g0, x )() == 102); + BOOST_TEST(phx::bind(&X::g0, ref(x) )() == 102); + + return; +} + +int main() +{ + + boost::function<int (int)> fun1_f1(boost::bind ( &f1, _1) ); + boost::function<int (int)> fun2_f1( phx::bind ( &f1, _1) ); + boost::function<int (int)> fun3_f1( phx::bind ( &f1, arg1) ); + + BOOST_TEST( fun1_f1(1) == 1 ); + BOOST_TEST( fun2_f1(2) == 2 ); + BOOST_TEST( fun3_f1(3) == 3 ); + + boost::function<int (int, int)> fun1_f2(boost::bind ( &f2, _1, _2) ); + boost::function<int (int, int)> fun2_f2( phx::bind ( &f2, _1, _2) ); + boost::function<int (int, int)> fun3_f2( phx::bind ( &f2, arg1, arg2) ); + + BOOST_TEST( fun1_f2(1,2) == 3 ); + BOOST_TEST( fun2_f2(2,3) == 5 ); + BOOST_TEST( fun3_f2(3,4) == 7 ); + + member_function_test(); + member_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_lookup_problem_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_lookup_problem_test.cpp new file mode 100644 index 000000000..a0e23de58 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_lookup_problem_test.cpp @@ -0,0 +1,42 @@ +/*============================================================================== + Copyright (c) 2005 Markus Schoepflin + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +template<class T> void value(); + +void f0() { } +void f1(int) { } +void f2(int, int) { } +void f3(int, int, int) { } +void f4(int, int, int, int) { } +void f5(int, int, int, int, int) { } +void f6(int, int, int, int, int, int) { } +void f7(int, int, int, int, int, int, int) { } +void f8(int, int, int, int, int, int, int, int) { } +void f9(int, int, int, int, int, int, int, int, int) { } + +int main() +{ + using boost::phoenix::bind; + + bind(f0); + bind(f1, 0); + bind(f2, 0, 0); + bind(f3, 0, 0, 0); + bind(f4, 0, 0, 0, 0); + bind(f5, 0, 0, 0, 0, 0); + bind(f6, 0, 0, 0, 0, 0, 0); + bind(f7, 0, 0, 0, 0, 0, 0, 0); + bind(f8, 0, 0, 0, 0, 0, 0, 0, 0); + bind(f9, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + return 0; +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_mf2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_mf2_test.cpp new file mode 100644 index 000000000..178bd6e1c --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_mf2_test.cpp @@ -0,0 +1,163 @@ +/*============================================================================== + Copyright (c) 2005, 2008 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int f0() { f1(17); return 0; } + int g0() const { g1(17); return 0; } + + int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + bind(&X::f0, &x )(); + bind(&X::f0, ref(x) )(); + + bind(&X::g0, &x )(); + bind(&X::g0, x )(); + bind(&X::g0, ref(x) )(); + + // 1 + + bind(&X::f1, &x, 1 )(); + bind(&X::f1, ref(x), 1 )(); + + bind(&X::g1, &x, 1 )(); + bind(&X::g1, x, 1 )(); + bind(&X::g1, ref(x), 1 )(); + + // 2 + + bind(&X::f2, &x, 1, 2 )(); + bind(&X::f2, ref(x), 1, 2 )(); + + bind(&X::g2, &x, 1, 2 )(); + bind(&X::g2, x, 1, 2 )(); + bind(&X::g2, ref(x), 1, 2 )(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3 )(); + bind(&X::f3, ref(x), 1, 2, 3 )(); + + bind(&X::g3, &x, 1, 2, 3 )(); + bind(&X::g3, x, 1, 2, 3 )(); + bind(&X::g3, ref(x), 1, 2, 3 )(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4 )(); + bind(&X::f4, ref(x), 1, 2, 3, 4 )(); + + bind(&X::g4, &x, 1, 2, 3, 4 )(); + bind(&X::g4, x, 1, 2, 3, 4 )(); + bind(&X::g4, ref(x), 1, 2, 3, 4 )(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5 )(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5 )(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5 )(); + bind(&X::g5, x, 1, 2, 3, 4, 5 )(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5 )(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6 )(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6 )(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6 )(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6 )(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6 )(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_not_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_not_test.cpp new file mode 100644 index 000000000..e49980692 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_not_test.cpp @@ -0,0 +1,61 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/operator.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +template<class F, class A1, class R> void tester( F f, A1 a1, R r ) +{ + BOOST_TEST( f(a1) == r ); +} + +bool f( bool v ) +{ + return v; +} + +int g( int v ) +{ + return v; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + tester( !bind( f, true ), 0, !f( true ) ); + tester( !bind( g, _1 ), 5, !g( 5 ) ); + tester( bind( f, !bind( f, true ) ), 0, f( !f( true ) ) ); + tester( bind( f, !bind( f, _1 ) ), true, f( !f( true ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_placeholder_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_placeholder_test.cpp new file mode 100644 index 000000000..817805b6b --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_placeholder_test.cpp @@ -0,0 +1,87 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC ) + +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed + +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long f( long a, long b, long c, long d, long e, long f, long g, long h, long i ) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +template< int I > struct custom_placeholder + : boost::mpl::int_<I> +{ +}; + +namespace boost +{ + +template< int I > struct is_placeholder< custom_placeholder< I > > +{ + enum { value = I + 1}; +}; + +} // namespace boost + +int main() +{ + using boost::phoenix::bind; + + int const x1 = 1; + int const x2 = 2; + int const x3 = 3; + int const x4 = 4; + int const x5 = 5; + int const x6 = 6; + int const x7 = 7; + int const x8 = 8; + int const x9 = 9; + + custom_placeholder<0> p1; + custom_placeholder<1> p2; + custom_placeholder<2> p3; + custom_placeholder<3> p4; + custom_placeholder<4> p5; + custom_placeholder<5> p6; + custom_placeholder<6> p7; + custom_placeholder<7> p8; + custom_placeholder<8> p9; + + BOOST_TEST( + bind( f, p1, p2, p3, p4, p5, p6, p7, p8, p9 ) + ( x1, x2, x3, x4, x5, x6, x7, x8, x9 ) == 987654321L ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_ref_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_ref_test.cpp new file mode 100644 index 000000000..486028be2 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_ref_test.cpp @@ -0,0 +1,38 @@ +/*============================================================================== + Copyright (c) 2009 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/ref.hpp> +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int f( int x ) + { + return x; + } + + int g( int x ) const + { + return -x; + } +}; + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + X x; + + BOOST_TEST( bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 ); + BOOST_TEST( bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rel_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rel_test.cpp new file mode 100644 index 000000000..63d3c66aa --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rel_test.cpp @@ -0,0 +1,102 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/operator.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +int f( int x ) +{ + return x + x; +} + +int g( int x ) +{ + return 2 * x; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + using boost::phoenix::placeholders::_2; + + int x = 4; + int y = x + x; + + // bind op value + + BOOST_TEST( ( bind( f, _1 ) == y )( x ) ); + BOOST_TEST( !( ( bind( f, _1 ) != y )( x ) ) ); + + BOOST_TEST( !( ( bind( f, _1 ) < y )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) < y + 1 )( x ) ); + + BOOST_TEST( !( ( bind( f, _1 ) > y )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) > y - 1 )( x ) ); + + BOOST_TEST( !( ( bind( f, _1 ) <= y - 1 )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) <= y )( x ) ); + BOOST_TEST( ( bind( f, _1 ) <= y + 1 )( x ) ); + + BOOST_TEST( !( ( bind( f, _1 ) >= y + 1 )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) >= y )( x ) ); + BOOST_TEST( ( bind( f, _1 ) >= y - 1 )( x ) ); + + // bind op ref + + BOOST_TEST( ( bind( f, _1 ) == ref( y ) )( x ) ); + BOOST_TEST( !( ( bind( f, _1 ) != ref( y ) )( x ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) < ref( y ) )( x ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) > ref( y ) )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) <= ref( y ) )( x ) ); + BOOST_TEST( ( bind( f, _1 ) >= ref( y ) )( x ) ); + + // bind op placeholder + + BOOST_TEST( ( bind( f, _1 ) == _2 )( x, y ) ); + BOOST_TEST( !( ( bind( f, _1 ) != _2 )( x, y ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) < _2 )( x, y ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) > _2 )( x, y ) ) ); + BOOST_TEST( ( bind( f, _1 ) <= _2 )( x, y ) ); + BOOST_TEST( ( bind( f, _1 ) >= _2 )( x, y ) ); + + // bind op bind + + BOOST_TEST( ( bind( f, _1 ) == bind( g, _1 ) )( x ) ); + BOOST_TEST( !( ( bind( f, _1 ) != bind( g, _1 ) )( x ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) < bind( g, _1 ) )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) <= bind( g, _1 ) )( x ) ); + BOOST_TEST( !( ( bind( f, _1 ) > bind( g, _1 ) )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) >= bind( g, _1 ) )( x ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp1_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp1_test.cpp new file mode 100644 index 000000000..a276014c6 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp1_test.cpp @@ -0,0 +1,68 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. + BOOST_TEST( bind( &X::f, _1) ( bind( &Y::f, &y )()) == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp2_test.cpp new file mode 100644 index 000000000..ca505f25a --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp2_test.cpp @@ -0,0 +1,68 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Simplify Change bind_rv_sp_test.cpp to bind to _1. + BOOST_TEST( (*bind( &Y::f, &y )()).f() == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp3_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp3_test.cpp new file mode 100644 index 000000000..2aff70a66 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp3_test.cpp @@ -0,0 +1,68 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> g() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp4_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp4_test.cpp new file mode 100644 index 000000000..1cd9a8876 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp4_test.cpp @@ -0,0 +1,70 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + //BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + boost::shared_ptr<X> xp = bind( &Y::f, &y )(); + BOOST_TEST( bind( &X::f, xp)() == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp5_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp5_test.cpp new file mode 100644 index 000000000..4d82a46d1 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp5_test.cpp @@ -0,0 +1,70 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + //BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + boost::shared_ptr<X> xp = bind( &Y::f, &y )(); + //BOOST_TEST( bind( &X::f, xp)() == 42 ); + BOOST_TEST( (*xp).f() == 42 ); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp6_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp6_test.cpp new file mode 100644 index 000000000..446d17e75 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp6_test.cpp @@ -0,0 +1,71 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + //BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + //boost::shared_ptr<X> xp = bind( &Y::f, &y )(); + boost::shared_ptr<X> xp = y.f(); + BOOST_TEST( bind( &X::f, xp)() == 42 ); + //BOOST_TEST( (*xp).f() == 42 ); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp7_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp7_test.cpp new file mode 100644 index 000000000..7b050bf70 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp7_test.cpp @@ -0,0 +1,71 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + //BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + //boost::shared_ptr<X> xp = bind( &Y::f, &y )(); + boost::shared_ptr<X> xp = y.f(); + // BOOST_TEST( bind( &X::f, xp)() == 42 ); + BOOST_TEST( (*xp).f() == 42 ); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp_test.cpp new file mode 100644 index 000000000..3fe67c48f --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp_test.cpp @@ -0,0 +1,75 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + Copyright (c) 2015 John Fletcher + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + + Y y; + + // MSVC 10,9 and 8 all give a COMDAT error with the full test. + // This also fails: + //boost::shared_ptr<X> xp = bind( &Y::f, &y )(); +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1700) + boost::shared_ptr<X> xp = y.f(); + BOOST_TEST( bind( &X::f, xp)() == 42 ); +#else + BOOST_TEST( bind( &X::f, bind( &Y::f, &y ) )() == 42 ); +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rvalue_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rvalue_test.cpp new file mode 100644 index 000000000..049e45e18 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rvalue_test.cpp @@ -0,0 +1,93 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC ) + +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed + +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +int f( int x ) +{ + return x; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + using boost::phoenix::placeholders::_2; + using boost::phoenix::placeholders::_3; + using boost::phoenix::placeholders::_4; + using boost::phoenix::placeholders::_5; + using boost::phoenix::placeholders::_6; + using boost::phoenix::placeholders::_7; + using boost::phoenix::placeholders::_8; + using boost::phoenix::placeholders::_9; + + BOOST_TEST( + bind( f, _1 ) + ( 1 ) == 1 ); + + BOOST_TEST( + bind( f, _2 ) + ( 1, 2 ) == 2 ); + + BOOST_TEST( + bind( f, _3 ) + ( 1, 2, 3 ) == 3 ); + + BOOST_TEST( + bind( f, _4 ) + ( 1, 2, 3, 4 ) == 4 ); + + BOOST_TEST( + bind( f, _5 ) + ( 1, 2, 3, 4, 5 ) == 5 ); + + BOOST_TEST( + bind( f, _6 ) + ( 1, 2, 3, 4, 5, 6 ) == 6 ); + + BOOST_TEST( + bind( f, _7 ) + ( 1, 2, 3, 4, 5, 6, 7 ) == 7 ); + + BOOST_TEST( + bind( f, _8 ) + ( 1, 2, 3, 4, 5, 6, 7, 8 ) == 8 ); + + BOOST_TEST( + bind( f, _9 ) + ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) == 9 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stateful_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stateful_test.cpp new file mode 100644 index 000000000..fae0e9c60 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stateful_test.cpp @@ -0,0 +1,301 @@ +/*============================================================================== + Copyright (c) 2004 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +class X +{ +private: + + mutable int state_; + +public: + + X(): state_(0) + { + } + + int state() const + { + return state_; + } + + typedef int result_type; + + int operator()() const + { + return state_ += 17041; + } + + int operator()(int x1) const + { + return state_ += x1; + } + + int operator()(int x1, int x2) const + { + return state_ += x1+x2; + } + + int operator()(int x1, int x2, int x3) const + { + return state_ += x1+x2+x3; + } + + int operator()(int x1, int x2, int x3, int x4) const + { + return state_ += x1+x2+x3+x4; + } + + int operator()(int x1, int x2, int x3, int x4, int x5) const + { + return state_ += x1+x2+x3+x4+x5; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6) const + { + return state_ += x1+x2+x3+x4+x5+x6; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) const + { + return state_ += x1+x2+x3+x4+x5+x6+x7; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) const + { + return state_ += x1+x2+x3+x4+x5+x6+x7+x8; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) const + { + return state_ += x1+x2+x3+x4+x5+x6+x7+x8+x9; + } +}; + +class Y +{ +private: + + int state_; + +public: + + Y(): state_(0) + { + } + + int state() const + { + return state_; + } + + typedef int result_type; + + int operator()() + { + return state_ += 17041; + } + + int operator()(int x1) + { + return state_ += x1; + } + + int operator()(int x1, int x2) + { + return state_ += x1+x2; + } + + int operator()(int x1, int x2, int x3) + { + return state_ += x1+x2+x3; + } + + int operator()(int x1, int x2, int x3, int x4) + { + return state_ += x1+x2+x3+x4; + } + + int operator()(int x1, int x2, int x3, int x4, int x5) + { + return state_ += x1+x2+x3+x4+x5; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6) + { + return state_ += x1+x2+x3+x4+x5+x6; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) + { + return state_ += x1+x2+x3+x4+x5+x6+x7; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) + { + return state_ += x1+x2+x3+x4+x5+x6+x7+x8; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) + { + return state_ += x1+x2+x3+x4+x5+x6+x7+x8+x9; + } +}; + +int f0(int & state_) +{ + return state_ += 17041; +} + +int f1(int & state_, int x1) +{ + return state_ += x1; +} + +int f2(int & state_, int x1, int x2) +{ + return state_ += x1+x2; +} + +int f3(int & state_, int x1, int x2, int x3) +{ + return state_ += x1+x2+x3; +} + +int f4(int & state_, int x1, int x2, int x3, int x4) +{ + return state_ += x1+x2+x3+x4; +} + +int f5(int & state_, int x1, int x2, int x3, int x4, int x5) +{ + return state_ += x1+x2+x3+x4+x5; +} + +int f6(int & state_, int x1, int x2, int x3, int x4, int x5, int x6) +{ + return state_ += x1+x2+x3+x4+x5+x6; +} + +int f7(int & state_, int x1, int x2, int x3, int x4, int x5, int x6, int x7) +{ + return state_ += x1+x2+x3+x4+x5+x6+x7; +} + +int f8(int & state_, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) +{ + return state_ += x1+x2+x3+x4+x5+x6+x7+x8; +} + +template <typename> struct wrap {}; + +template<class F> void test(F f, int a, int b) +{ + BOOST_TEST( f() == a + b ); + BOOST_TEST( f() == a + 2*b ); + BOOST_TEST( f() == a + 3*b ); +} + +using boost::phoenix::bind; +using boost::phoenix::ref; + +void stateful_function_object_test() +{ + ::test( bind( X() ), 0, 17041 ); + ::test( bind( X(), 1 ), 0, 1 ); + ::test( bind( X(), 1, 2 ), 0, 1+2 ); + ::test( bind( X(), 1, 2, 3 ), 0, 1+2+3 ); + ::test( bind( X(), 1, 2, 3, 4 ), 0, 1+2+3+4 ); + ::test( bind( X(), 1, 2, 3, 4, 5 ), 0, 1+2+3+4+5 ); + ::test( bind( X(), 1, 2, 3, 4, 5, 6 ), 0, 1+2+3+4+5+6 ); + ::test( bind( X(), 1, 2, 3, 4, 5, 6, 7 ), 0, 1+2+3+4+5+6+7 ); + ::test( bind( X(), 1, 2, 3, 4, 5, 6, 7, 8 ), 0, 1+2+3+4+5+6+7+8 ); + ::test( bind( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 0, 1+2+3+4+5+6+7+8+9 ); + + Y y; + + int n = y.state(); + + ::test( bind( ref(y) ), n, 17041 ); + n += 3 * 17041; + + ::test( bind( ref(y), 1 ), n, 1 ); + n += 3*1; + + ::test( bind( ref(y), 1, 2 ), n, 1+2 ); + n += 3*(1+2); + + ::test( bind( ref(y), 1, 2, 3 ), n, 1+2+3 ); + n += 3*(1+2+3); + + ::test( bind( ref(y), 1, 2, 3, 4 ), n, 1+2+3+4 ); + n += 3*(1+2+3+4); + + ::test( bind( ref(y), 1, 2, 3, 4, 5 ), n, 1+2+3+4+5 ); + n += 3*(1+2+3+4+5); + + ::test( bind( ref(y), 1, 2, 3, 4, 5, 6 ), n, 1+2+3+4+5+6 ); + n += 3*(1+2+3+4+5+6); + + ::test( bind( ref(y), 1, 2, 3, 4, 5, 6, 7 ), n, 1+2+3+4+5+6+7 ); + n += 3*(1+2+3+4+5+6+7); + + ::test( bind( ref(y), 1, 2, 3, 4, 5, 6, 7, 8 ), n, 1+2+3+4+5+6+7+8 ); + n += 3*(1+2+3+4+5+6+7+8); + + ::test( bind( ref(y), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), n, 1+2+3+4+5+6+7+8+9 ); + n += 3*(1+2+3+4+5+6+7+8+9); + + BOOST_TEST( y.state() == n ); +} + +void stateful_function_test() +{ + using boost::phoenix::ref; + + ::test( bind( f0, 0), 0, 17041 ); + ::test( bind( f1, 0, 1 ), 0, 1 ); + ::test( bind( f2, 0, 1, 2 ), 0, 1+2 ); + ::test( bind( f3, 0, 1, 2, 3 ), 0, 1+2+3 ); + ::test( bind( f4, 0, 1, 2, 3, 4 ), 0, 1+2+3+4 ); + ::test( bind( f5, 0, 1, 2, 3, 4, 5 ), 0, 1+2+3+4+5 ); + ::test( bind( f6, 0, 1, 2, 3, 4, 5, 6 ), 0, 1+2+3+4+5+6 ); + ::test( bind( f7, 0, 1, 2, 3, 4, 5, 6, 7 ), 0, 1+2+3+4+5+6+7 ); + ::test( bind( f8, 0, 1, 2, 3, 4, 5, 6, 7, 8 ), 0, 1+2+3+4+5+6+7+8 ); +} + +int main() +{ + stateful_function_object_test(); + stateful_function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp new file mode 100644 index 000000000..b7ecdd183 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp @@ -0,0 +1,167 @@ +/*============================================================================== + Copyright (c) 2001 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#define BOOST_MEM_FN_ENABLE_STDCALL + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int __stdcall f0() { f1(17); return 0; } + int __stdcall g0() const { g1(17); return 0; } + + int __stdcall f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int __stdcall g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int __stdcall f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int __stdcall g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int __stdcall f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int __stdcall g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int __stdcall f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int __stdcall g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int __stdcall f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int __stdcall g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int __stdcall f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int __stdcall g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int __stdcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int __stdcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int __stdcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int __stdcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + std::cout << typeid(typename boost::result_of<X::f0()>::type).name() << "\n"; + + bind(&X::f0, &x)(); + bind(&X::f0, ref(x))(); + + bind(&X::g0, &x)(); + bind(&X::g0, x)(); + bind(&X::g0, ref(x))(); + + // 1 + + bind(&X::f1, &x, 1)(); + bind(&X::f1, ref(x), 1)(); + + bind(&X::g1, &x, 1)(); + bind(&X::g1, x, 1)(); + bind(&X::g1, ref(x), 1)(); + + // 2 + + bind(&X::f2, &x, 1, 2)(); + bind(&X::f2, ref(x), 1, 2)(); + + bind(&X::g2, &x, 1, 2)(); + bind(&X::g2, x, 1, 2)(); + bind(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3)(); + bind(&X::f3, ref(x), 1, 2, 3)(); + + bind(&X::g3, &x, 1, 2, 3)(); + bind(&X::g3, x, 1, 2, 3)(); + bind(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4)(); + bind(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind(&X::g4, &x, 1, 2, 3, 4)(); + bind(&X::g4, x, 1, 2, 3, 4)(); + bind(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind(&X::g5, x, 1, 2, 3, 4, 5)(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_test.cpp new file mode 100644 index 000000000..b3723a5da --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_test.cpp @@ -0,0 +1,111 @@ +/*============================================================================== + Copyright (c) 2001 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#define BOOST_BIND_ENABLE_STDCALL + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long __stdcall f_0() +{ + return 17041L; +} + +long __stdcall f_1(long a) +{ + return a; +} + +long __stdcall f_2(long a, long b) +{ + return a + 10 * b; +} + +long __stdcall f_3(long a, long b, long c) +{ + return a + 10 * b + 100 * c; +} + +long __stdcall f_4(long a, long b, long c, long d) +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long __stdcall f_5(long a, long b, long c, long d, long e) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long __stdcall f_6(long a, long b, long c, long d, long e, long f) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long __stdcall f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long __stdcall f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long __stdcall f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + int const i = 1; + + BOOST_TEST( bind(f_0)(i) == 17041L ); + BOOST_TEST( bind(f_1, _1)(i) == 1L ); + BOOST_TEST( bind(f_2, _1, 2)(i) == 21L ); + BOOST_TEST( bind(f_3, _1, 2, 3)(i) == 321L ); + BOOST_TEST( bind(f_4, _1, 2, 3, 4)(i) == 4321L ); + BOOST_TEST( bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L ); + BOOST_TEST( bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L ); + BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); + BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); + BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_test.cpp new file mode 100644 index 000000000..1225b8abf --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_test.cpp @@ -0,0 +1,542 @@ +/*============================================================================== + Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. + Copyright (c) 2001 David Abrahams + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long f_0() +{ + return 17041L; +} + +long f_1(long a) +{ + return a; +} + +long f_2(long a, long b) +{ + return a + 10 * b; +} + +long f_3(long a, long b, long c) +{ + return a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long f_6(long a, long b, long c, long d, long e, long f) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +long global_result; + +void fv_0() +{ + global_result = 17041L; +} + +void fv_1(long a) +{ + global_result = a; +} + +void fv_2(long a, long b) +{ + global_result = a + 10 * b; +} + +void fv_3(long a, long b, long c) +{ + global_result = a + 10 * b + 100 * c; +} + +void fv_4(long a, long b, long c, long d) +{ + global_result = a + 10 * b + 100 * c + 1000 * d; +} + +void fv_5(long a, long b, long c, long d, long e) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +void fv_6(long a, long b, long c, long d, long e, long f) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +void fv_7(long a, long b, long c, long d, long e, long f, long g) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +void fv_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + int const i = 1; + + BOOST_TEST( bind(f_0)(i) == 17041L ); + BOOST_TEST( bind(f_1, _1)(i) == 1L ); + BOOST_TEST( bind(f_2, _1, 2)(i) == 21L ); + BOOST_TEST( bind(f_3, _1, 2, 3)(i) == 321L ); + BOOST_TEST( bind(f_4, _1, 2, 3, 4)(i) == 4321L ); + BOOST_TEST( bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L ); + BOOST_TEST( bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L ); + BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); + BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); + BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); + + BOOST_TEST( (bind(fv_0)(i), (global_result == 17041L)) ); + BOOST_TEST( (bind(fv_1, _1)(i), (global_result == 1L)) ); + BOOST_TEST( (bind(fv_2, _1, 2)(i), (global_result == 21L)) ); + BOOST_TEST( (bind(fv_3, _1, 2, 3)(i), (global_result == 321L)) ); + BOOST_TEST( (bind(fv_4, _1, 2, 3, 4)(i), (global_result == 4321L)) ); + BOOST_TEST( (bind(fv_5, _1, 2, 3, 4, 5)(i), (global_result == 54321L)) ); + BOOST_TEST( (bind(fv_6, _1, 2, 3, 4, 5, 6)(i), (global_result == 654321L)) ); + BOOST_TEST( (bind(fv_7, _1, 2, 3, 4, 5, 6, 7)(i), (global_result == 7654321L)) ); + BOOST_TEST( (bind(fv_8, _1, 2, 3, 4, 5, 6, 7, 8)(i), (global_result == 87654321L)) ); + BOOST_TEST( (bind(fv_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i), (global_result == 987654321L)) ); +} + +// + +struct Y +{ + template <typename Sig> + struct result; + template <typename This, typename A0> + struct result<This(A0 &)> { typedef short type; }; + template <typename This, typename A0, typename A1> + struct result<This(A0, A1)> { typedef int type; }; + template <typename This, typename A0, typename A1, typename A2> + struct result<This(A0, A1, A2)> { typedef long type; }; + template <typename This, typename A0, typename A1, typename A2, typename A3> + struct result<This(A0, A1, A2, A3)> { typedef void type; }; + + short operator()(short & r) const { return ++r; } + int operator()(int a, int b) const { return a + 10 * b; } + long operator() (long a, long b, long c) const { return a + 10 * b + 100 * c; } + void operator() (long a, long b, long c, long d) const { global_result = a + 10 * b + 100 * c + 1000 * d; } +}; + +void function_object_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + short i(6); + + int const k = 3; + + BOOST_TEST( bind(Y(), ref(i))() == 7 ); + BOOST_TEST( bind(Y(), ref(i))() == 8 ); + BOOST_TEST( bind(Y(), i, _1)(k) == 38 ); + BOOST_TEST( bind(Y(), i, _1, 9)(k) == 938 ); + +#if !defined(__MWERKS__) || (__MWERKS__ > 0x2407) // Fails for this version of the compiler. + + global_result = 0; + bind(Y(), i, _1, 9, 4)(k); + BOOST_TEST( global_result == 4938 ); + +#endif +} + +void function_object_test2() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + short i(6); + + int const k = 3; + + BOOST_TEST( bind(Y(), ref(i))() == 7 ); + BOOST_TEST( bind(Y(), ref(i))() == 8 ); + BOOST_TEST( bind(Y(), i, _1)(k) == 38 ); + BOOST_TEST( bind(Y(), i, _1, 9)(k) == 938 ); + + global_result = 0; + bind(Y(), i, _1, 9, 4)(k); + BOOST_TEST( global_result == 4938 ); +} + +// + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + +struct Z +{ + typedef int result_type; + int operator()(int a, int b) const { return a + 10 * b; } +}; + +void adaptable_function_object_test() +{ + using boost::phoenix::bind; + BOOST_TEST( bind(Z(), 7, 4)() == 47 ); +} + +#endif + +// + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int f0() { f1(17); return 0; } + int g0() const { g1(17); return 0; } + + int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +struct V +{ + mutable unsigned int hash; + + V(): hash(0) {} + + void f0() { f1(17); } + void g0() const { g1(17); } + + void f1(int a1) { hash = (hash * 17041 + a1) % 32768; } + void g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; } + + void f2(int a1, int a2) { f1(a1); f1(a2); } + void g2(int a1, int a2) const { g1(a1); g1(a2); } + + void f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); } + void g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); } + + void f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); } + void g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); } + + void f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); } + void g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); } + + void f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } + void g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } + + void f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } + void g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } + + void f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } + void g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + bind(&X::f0, &x)(); + bind(&X::f0, ref(x))(); + + bind(&X::g0, &x)(); + bind(&X::g0, x)(); + bind(&X::g0, ref(x))(); + + // 1 + + bind(&X::f1, &x, 1)(); + bind(&X::f1, ref(x), 1)(); + + bind(&X::g1, &x, 1)(); + bind(&X::g1, x, 1)(); + bind(&X::g1, ref(x), 1)(); + + // 2 + + bind(&X::f2, &x, 1, 2)(); + bind(&X::f2, ref(x), 1, 2)(); + + bind(&X::g2, &x, 1, 2)(); + bind(&X::g2, x, 1, 2)(); + bind(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3)(); + bind(&X::f3, ref(x), 1, 2, 3)(); + + bind(&X::g3, &x, 1, 2, 3)(); + bind(&X::g3, x, 1, 2, 3)(); + bind(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4)(); + bind(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind(&X::g4, &x, 1, 2, 3, 4)(); + bind(&X::g4, x, 1, 2, 3, 4)(); + bind(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind(&X::g5, x, 1, 2, 3, 4, 5)(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +void member_function_void_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + V v; + + // 0 + + bind(&V::f0, &v)(); + bind(&V::f0, ref(v))(); + + bind(&V::g0, &v)(); + bind(&V::g0, v)(); + bind(&V::g0, ref(v))(); + + // 1 + + bind(&V::f1, &v, 1)(); + bind(&V::f1, ref(v), 1)(); + + bind(&V::g1, &v, 1)(); + bind(&V::g1, v, 1)(); + bind(&V::g1, ref(v), 1)(); + + // 2 + + bind(&V::f2, &v, 1, 2)(); + bind(&V::f2, ref(v), 1, 2)(); + + bind(&V::g2, &v, 1, 2)(); + bind(&V::g2, v, 1, 2)(); + bind(&V::g2, ref(v), 1, 2)(); + + // 3 + + bind(&V::f3, &v, 1, 2, 3)(); + bind(&V::f3, ref(v), 1, 2, 3)(); + + bind(&V::g3, &v, 1, 2, 3)(); + bind(&V::g3, v, 1, 2, 3)(); + bind(&V::g3, ref(v), 1, 2, 3)(); + + // 4 + + bind(&V::f4, &v, 1, 2, 3, 4)(); + bind(&V::f4, ref(v), 1, 2, 3, 4)(); + + bind(&V::g4, &v, 1, 2, 3, 4)(); + bind(&V::g4, v, 1, 2, 3, 4)(); + bind(&V::g4, ref(v), 1, 2, 3, 4)(); + + // 5 + + bind(&V::f5, &v, 1, 2, 3, 4, 5)(); + bind(&V::f5, ref(v), 1, 2, 3, 4, 5)(); + + bind(&V::g5, &v, 1, 2, 3, 4, 5)(); + bind(&V::g5, v, 1, 2, 3, 4, 5)(); + bind(&V::g5, ref(v), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&V::f6, &v, 1, 2, 3, 4, 5, 6)(); + bind(&V::f6, ref(v), 1, 2, 3, 4, 5, 6)(); + + bind(&V::g6, &v, 1, 2, 3, 4, 5, 6)(); + bind(&V::g6, v, 1, 2, 3, 4, 5, 6)(); + bind(&V::g6, ref(v), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&V::f7, &v, 1, 2, 3, 4, 5, 6, 7)(); + bind(&V::f7, ref(v), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&V::g7, &v, 1, 2, 3, 4, 5, 6, 7)(); + bind(&V::g7, v, 1, 2, 3, 4, 5, 6, 7)(); + bind(&V::g7, ref(v), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&V::f8, &v, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&V::f8, ref(v), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&V::g8, &v, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&V::g8, v, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&V::g8, ref(v), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( v.hash == 23558 ); +} + +void nested_bind_test() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + using boost::phoenix::placeholders::_2; + + int const x = 1; + int const y = 2; + + BOOST_TEST( bind(f_1, bind(f_1, _1))(x) == 1L ); + BOOST_TEST( bind(f_1, bind(f_2, _1, _2))(x, y) == 21L ); + BOOST_TEST( bind(f_2, bind(f_1, _1), bind(f_1, _1))(x) == 11L ); + BOOST_TEST( bind(f_2, bind(f_1, _1), bind(f_1, _2))(x, y) == 21L ); + BOOST_TEST( bind(f_1, bind(f_0))() == 17041L ); + + BOOST_TEST( (bind(fv_1, bind(f_1, _1))(x), (global_result == 1L)) ); + BOOST_TEST( (bind(fv_1, bind(f_2, _1, _2))(x, y), (global_result == 21L)) ); + BOOST_TEST( (bind(fv_2, bind(f_1, _1), bind(f_1, _1))(x), (global_result == 11L)) ); + BOOST_TEST( (bind(fv_2, bind(f_1, _1), bind(f_1, _2))(x, y), (global_result == 21L)) ); + BOOST_TEST( (bind(fv_1, bind(f_0))(), (global_result == 17041L)) ); +} + +int main() +{ + function_test(); + function_object_test(); + function_object_test2(); + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + adaptable_function_object_test(); +#endif + + member_function_test(); + member_function_void_test(); + nested_bind_test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_unary_addr.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_unary_addr.cpp new file mode 100644 index 000000000..9a02a271f --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_unary_addr.cpp @@ -0,0 +1,151 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +class X +{ +private: + + void operator& (); + void operator& () const; + +public: + + typedef void result_type; + + void operator()() + { + } + + void operator()() const + { + } + + void operator()(int) + { + } + + void operator()(int) const + { + } + + void operator()(int, int) + { + } + + void operator()(int, int) const + { + } + + void operator()(int, int, int) + { + } + + void operator()(int, int, int) const + { + } + + void operator()(int, int, int, int) + { + } + + void operator()(int, int, int, int) const + { + } + + void operator()(int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int) const + { + } + + void operator()(int, int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int, int) const + { + } + + void operator()(int, int, int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int, int, int) const + { + } + + void operator()(int, int, int, int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int, int, int, int) const + { + } + + void operator()(int, int, int, int, int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int, int, int, int, int) const + { + } +}; + +template<class F> void test_const( F const & f ) +{ + f(); +} + +template<class F> void test( F f ) +{ + f(); + test_const( f ); +} + +int main() +{ + using boost::phoenix::bind; + + test( bind( X() ) ); + test( bind( X(), 1 ) ); + test( bind( X(), 1, 2 ) ); + test( bind( X(), 1, 2, 3 ) ); + test( bind( X(), 1, 2, 3, 4 ) ); + test( bind( X(), 1, 2, 3, 4, 5 ) ); + test( bind( X(), 1, 2, 3, 4, 5, 6 ) ); + test( bind( X(), 1, 2, 3, 4, 5, 6, 7 ) ); + test( bind( X(), 1, 2, 3, 4, 5, 6, 7, 8 ) ); + test( bind( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ) ); + + return 0; +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_dm_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_dm_test.cpp new file mode 100644 index 000000000..5755fb655 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_dm_test.cpp @@ -0,0 +1,73 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2014 Agustin Berge + Copyright (c) 2015 John Fletcher + + 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_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/ref.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +struct Z +{ + int m; +}; + +void member_data_test() +{ + using boost::phoenix::bind; + + Z z = { 17041 }; + Z * pz = &z; + + bind<void>( &Z::m, _1 )( z ); + bind<void>( &Z::m, _1 )( pz ); + + bind<void>( &Z::m, z )(); + bind<void>( &Z::m, pz )(); + bind<void>( &Z::m, boost::ref(z) )(); + + + Z const cz = z; + Z const * pcz = &cz; + + bind<void>( &Z::m, _1 )( cz ); + bind<void>( &Z::m, _1 )( pcz ); + + bind<void>( &Z::m, cz )(); + bind<void>( &Z::m, pcz )(); + bind<void>( &Z::m, boost::ref(cz) )(); +} + +int main() +{ + member_data_test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_mf_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_mf_test.cpp new file mode 100644 index 000000000..62c2dcda7 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_mf_test.cpp @@ -0,0 +1,171 @@ +#include <boost/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// +// bind_void_mf_test.cpp - test for bind<void> with member functions +// +// Copyright (c) 2008 Peter Dimov +// Copyright (c) 2014 Agustin Berge +// +// 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/bind.hpp> +#include <boost/ref.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long global_result; + +// + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int f0() { f1(17); return 0; } + int g0() const { g1(17); return 0; } + + int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + using namespace boost; + + X x; + + // 0 + + bind<void>(&X::f0, &x)(); + bind<void>(&X::f0, ref(x))(); + + bind<void>(&X::g0, &x)(); + bind<void>(&X::g0, x)(); + bind<void>(&X::g0, ref(x))(); + + // 1 + + bind<void>(&X::f1, &x, 1)(); + bind<void>(&X::f1, ref(x), 1)(); + + bind<void>(&X::g1, &x, 1)(); + bind<void>(&X::g1, x, 1)(); + bind<void>(&X::g1, ref(x), 1)(); + + // 2 + + bind<void>(&X::f2, &x, 1, 2)(); + bind<void>(&X::f2, ref(x), 1, 2)(); + + bind<void>(&X::g2, &x, 1, 2)(); + bind<void>(&X::g2, x, 1, 2)(); + bind<void>(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind<void>(&X::f3, &x, 1, 2, 3)(); + bind<void>(&X::f3, ref(x), 1, 2, 3)(); + + bind<void>(&X::g3, &x, 1, 2, 3)(); + bind<void>(&X::g3, x, 1, 2, 3)(); + bind<void>(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind<void>(&X::f4, &x, 1, 2, 3, 4)(); + bind<void>(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind<void>(&X::g4, &x, 1, 2, 3, 4)(); + bind<void>(&X::g4, x, 1, 2, 3, 4)(); + bind<void>(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind<void>(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind<void>(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind<void>(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind<void>(&X::g5, x, 1, 2, 3, 4, 5)(); + bind<void>(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind<void>(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind<void>(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind<void>(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind<void>(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind<void>(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind<void>(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind<void>(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind<void>(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind<void>(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind<void>(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind<void>(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind<void>(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind<void>(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind<void>(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind<void>(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_test.cpp new file mode 100644 index 000000000..bb1e80dae --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_test.cpp @@ -0,0 +1,139 @@ +#include <boost/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// +// bind_void_test.cpp - test for bind<void> +// +// Copyright (c) 2008 Peter Dimov +// Copyright (c) 2014 Agustin Berge +// +// 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/bind.hpp> +#include <boost/ref.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long global_result; + +long f_0() +{ + return global_result = 17041L; +} + +long f_1(long a) +{ + return global_result = a; +} + +long f_2(long a, long b) +{ + return global_result = a + 10 * b; +} + +long f_3(long a, long b, long c) +{ + return global_result = a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long f_6(long a, long b, long c, long d, long e, long f) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using namespace boost; + + int const i = 1; + + BOOST_TEST( (bind<void>(f_0)(i), (global_result == 17041L)) ); + BOOST_TEST( (bind<void>(f_1, _1)(i), (global_result == 1L)) ); + BOOST_TEST( (bind<void>(f_2, _1, 2)(i), (global_result == 21L)) ); + BOOST_TEST( (bind<void>(f_3, _1, 2, 3)(i), (global_result == 321L)) ); + BOOST_TEST( (bind<void>(f_4, _1, 2, 3, 4)(i), (global_result == 4321L)) ); + BOOST_TEST( (bind<void>(f_5, _1, 2, 3, 4, 5)(i), (global_result == 54321L)) ); + BOOST_TEST( (bind<void>(f_6, _1, 2, 3, 4, 5, 6)(i), (global_result == 654321L)) ); + BOOST_TEST( (bind<void>(f_7, _1, 2, 3, 4, 5, 6, 7)(i), (global_result == 7654321L)) ); + BOOST_TEST( (bind<void>(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i), (global_result == 87654321L)) ); + BOOST_TEST( (bind<void>(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i), (global_result == 987654321L)) ); +} + +// + +struct Y +{ + short operator()(short & r) const { return global_result = ++r; } + int operator()(int a, int b) const { return global_result = a + 10 * b; } + long operator() (long a, long b, long c) const { return global_result = a + 10 * b + 100 * c; } + void operator() (long a, long b, long c, long d) const { global_result = a + 10 * b + 100 * c + 1000 * d; } +}; + +void function_object_test() +{ + using namespace boost; + + short i(6); + + int const k = 3; + + BOOST_TEST( (bind<void>(Y(), ref(i))(), (global_result == 7)) ); + BOOST_TEST( (bind<void>(Y(), ref(i))(), (global_result == 8)) ); + BOOST_TEST( (bind<void>(Y(), i, _1)(k), (global_result == 38)) ); + BOOST_TEST( (bind<void>(Y(), i, _1, 9)(k), (global_result == 938)) ); + BOOST_TEST( (bind<void>(Y(), i, _1, 9, 4)(k), (global_result == 4938)) ); +} + +int main() +{ + function_test(); + function_object_test(); + + return boost::report_errors(); +} |