diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/bind | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/bind')
70 files changed, 8461 insertions, 0 deletions
diff --git a/src/boost/libs/bind/CMakeLists.txt b/src/boost/libs/bind/CMakeLists.txt new file mode 100644 index 00000000..a8517d2d --- /dev/null +++ b/src/boost/libs/bind/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2018 Mike Dev +# 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 + +# Partial (add_subdirectory only) and experimental CMake support +# Subject to change; please do not rely on the contents of this file yet + +cmake_minimum_required(VERSION 3.5) +project(BoostBind LANGUAGES CXX) + +add_library(boost_bind INTERFACE) +add_library(Boost::bind ALIAS boost_bind) + +target_include_directories(boost_bind INTERFACE include) + +target_link_libraries(boost_bind + INTERFACE + Boost::config + Boost::core +) diff --git a/src/boost/libs/bind/README.md b/src/boost/libs/bind/README.md new file mode 100644 index 00000000..ebe55532 --- /dev/null +++ b/src/boost/libs/bind/README.md @@ -0,0 +1,6 @@ +# Boost.Bind + +Branch | Travis | Appveyor +---------|--------|--------- +Develop | [![Build Status](https://travis-ci.org/boostorg/bind.svg?branch=develop)](https://travis-ci.org/boostorg/bind) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/bind?branch=develop&svg=true)](https://ci.appveyor.com/project/pdimov/bind) +Master | [![Build Status](https://travis-ci.org/boostorg/bind.svg?branch=master)](https://travis-ci.org/boostorg/bind) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/bind?branch=master&svg=true)](https://ci.appveyor.com/project/pdimov/bind) diff --git a/src/boost/libs/bind/bind.html b/src/boost/libs/bind/bind.html new file mode 100644 index 00000000..bcc5add9 --- /dev/null +++ b/src/boost/libs/bind/bind.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html> +<head> +<title>Boost.Bind</title> +<meta charset="utf-8"> +<meta http-equiv="refresh" content="0; url=doc/html/bind.html"> +<style> + body { + background: #fff; + color: #000; + } + a { + color: #00f; + text-decoration: none; + } +</style> +</head> +<body> + <p> + Automatic redirection failed, please go to + <a href="doc/html/bind.html">doc/html/bind.html</a> + </p> + <p> + © 2001, 2002 Peter Dimov and Multi Media Ltd.<br> + © 2003-2008 Peter Dimov + </p> +</body> +</html> diff --git a/src/boost/libs/bind/bind_as_compose.cpp b/src/boost/libs/bind/bind_as_compose.cpp new file mode 100644 index 00000000..999856cf --- /dev/null +++ b/src/boost/libs/bind/bind_as_compose.cpp @@ -0,0 +1,76 @@ +#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_as_compose.cpp - function composition using bind.hpp +// +// Version 1.00.0001 (2001-08-30) +// +// Copyright (c) 2001 Peter Dimov and Multi Media Ltd. +// +// 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 <iostream> +#include <string> + +std::string f(std::string const & x) +{ + return "f(" + x + ")"; +} + +std::string g(std::string const & x) +{ + return "g(" + x + ")"; +} + +std::string h(std::string const & x, std::string const & y) +{ + return "h(" + x + ", " + y + ")"; +} + +std::string k() +{ + return "k()"; +} + +template<class F> void test(F f) +{ + std::cout << f("x", "y") << '\n'; +} + +int main() +{ + using namespace boost; + + // compose_f_gx + + test( bind(f, bind(g, _1)) ); + + // compose_f_hxy + + test( bind(f, bind(h, _1, _2)) ); + + // compose_h_fx_gx + + test( bind(h, bind(f, _1), bind(g, _1)) ); + + // compose_h_fx_gy + + test( bind(h, bind(f, _1), bind(g, _2)) ); + + // compose_f_k + + test( bind(f, bind(k)) ); + + return 0; +} diff --git a/src/boost/libs/bind/bind_visitor.cpp b/src/boost/libs/bind/bind_visitor.cpp new file mode 100644 index 00000000..1ce7b53f --- /dev/null +++ b/src/boost/libs/bind/bind_visitor.cpp @@ -0,0 +1,65 @@ +#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_visitor.cpp - tests bind.hpp with a visitor +// +// Copyright (c) 2001 Peter Dimov and Multi Media Ltd. +// +// 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> +#include <typeinfo> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +// + +struct visitor +{ + template<class T> void operator()( boost::reference_wrapper<T> const & r ) const + { + std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n"; + } + + template<class T> void operator()( T const & t ) const + { + std::cout << "Value of type " << typeid(T).name() << " (with value " << t << ")\n"; + } +}; + +int f(int & i, int & j, int) +{ + ++i; + --j; + return i + j; +} + +int x = 2; +int y = 7; + +int main() +{ + using namespace boost; + + visitor v; + visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0); +} diff --git a/src/boost/libs/bind/index.html b/src/boost/libs/bind/index.html new file mode 100644 index 00000000..3f5edf31 --- /dev/null +++ b/src/boost/libs/bind/index.html @@ -0,0 +1,16 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/html/bind.html"> +</head> +<body> +Automatic redirection failed, please go to +<a href="doc/html/bind.html">doc/html/bind.html</a> or +<a href="doc/html/mem_fn.html">doc/html/mem_fn.html</a>. +</body> +</html> +<!-- + © Copyright Beman Dawes, 2001 + 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 +--> diff --git a/src/boost/libs/bind/mem_fn.html b/src/boost/libs/bind/mem_fn.html new file mode 100644 index 00000000..820d2ccc --- /dev/null +++ b/src/boost/libs/bind/mem_fn.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html> +<head> +<title>Boost.MemberFunction</title> +<meta charset="utf-8"> +<meta http-equiv="refresh" content="0; url=doc/html/mem_fn.html"> +<style> + body { + background: #fff; + color: #000; + } + a { + color: #00f; + text-decoration: none; + } +</style> +</head> +<body> + <p> + Automatic redirection failed, please go to + <a href="doc/html/mem_fn.html">doc/html/mem_fn.html</a> + </p> + <p> + © 2001, 2002 Peter Dimov and Multi Media Ltd.<br> + © 2003-2005 Peter Dimov + </p> +</body> +</html> diff --git a/src/boost/libs/bind/meta/libraries.json b/src/boost/libs/bind/meta/libraries.json new file mode 100644 index 00000000..ebf8f7b6 --- /dev/null +++ b/src/boost/libs/bind/meta/libraries.json @@ -0,0 +1,34 @@ +[ + { + "key": "bind", + "name": "Bind", + "authors": [ + "Peter Dimov" + ], + "description": "boost::bind is a generalization of the standard functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions.", + "std": [ + "tr1" + ], + "category": [ + "Function-objects" + ], + "maintainers": [ + "Peter Dimov <pdimov -at- pdimov.com>" + ] + }, + { + "key": "bind/mem_fn", + "name": "Member Function", + "authors": [ + "Peter Dimov" + ], + "description": "Generalized binders for function/object/pointers and member functions.", + "documentation": "mem_fn.html", + "std": [ + "tr1" + ], + "category": [ + "Function-objects" + ] + } +] diff --git a/src/boost/libs/bind/test/Jamfile.v2 b/src/boost/libs/bind/test/Jamfile.v2 new file mode 100644 index 00000000..272725c6 --- /dev/null +++ b/src/boost/libs/bind/test/Jamfile.v2 @@ -0,0 +1,74 @@ +# Boost.Bind Library test Jamfile +# +# Copyright (c) 2003-2006, 2017 Peter Dimov +# +# 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) + +# bring in rules for testing +import testing ; + +# quick test (for CI) +run quick.cpp ; + +# full test suite +run bind_test.cpp ; +run bind_dm_test.cpp ; +run bind_eq_test.cpp ; +run bind_const_test.cpp ; +run bind_cv_test.cpp ; +run bind_stateful_test.cpp ; +run bind_dm2_test.cpp ; +run bind_not_test.cpp ; +run bind_rel_test.cpp ; +run bind_function_test.cpp ; +run bind_lookup_problem_test.cpp ; +run bind_rv_sp_test.cpp ; +compile bind_unary_addr.cpp ; +run bind_dm3_test.cpp ; +run bind_visit_test.cpp ; +run bind_placeholder_test.cpp ; +run bind_rvalue_test.cpp ; +run bind_and_or_test.cpp ; +run bind_void_test.cpp ; +run bind_void_dm_test.cpp ; +run bind_void_mf_test.cpp ; +run mem_fn_test.cpp ; +run mem_fn_void_test.cpp ; +run mem_fn_derived_test.cpp ; +run mem_fn_eq_test.cpp ; +run mem_fn_dm_test.cpp ; +run mem_fn_rv_test.cpp ; +run ref_fn_test.cpp ; +run bind_fnobj2_test.cpp ; +run bind_fn2_test.cpp ; +run bind_mf2_test.cpp ; +run bind_eq2_test.cpp ; +run mem_fn_ref_test.cpp ; +run bind_ref_test.cpp ; +run bind_eq3_test.cpp ; +run protect_test.cpp ; +run mem_fn_unary_addr_test.cpp ; +run bind_function2_test.cpp ; +run bind_fwd_test.cpp ; +run bind_fwd2_test.cpp ; +run bind_no_placeholders_test.cpp ; +run placeholder_const_ref_test.cpp ; +run bind_function_ap_test.cpp ; +run bind_type_test.cpp ; +run bind_unique_ptr_test.cpp ; +run bind_nested_rv_test.cpp ; +compile arg_copy_test.cpp ; +compile-fail arg_copy_fail.cpp ; +run placeholder_std_bind_test.cpp ; +run bind_fastcall_test.cpp ; +run bind_stdcall_test.cpp ; +run bind_cdecl_mf_test.cpp ; +run bind_fastcall_mf_test.cpp ; +run bind_stdcall_mf_test.cpp ; +run mem_fn_cdecl_test.cpp ; +run mem_fn_fastcall_test.cpp ; +run mem_fn_stdcall_test.cpp ; +run bind_noexcept_test.cpp ; +run bind_noexcept_mf_test.cpp ; diff --git a/src/boost/libs/bind/test/arg_copy_fail.cpp b/src/boost/libs/bind/test/arg_copy_fail.cpp new file mode 100644 index 00000000..35e9e3d0 --- /dev/null +++ b/src/boost/libs/bind/test/arg_copy_fail.cpp @@ -0,0 +1,19 @@ +// +// arg_copy_fail.cpp - arg<1> to arg<2> +// +// Copyright 2016 Peter Dimov +// +// 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/arg.hpp> + +// + +int main() +{ + boost::arg<1> a1(( boost::arg<2>() )); + (void)a1; +} diff --git a/src/boost/libs/bind/test/arg_copy_test.cpp b/src/boost/libs/bind/test/arg_copy_test.cpp new file mode 100644 index 00000000..b727ce6e --- /dev/null +++ b/src/boost/libs/bind/test/arg_copy_test.cpp @@ -0,0 +1,34 @@ +// +// arg_copy_test.cpp - copying a custom placeholder _1 to arg<1> +// +// Copyright 2016 Peter Dimov +// +// 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/is_placeholder.hpp> +#include <boost/bind/arg.hpp> + +// + +template<int I> struct ph +{ +}; + +namespace boost +{ + +template<int I> struct is_placeholder< ::ph<I> > +{ + enum _vt { value = I }; +}; + +} // namespace boost + +int main() +{ + boost::arg<1> a1 = ph<1>(); + (void)a1; +} diff --git a/src/boost/libs/bind/test/bind_and_or_test.cpp b/src/boost/libs/bind/test/bind_and_or_test.cpp new file mode 100644 index 00000000..337a11ef --- /dev/null +++ b/src/boost/libs/bind/test/bind_and_or_test.cpp @@ -0,0 +1,84 @@ +#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_and_or_test.cpp - &&, || operators +// +// Copyright (c) 2008 Peter Dimov +// +// 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> + +#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> + +bool f( bool x ) +{ + return x; +} + +bool g( bool x ) +{ + return !x; +} + +bool h() +{ + BOOST_ERROR( "Short-circuit evaluation failure" ); + return false; +} + +template< class F, class A1, class A2, class R > void test( F f, A1 a1, A2 a2, R r ) +{ + BOOST_TEST( f( a1, a2 ) == r ); +} + +int main() +{ + // && + + test( boost::bind( f, true ) && boost::bind( g, true ), false, false, f( true ) && g( true ) ); + test( boost::bind( f, true ) && boost::bind( g, false ), false, false, f( true ) && g( false ) ); + + test( boost::bind( f, false ) && boost::bind( h ), false, false, f( false ) && h() ); + + test( boost::bind( f, _1 ) && boost::bind( g, _2 ), true, true, f( true ) && g( true ) ); + test( boost::bind( f, _1 ) && boost::bind( g, _2 ), true, false, f( true ) && g( false ) ); + + test( boost::bind( f, _1 ) && boost::bind( h ), false, false, f( false ) && h() ); + + // || + + test( boost::bind( f, false ) || boost::bind( g, true ), false, false, f( false ) || g( true ) ); + test( boost::bind( f, false ) || boost::bind( g, false ), false, false, f( false ) || g( false ) ); + + test( boost::bind( f, true ) || boost::bind( h ), false, false, f( true ) || h() ); + + test( boost::bind( f, _1 ) || boost::bind( g, _2 ), false, true, f( false ) || g( true ) ); + test( boost::bind( f, _1 ) || boost::bind( g, _2 ), false, false, f( false ) || g( false ) ); + + test( boost::bind( f, _1 ) || boost::bind( h ), true, false, f( true ) || h() ); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_cdecl_mf_test.cpp b/src/boost/libs/bind/test/bind_cdecl_mf_test.cpp new file mode 100644 index 00000000..eaf84d6b --- /dev/null +++ b/src/boost/libs/bind/test/bind_cdecl_mf_test.cpp @@ -0,0 +1,174 @@ +#include <boost/config.hpp> + +#ifndef BOOST_MSVC + +int main() +{ +} + +#else + +#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_cdecl_mf_test.cpp - test for bind.hpp + __cdecl (member functions) +// +// Copyright (c) 2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#define BOOST_MEM_FN_ENABLE_CDECL + +#include <boost/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 __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 namespace boost; + + 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(); +} + +#endif diff --git a/src/boost/libs/bind/test/bind_const_test.cpp b/src/boost/libs/bind/test/bind_const_test.cpp new file mode 100644 index 00000000..9647ca90 --- /dev/null +++ b/src/boost/libs/bind/test/bind_const_test.cpp @@ -0,0 +1,184 @@ +#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_const_test.cpp - test const bind objects +// +// Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2001 David Abrahams +// +// 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 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 test(F const & f, A const & a) +{ + return f(a); +} + +template<class F, class A> long testv(F const & f, A const & a) +{ + f(a); + return global_result; +} + +void function_test() +{ + using namespace boost; + + int const i = 1; + + BOOST_TEST( test( bind(f_0), i ) == 17041L ); + BOOST_TEST( test( bind(f_1, _1), i ) == 1L ); + BOOST_TEST( test( bind(f_2, _1, 2), i ) == 21L ); + BOOST_TEST( test( bind(f_3, _1, 2, 3), i ) == 321L ); + BOOST_TEST( test( bind(f_4, _1, 2, 3, 4), i ) == 4321L ); + BOOST_TEST( test( bind(f_5, _1, 2, 3, 4, 5), i ) == 54321L ); + BOOST_TEST( test( bind(f_6, _1, 2, 3, 4, 5, 6), i ) == 654321L ); + BOOST_TEST( test( bind(f_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L ); + BOOST_TEST( test( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L ); + BOOST_TEST( test( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L ); + + BOOST_TEST( testv( bind(fv_0), i ) == 17041L ); + BOOST_TEST( testv( bind(fv_1, _1), i ) == 1L ); + BOOST_TEST( testv( bind(fv_2, _1, 2), i ) == 21L ); + BOOST_TEST( testv( bind(fv_3, _1, 2, 3), i ) == 321L ); + BOOST_TEST( testv( bind(fv_4, _1, 2, 3, 4), i ) == 4321L ); + BOOST_TEST( testv( bind(fv_5, _1, 2, 3, 4, 5), i ) == 54321L ); + BOOST_TEST( testv( bind(fv_6, _1, 2, 3, 4, 5, 6), i ) == 654321L ); + BOOST_TEST( testv( bind(fv_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L ); + BOOST_TEST( testv( bind(fv_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L ); + BOOST_TEST( testv( 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/bind/test/bind_cv_test.cpp b/src/boost/libs/bind/test/bind_cv_test.cpp new file mode 100644 index 00000000..257aaa9d --- /dev/null +++ b/src/boost/libs/bind/test/bind_cv_test.cpp @@ -0,0 +1,164 @@ +#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_cv_test.cpp +// +// Copyright (c) 2004 Peter Dimov +// +// 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> + +#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 +{ + // SGI-related compilers have odd compiler-synthesized ctors dtors + #ifdef __PATHSCALE__ + X() {} + ~X() {} + #endif + + 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() +{ + test( boost::bind<int>( X() ), 17041 ); + test( boost::bind<int>( X(), 1 ), 1 ); + test( boost::bind<int>( X(), 1, 2 ), 1+2 ); + test( boost::bind<int>( X(), 1, 2, 3 ), 1+2+3 ); + test( boost::bind<int>( X(), 1, 2, 3, 4 ), 1+2+3+4 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5 ), 1+2+3+4+5 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6 ), 1+2+3+4+5+6 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7 ), 1+2+3+4+5+6+7 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8 ), 1+2+3+4+5+6+7+8 ); + test( boost::bind<int>( 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/bind/test/bind_dm2_test.cpp b/src/boost/libs/bind/test/bind_dm2_test.cpp new file mode 100644 index 00000000..4bac5c7b --- /dev/null +++ b/src/boost/libs/bind/test/bind_dm2_test.cpp @@ -0,0 +1,70 @@ +#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_dm2_test.cpp - data members, advanced uses +// +// Copyright (c) 2005 Peter Dimov +// +// 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> + +#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() +{ + X x = { 0 }; + X * px = &x; + + boost::bind< int& >( &X::m, _1 )( px ) = 42; + + BOOST_TEST( x.m == 42 ); + + boost::bind< int& >( &X::m, boost::ref(x) )() = 17041; + + BOOST_TEST( x.m == 17041 ); + + X const * pcx = &x; + + BOOST_TEST( boost::bind< long >( &X::m, _1 )( pcx ) == 17041L ); + BOOST_TEST( boost::bind< long >( &X::m, pcx )() == 17041L ); + + Y y = { "test" }; + std::string v( "test" ); + + BOOST_TEST( boost::bind< char const* >( &Y::m, &y )() == v ); + BOOST_TEST( boost::bind< std::string >( &Y::m, &y )() == v ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_dm3_test.cpp b/src/boost/libs/bind/test/bind_dm3_test.cpp new file mode 100644 index 00000000..c9571d4c --- /dev/null +++ b/src/boost/libs/bind/test/bind_dm3_test.cpp @@ -0,0 +1,46 @@ +#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_dm3_test.cpp - data members (regression 1.31 - 1.32) +// +// Copyright (c) 2005 Peter Dimov +// +// 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> + +#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() +{ + typedef std::pair<int, int> pair_type; + + pair_type pair( 10, 20 ); + + int const & x = boost::bind( &pair_type::first, _1 )( pair ); + + BOOST_TEST( &pair.first == &x ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_dm_test.cpp b/src/boost/libs/bind/test/bind_dm_test.cpp new file mode 100644 index 00000000..67109657 --- /dev/null +++ b/src/boost/libs/bind/test/bind_dm_test.cpp @@ -0,0 +1,73 @@ +#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_dm_test.cpp - data members +// +// Copyright (c) 2005 Peter Dimov +// +// 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> + +#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() +{ + X x = { 17041 }; + X * px = &x; + + BOOST_TEST( boost::bind( &X::m, _1 )( x ) == 17041 ); + BOOST_TEST( boost::bind( &X::m, _1 )( px ) == 17041 ); + + BOOST_TEST( boost::bind( &X::m, x )() == 17041 ); + BOOST_TEST( boost::bind( &X::m, px )() == 17041 ); + BOOST_TEST( boost::bind( &X::m, boost::ref(x) )() == 17041 ); + + + X const cx = x; + X const * pcx = &cx; + + BOOST_TEST( boost::bind( &X::m, _1 )( cx ) == 17041 ); + BOOST_TEST( boost::bind( &X::m, _1 )( pcx ) == 17041 ); + + BOOST_TEST( boost::bind( &X::m, cx )() == 17041 ); + BOOST_TEST( boost::bind( &X::m, pcx )() == 17041 ); + BOOST_TEST( boost::bind( &X::m, boost::ref(cx) )() == 17041 ); + + int const v = 42; + + BOOST_TEST( boost::bind( &X::m, boost::bind( f, _1 ) )( v ) == v ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_eq2_test.cpp b/src/boost/libs/bind/test/bind_eq2_test.cpp new file mode 100644 index 00000000..3d7ca38d --- /dev/null +++ b/src/boost/libs/bind/test/bind_eq2_test.cpp @@ -0,0 +1,49 @@ +#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_eq2_test.cpp - boost::bind equality operator +// +// Copyright (c) 2004, 2005, 2009 Peter Dimov +// +// 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/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() +{ + test_self_equal( boost::bind( f, _1 ) ); + test_self_equal( boost::bind( g, _1 ) ); + test_self_equal( boost::bind( f, boost::bind( g, _1 ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_eq3_test.cpp b/src/boost/libs/bind/test/bind_eq3_test.cpp new file mode 100644 index 00000000..03a5593c --- /dev/null +++ b/src/boost/libs/bind/test/bind_eq3_test.cpp @@ -0,0 +1,45 @@ +#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_eq3_test.cpp - function_equal with bind and weak_ptr +// +// Copyright (c) 2004, 2005, 2009 Peter Dimov +// +// 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/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() +{ + test_self_equal( boost::bind( f, _1 ) ); + test_self_equal( boost::bind( f, boost::weak_ptr<void>() ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_eq_test.cpp b/src/boost/libs/bind/test/bind_eq_test.cpp new file mode 100644 index 00000000..742ac73d --- /dev/null +++ b/src/boost/libs/bind/test/bind_eq_test.cpp @@ -0,0 +1,427 @@ +#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_eq_test.cpp - boost::bind equality operator +// +// Copyright (c) 2004, 2005 Peter Dimov +// +// 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> + +#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 ) ); +} + +// 0 + +template<class F> void test_0(F f) +{ + test_eq( boost::bind(f), boost::bind(f) ); +} + +// 1 + +template<class F, class V> void test_1_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1), boost::bind(f, v1) ); + test_ne( boost::bind(f, v1), boost::bind(f, v2) ); +} + +template<class F> void test_1(F f) +{ + test_eq( boost::bind(f, _1), boost::bind(f, _1) ); + + test_1_( f, X(1), X(2) ); + + X a(0), b(0); + test_1_( f, boost::ref(a), boost::ref(b) ); +} + +// 2 + +template<class F, class V> void test_2_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1, v1), boost::bind(f, v1, v1) ); + test_ne( boost::bind(f, v1, v1), boost::bind(f, v1, v2) ); + test_ne( boost::bind(f, v1, v1), boost::bind(f, v2, v1) ); +} + +template<class F> void test_2(F f) +{ + test_eq( boost::bind(f, _1, _2), boost::bind(f, _1, _2) ); + + test_2_( f, X(1), X(2) ); + + X a(0), b(0); + test_2_( f, boost::ref(a), boost::ref(b) ); +} + +// 3 + +template<class F, class V> void test_3_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1, v1, v1), boost::bind(f, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1), boost::bind(f, v1, v1, v2) ); + test_ne( boost::bind(f, v1, v1, v1), boost::bind(f, v1, v2, v1) ); + test_ne( boost::bind(f, v1, v1, v1), boost::bind(f, v2, v1, v1) ); +} + +template<class F> void test_3(F f) +{ + test_eq( boost::bind(f, _1, _2, _3), boost::bind(f, _1, _2, _3) ); + + test_3_( f, X(1), X(2) ); + + X a(0), b(0); + test_3_( f, boost::ref(a), boost::ref(b) ); +} + +// 4 + +template<class F, class V> void test_4_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2) ); + test_ne( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1) ); +} + +template<class F> void test_4(F f) +{ + test_eq( boost::bind(f, _1, _2, _3, _4), boost::bind(f, _1, _2, _3, _4) ); + + test_4_( f, X(1), X(2) ); + + X a(0), b(0); + test_4_( f, boost::ref(a), boost::ref(b) ); +} + +// 5 + +template<class F, class V> void test_5_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1) ); +} + +template<class F> void test_5(F f) +{ + test_eq( boost::bind(f, _1, _2, _3, _4, _5), boost::bind(f, _1, _2, _3, _4, _5) ); + + test_5_( f, X(1), X(2) ); + + X a(0), b(0); + test_5_( f, boost::ref(a), boost::ref(b) ); +} + +// 6 + +template<class F, class V> void test_6_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v2) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_6(F f) +{ + test_eq( boost::bind(f, _1, _2, _3, _4, _5, _6), boost::bind(f, _1, _2, _3, _4, _5, _6) ); + + test_6_( f, X(1), X(2) ); + + X a(0), b(0); + test_6_( f, boost::ref(a), boost::ref(b) ); +} + +// 7 + +template<class F, class V> void test_7_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_7(F f) +{ + test_eq( boost::bind(f, _1, _2, _3, _4, _5, _6, _7), boost::bind(f, _1, _2, _3, _4, _5, _6, _7) ); + + test_7_( f, X(1), X(2) ); + + X a(0), b(0); + test_7_( f, boost::ref(a), boost::ref(b) ); +} + +// 8 + +template<class F, class V> void test_8_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_8(F f) +{ + test_eq( boost::bind(f, _1, _2, _3, _4, _5, _6, _7, _8), boost::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, boost::ref(a), boost::ref(b) ); +} + +// 9 + +template<class F, class V> void test_9_(F f, V v1, V v2) +{ + test_eq( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_9(F f) +{ + test_eq( boost::bind(f, _1, _2, _3, _4, _5, _6, _7, _8, _9), boost::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, boost::ref(a), boost::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/bind/test/bind_fastcall_mf_test.cpp b/src/boost/libs/bind/test/bind_fastcall_mf_test.cpp new file mode 100644 index 00000000..e333ec7b --- /dev/null +++ b/src/boost/libs/bind/test/bind_fastcall_mf_test.cpp @@ -0,0 +1,174 @@ +#include <boost/config.hpp> + +#ifndef BOOST_MSVC + +int main() +{ +} + +#else + +#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_stdcall_mf_test.cpp - test for bind.hpp + __stdcall (member functions) +// +// Copyright (c) 2001 Peter Dimov and Multi Media Ltd. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#define BOOST_MEM_FN_ENABLE_FASTCALL + +#include <boost/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 namespace boost; + + 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(); +} + +#endif diff --git a/src/boost/libs/bind/test/bind_fastcall_test.cpp b/src/boost/libs/bind/test/bind_fastcall_test.cpp new file mode 100644 index 00000000..b48c0718 --- /dev/null +++ b/src/boost/libs/bind/test/bind_fastcall_test.cpp @@ -0,0 +1,120 @@ +#include <boost/config.hpp> + +#ifndef BOOST_MSVC + +int main() +{ +} + +#else + +#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_fastcall_test.cpp - test for bind.hpp + __fastcall (free functions) +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#define BOOST_BIND_ENABLE_FASTCALL + +#include <boost/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 namespace boost; + + 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(); +} + +#endif diff --git a/src/boost/libs/bind/test/bind_fn2_test.cpp b/src/boost/libs/bind/test/bind_fn2_test.cpp new file mode 100644 index 00000000..93f587c0 --- /dev/null +++ b/src/boost/libs/bind/test/bind_fn2_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_fn2_test.cpp - test for functions w/ the type<> syntax +// +// Copyright (c) 2005, 2008 Peter Dimov +// +// 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> + +#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 namespace boost; + + bind( type<void>(), f_0 )(); BOOST_TEST( global_result == 17041L ); + bind( type<void>(), f_1, 1 )(); BOOST_TEST( global_result == 1L ); + bind( type<void>(), f_2, 1, 2 )(); BOOST_TEST( global_result == 21L ); + bind( type<void>(), f_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L ); + bind( type<void>(), f_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L ); + bind( type<void>(), f_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L ); + bind( type<void>(), f_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L ); + bind( type<void>(), f_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L ); + bind( type<void>(), f_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L ); + bind( type<void>(), f_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L ); + + bind( type<void>(), fv_0 )(); BOOST_TEST( global_result == 17041L ); + bind( type<void>(), fv_1, 1 )(); BOOST_TEST( global_result == 1L ); + bind( type<void>(), fv_2, 1, 2 )(); BOOST_TEST( global_result == 21L ); + bind( type<void>(), fv_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L ); + bind( type<void>(), fv_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L ); + bind( type<void>(), fv_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L ); + bind( type<void>(), fv_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L ); + bind( type<void>(), fv_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L ); + bind( type<void>(), fv_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L ); + bind( type<void>(), 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/bind/test/bind_fnobj2_test.cpp b/src/boost/libs/bind/test/bind_fnobj2_test.cpp new file mode 100644 index 00000000..a85fe5dd --- /dev/null +++ b/src/boost/libs/bind/test/bind_fnobj2_test.cpp @@ -0,0 +1,76 @@ +#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_fnobj2_test.cpp - test for function objects w/ the type<> syntax +// +// Copyright (c) 2005, 2008 Peter Dimov +// +// 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> + +#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 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 namespace boost; + + X x; + + bind( type<void>(), ref(x) )(); + bind( type<void>(), ref(x), 1 )(); + bind( type<void>(), ref(x), 1, 2 )(); + bind( type<void>(), ref(x), 1, 2, 3 )(); + bind( type<void>(), ref(x), 1, 2, 3, 4 )(); + bind( type<void>(), ref(x), 1, 2, 3, 4, 5 )(); + bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6 )(); + bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6, 7)(); + bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind( type<void>(), 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/bind/test/bind_function2_test.cpp b/src/boost/libs/bind/test/bind_function2_test.cpp new file mode 100644 index 00000000..f991248a --- /dev/null +++ b/src/boost/libs/bind/test/bind_function2_test.cpp @@ -0,0 +1,118 @@ +#include <boost/config.hpp> + +// +// bind_function2_test.cpp - regression test +// +// Copyright (c) 2015 Peter Dimov +// +// 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/function.hpp> +#include <boost/detail/lightweight_test.hpp> + +// + +void fv1( int & a ) +{ + a = 17041; +} + +void fv2( int & a, int b ) +{ + a = b; +} + +void fv3( int & a, int b, int c ) +{ + a = b + c; +} + +void fv4( int & a, int b, int c, int d ) +{ + a = b + c + d; +} + +void fv5( int & a, int b, int c, int d, int e ) +{ + a = b + c + d + e; +} + +void fv6( int & a, int b, int c, int d, int e, int f ) +{ + a = b + c + d + e + f; +} + +void fv7( int & a, int b, int c, int d, int e, int f, int g ) +{ + a = b + c + d + e + f + g; +} + +void fv8( int & a, int b, int c, int d, int e, int f, int g, int h ) +{ + a = b + c + d + e + f + g + h; +} + +void fv9( int & a, int b, int c, int d, int e, int f, int g, int h, int i ) +{ + a = b + c + d + e + f + g + h + i; +} + +void function_test() +{ + int x = 0; + + { + boost::function<void(int&)> fw1 = boost::bind( fv1, _1 ); + fw1( x ); BOOST_TEST( x == 17041 ); + } + + { + boost::function<void(int&, int)> fw2 = boost::bind( fv2, _1, _2 ); + fw2( x, 1 ); BOOST_TEST( x == 1 ); + } + + { + boost::function<void(int&, int, int)> fw3 = boost::bind( fv3, _1, _2, _3 ); + fw3( x, 1, 2 ); BOOST_TEST( x == 1+2 ); + } + + { + boost::function<void(int&, int, int, int)> fw4 = boost::bind( fv4, _1, _2, _3, _4 ); + fw4( x, 1, 2, 3 ); BOOST_TEST( x == 1+2+3 ); + } + + { + boost::function<void(int&, int, int, int, int)> fw5 = boost::bind( fv5, _1, _2, _3, _4, _5 ); + fw5( x, 1, 2, 3, 4 ); BOOST_TEST( x == 1+2+3+4 ); + } + + { + boost::function<void(int&, int, int, int, int, int)> fw6 = boost::bind( fv6, _1, _2, _3, _4, _5, _6 ); + fw6( x, 1, 2, 3, 4, 5 ); BOOST_TEST( x == 1+2+3+4+5 ); + } + + { + boost::function<void(int&, int, int, int, int, int, int)> fw7 = boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 ); + fw7( x, 1, 2, 3, 4, 5, 6 ); BOOST_TEST( x == 1+2+3+4+5+6 ); + } + + { + boost::function<void(int&, int, int, int, int, int, int, int)> fw8 = boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 ); + fw8( x, 1, 2, 3, 4, 5, 6, 7 ); BOOST_TEST( x == 1+2+3+4+5+6+7 ); + } + + { + boost::function<void(int&, int, int, int, int, int, int, int, int)> fw9 = boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 ); + fw9( x, 1, 2, 3, 4, 5, 6, 7, 8 ); BOOST_TEST( x == 1+2+3+4+5+6+7+8 ); + } +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_function_ap_test.cpp b/src/boost/libs/bind/test/bind_function_ap_test.cpp new file mode 100644 index 00000000..67551d32 --- /dev/null +++ b/src/boost/libs/bind/test/bind_function_ap_test.cpp @@ -0,0 +1,234 @@ +#include <boost/config.hpp> + +// +// bind_function_ap_test.cpp - regression test +// +// Copyright (c) 2015 Peter Dimov +// +// 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 +// + +#if defined( BOOST_NO_AUTO_PTR ) + +int main() +{ +} + +#else + +#if defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 406 ) +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined( __clang__ ) && defined( __has_warning ) +# if __has_warning( "-Wdeprecated-declarations" ) +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# endif +#endif + +#include <boost/bind.hpp> +#include <boost/function.hpp> +#include <boost/detail/lightweight_test.hpp> +#include <memory> + +// + +void fv1( std::auto_ptr<int> p1 ) +{ + BOOST_TEST( *p1 == 1 ); +} + +void fv2( std::auto_ptr<int> p1, std::auto_ptr<int> p2 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); +} + +void fv3( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); +} + +void fv4( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); +} + +void fv5( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); +} + +void fv6( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); + BOOST_TEST( *p6 == 6 ); +} + +void fv7( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); + BOOST_TEST( *p6 == 6 ); + BOOST_TEST( *p7 == 7 ); +} + +void fv8( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7, std::auto_ptr<int> p8 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); + BOOST_TEST( *p6 == 6 ); + BOOST_TEST( *p7 == 7 ); + BOOST_TEST( *p8 == 8 ); +} + +void fv9( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7, std::auto_ptr<int> p8, std::auto_ptr<int> p9 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); + BOOST_TEST( *p6 == 6 ); + BOOST_TEST( *p7 == 7 ); + BOOST_TEST( *p8 == 8 ); + BOOST_TEST( *p9 == 9 ); +} + +void test() +{ + { + boost::function<void(std::auto_ptr<int>)> fw1 = boost::bind( fv1, _1 ); + + std::auto_ptr<int> p1( new int(1) ); + + fw1( p1 ); + } + + { + boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>)> fw2 = boost::bind( fv2, _1, _2 ); + + std::auto_ptr<int> p1( new int(1) ); + std::auto_ptr<int> p2( new int(2) ); + + fw2( p1, p2 ); + } + + { + boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw3 = boost::bind( fv3, _1, _2, _3 ); + + std::auto_ptr<int> p1( new int(1) ); + std::auto_ptr<int> p2( new int(2) ); + std::auto_ptr<int> p3( new int(3) ); + + fw3( p1, p2, p3 ); + } + + { + boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw4 = boost::bind( fv4, _1, _2, _3, _4 ); + + std::auto_ptr<int> p1( new int(1) ); + std::auto_ptr<int> p2( new int(2) ); + std::auto_ptr<int> p3( new int(3) ); + std::auto_ptr<int> p4( new int(4) ); + + fw4( p1, p2, p3, p4 ); + } + + { + boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw5 = boost::bind( fv5, _1, _2, _3, _4, _5 ); + + std::auto_ptr<int> p1( new int(1) ); + std::auto_ptr<int> p2( new int(2) ); + std::auto_ptr<int> p3( new int(3) ); + std::auto_ptr<int> p4( new int(4) ); + std::auto_ptr<int> p5( new int(5) ); + + fw5( p1, p2, p3, p4, p5 ); + } + + { + boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw6 = boost::bind( fv6, _1, _2, _3, _4, _5, _6 ); + + std::auto_ptr<int> p1( new int(1) ); + std::auto_ptr<int> p2( new int(2) ); + std::auto_ptr<int> p3( new int(3) ); + std::auto_ptr<int> p4( new int(4) ); + std::auto_ptr<int> p5( new int(5) ); + std::auto_ptr<int> p6( new int(6) ); + + fw6( p1, p2, p3, p4, p5, p6 ); + } + + { + boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw7 = boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 ); + + std::auto_ptr<int> p1( new int(1) ); + std::auto_ptr<int> p2( new int(2) ); + std::auto_ptr<int> p3( new int(3) ); + std::auto_ptr<int> p4( new int(4) ); + std::auto_ptr<int> p5( new int(5) ); + std::auto_ptr<int> p6( new int(6) ); + std::auto_ptr<int> p7( new int(7) ); + + fw7( p1, p2, p3, p4, p5, p6, p7 ); + } + + { + boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw8 = boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 ); + + std::auto_ptr<int> p1( new int(1) ); + std::auto_ptr<int> p2( new int(2) ); + std::auto_ptr<int> p3( new int(3) ); + std::auto_ptr<int> p4( new int(4) ); + std::auto_ptr<int> p5( new int(5) ); + std::auto_ptr<int> p6( new int(6) ); + std::auto_ptr<int> p7( new int(7) ); + std::auto_ptr<int> p8( new int(8) ); + + fw8( p1, p2, p3, p4, p5, p6, p7, p8 ); + } + + { + boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw9 = boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 ); + + std::auto_ptr<int> p1( new int(1) ); + std::auto_ptr<int> p2( new int(2) ); + std::auto_ptr<int> p3( new int(3) ); + std::auto_ptr<int> p4( new int(4) ); + std::auto_ptr<int> p5( new int(5) ); + std::auto_ptr<int> p6( new int(6) ); + std::auto_ptr<int> p7( new int(7) ); + std::auto_ptr<int> p8( new int(8) ); + std::auto_ptr<int> p9( new int(9) ); + + fw9( p1, p2, p3, p4, p5, p6, p7, p8, p9 ); + } +} + +int main() +{ + test(); + return boost::report_errors(); +} + +#endif // #if defined( BOOST_NO_AUTO_PTR ) diff --git a/src/boost/libs/bind/test/bind_function_test.cpp b/src/boost/libs/bind/test/bind_function_test.cpp new file mode 100644 index 00000000..5ce18c45 --- /dev/null +++ b/src/boost/libs/bind/test/bind_function_test.cpp @@ -0,0 +1,77 @@ +#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_function_test.cpp - function<> +// +// Copyright (c) 2005 Peter Dimov +// +// 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) +// + +#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 + +#include <boost/bind.hpp> +#include <boost/detail/lightweight_test.hpp> + +int f( int x ) +{ + return x; +} + +int g( int x ) +{ + return x + 1; +} + +int main() +{ + boost::function0<int> fn; + + BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) ); + + fn = boost::bind( f, 1 ); + + BOOST_TEST( fn() == 1 ); + + BOOST_TEST( fn.contains( boost::bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) ); + + fn = boost::bind( f, 2 ); + + BOOST_TEST( fn() == 2 ); + + BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) ); + BOOST_TEST( fn.contains( boost::bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) ); + + fn = boost::bind( g, 1 ); + + BOOST_TEST( fn() == 2 ); + + BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) ); + BOOST_TEST( fn.contains( boost::bind( g, 1 ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_fwd2_test.cpp b/src/boost/libs/bind/test/bind_fwd2_test.cpp new file mode 100644 index 00000000..5b7bf9cd --- /dev/null +++ b/src/boost/libs/bind/test/bind_fwd2_test.cpp @@ -0,0 +1,121 @@ +#include <boost/config.hpp> + +// +// bind_fwd2_test.cpp - forwarding test for 2 arguments +// +// Copyright (c) 2015 Peter Dimov +// +// 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/detail/lightweight_test.hpp> + +// + +int fv1( int const & a ) +{ + return a; +} + +void fv2_1( int & a, int const & b ) +{ + a = b; +} + +void fv2_2( int const & a, int & b ) +{ + b = a; +} + +int fv2_3( int const & a, int const & b ) +{ + return a+b; +} + +void test() +{ + { + int const a = 1; + int r = boost::bind( fv1, _1 )( a ); + BOOST_TEST( r == 1 ); + } + + { + int r = boost::bind( fv1, _1 )( 1 ); + BOOST_TEST( r == 1 ); + } + + { + int a = 1; + int const b = 2; + + boost::bind( fv2_1, _1, _2 )( a, b ); + + BOOST_TEST( a == 2 ); + } + + { + int a = 1; + + boost::bind( fv2_1, _1, _2 )( a, 2 ); + + BOOST_TEST( a == 2 ); + } + + { + int const a = 1; + int b = 2; + + boost::bind( fv2_2, _1, _2 )( a, b ); + + BOOST_TEST( b == 1 ); + } + + { + int b = 2; + + boost::bind( fv2_2, _1, _2 )( 1, b ); + + BOOST_TEST( b == 1 ); + } + + { + int const a = 1; + int const b = 2; + + int r = boost::bind( fv2_3, _1, _2 )( a, b ); + + BOOST_TEST( r == 3 ); + } + + { + int const a = 1; + + int r = boost::bind( fv2_3, _1, _2 )( a, 2 ); + + BOOST_TEST( r == 3 ); + } + + { + int const b = 2; + + int r = boost::bind( fv2_3, _1, _2 )( 1, b ); + + BOOST_TEST( r == 3 ); + } + + { + int r = boost::bind( fv2_3, _1, _2 )( 1, 2 ); + + BOOST_TEST( r == 3 ); + } +} + +int main() +{ + test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_fwd_test.cpp b/src/boost/libs/bind/test/bind_fwd_test.cpp new file mode 100644 index 00000000..92bd3b18 --- /dev/null +++ b/src/boost/libs/bind/test/bind_fwd_test.cpp @@ -0,0 +1,250 @@ +#include <boost/config.hpp> + +// +// bind_fwd_test.cpp - forwarding test +// +// Copyright (c) 2015 Peter Dimov +// +// 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/detail/lightweight_test.hpp> + +// + +void fv1( int & a ) +{ + a = 1; +} + +void fv2( int & a, int & b ) +{ + a = 1; + b = 2; +} + +void fv3( int & a, int & b, int & c ) +{ + a = 1; + b = 2; + c = 3; +} + +void fv4( int & a, int & b, int & c, int & d ) +{ + a = 1; + b = 2; + c = 3; + d = 4; +} + +void fv5( int & a, int & b, int & c, int & d, int & e ) +{ + a = 1; + b = 2; + c = 3; + d = 4; + e = 5; +} + +void fv6( int & a, int & b, int & c, int & d, int & e, int & f ) +{ + a = 1; + b = 2; + c = 3; + d = 4; + e = 5; + f = 6; +} + +void fv7( int & a, int & b, int & c, int & d, int & e, int & f, int & g ) +{ + a = 1; + b = 2; + c = 3; + d = 4; + e = 5; + f = 6; + g = 7; +} + +void fv8( int & a, int & b, int & c, int & d, int & e, int & f, int & g, int & h ) +{ + a = 1; + b = 2; + c = 3; + d = 4; + e = 5; + f = 6; + g = 7; + h = 8; +} + +void fv9( int & a, int & b, int & c, int & d, int & e, int & f, int & g, int & h, int & i ) +{ + a = 1; + b = 2; + c = 3; + d = 4; + e = 5; + f = 6; + g = 7; + h = 8; + i = 9; +} + +void test() +{ + { + int a = 0; + + boost::bind( fv1, _1 )( a ); + + BOOST_TEST( a == 1 ); + } + + { + int a = 0; + int b = 0; + + boost::bind( fv2, _1, _2 )( a, b ); + + BOOST_TEST( a == 1 ); + BOOST_TEST( b == 2 ); + } + + { + int a = 0; + int b = 0; + int c = 0; + + boost::bind( fv3, _1, _2, _3 )( a, b, c ); + + BOOST_TEST( a == 1 ); + BOOST_TEST( b == 2 ); + BOOST_TEST( c == 3 ); + } + + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + + boost::bind( fv4, _1, _2, _3, _4 )( a, b, c, d ); + + BOOST_TEST( a == 1 ); + BOOST_TEST( b == 2 ); + BOOST_TEST( c == 3 ); + BOOST_TEST( d == 4 ); + } + + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + int e = 0; + + boost::bind( fv5, _1, _2, _3, _4, _5 )( a, b, c, d, e ); + + BOOST_TEST( a == 1 ); + BOOST_TEST( b == 2 ); + BOOST_TEST( c == 3 ); + BOOST_TEST( d == 4 ); + BOOST_TEST( e == 5 ); + } + + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + int e = 0; + int f = 0; + + boost::bind( fv6, _1, _2, _3, _4, _5, _6 )( a, b, c, d, e, f ); + + BOOST_TEST( a == 1 ); + BOOST_TEST( b == 2 ); + BOOST_TEST( c == 3 ); + BOOST_TEST( d == 4 ); + BOOST_TEST( e == 5 ); + BOOST_TEST( f == 6 ); + } + + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + int e = 0; + int f = 0; + int g = 0; + + boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 )( a, b, c, d, e, f, g ); + + BOOST_TEST( a == 1 ); + BOOST_TEST( b == 2 ); + BOOST_TEST( c == 3 ); + BOOST_TEST( d == 4 ); + BOOST_TEST( e == 5 ); + BOOST_TEST( f == 6 ); + BOOST_TEST( g == 7 ); + } + + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + int e = 0; + int f = 0; + int g = 0; + int h = 0; + + boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 )( a, b, c, d, e, f, g, h ); + + BOOST_TEST( a == 1 ); + BOOST_TEST( b == 2 ); + BOOST_TEST( c == 3 ); + BOOST_TEST( d == 4 ); + BOOST_TEST( e == 5 ); + BOOST_TEST( f == 6 ); + BOOST_TEST( g == 7 ); + BOOST_TEST( h == 8 ); + } + + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + int e = 0; + int f = 0; + int g = 0; + int h = 0; + int i = 0; + + boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 )( a, b, c, d, e, f, g, h, i ); + + BOOST_TEST( a == 1 ); + BOOST_TEST( b == 2 ); + BOOST_TEST( c == 3 ); + BOOST_TEST( d == 4 ); + BOOST_TEST( e == 5 ); + BOOST_TEST( f == 6 ); + BOOST_TEST( g == 7 ); + BOOST_TEST( h == 8 ); + BOOST_TEST( i == 9 ); + } +} + +int main() +{ + test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_lookup_problem_test.cpp b/src/boost/libs/bind/test/bind_lookup_problem_test.cpp new file mode 100644 index 00000000..269b80aa --- /dev/null +++ b/src/boost/libs/bind/test/bind_lookup_problem_test.cpp @@ -0,0 +1,40 @@ +// +// bind_lookup_problem_test.cpp +// +// Copyright (C) Markus Schoepflin 2005. +// +// Use, modification, and distribution are subject to 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> + +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() +{ + boost::bind(f0); + boost::bind(f1, 0); + boost::bind(f2, 0, 0); + boost::bind(f3, 0, 0, 0); + boost::bind(f4, 0, 0, 0, 0); + boost::bind(f5, 0, 0, 0, 0, 0); + boost::bind(f6, 0, 0, 0, 0, 0, 0); + boost::bind(f7, 0, 0, 0, 0, 0, 0, 0); + boost::bind(f8, 0, 0, 0, 0, 0, 0, 0, 0); + boost::bind(f9, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + return 0; +} diff --git a/src/boost/libs/bind/test/bind_mf2_test.cpp b/src/boost/libs/bind/test/bind_mf2_test.cpp new file mode 100644 index 00000000..c04f9589 --- /dev/null +++ b/src/boost/libs/bind/test/bind_mf2_test.cpp @@ -0,0 +1,162 @@ +#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_mf2_test.cpp - test for member functions w/ the type<> syntax +// +// Copyright (c) 2005, 2008 Peter Dimov +// +// 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> + +#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 namespace boost; + + X x; + + // 0 + + bind( type<void>(), &X::f0, &x )(); + bind( type<void>(), &X::f0, ref(x) )(); + + bind( type<void>(), &X::g0, &x )(); + bind( type<void>(), &X::g0, x )(); + bind( type<void>(), &X::g0, ref(x) )(); + + // 1 + + bind( type<void>(), &X::f1, &x, 1 )(); + bind( type<void>(), &X::f1, ref(x), 1 )(); + + bind( type<void>(), &X::g1, &x, 1 )(); + bind( type<void>(), &X::g1, x, 1 )(); + bind( type<void>(), &X::g1, ref(x), 1 )(); + + // 2 + + bind( type<void>(), &X::f2, &x, 1, 2 )(); + bind( type<void>(), &X::f2, ref(x), 1, 2 )(); + + bind( type<void>(), &X::g2, &x, 1, 2 )(); + bind( type<void>(), &X::g2, x, 1, 2 )(); + bind( type<void>(), &X::g2, ref(x), 1, 2 )(); + + // 3 + + bind( type<void>(), &X::f3, &x, 1, 2, 3 )(); + bind( type<void>(), &X::f3, ref(x), 1, 2, 3 )(); + + bind( type<void>(), &X::g3, &x, 1, 2, 3 )(); + bind( type<void>(), &X::g3, x, 1, 2, 3 )(); + bind( type<void>(), &X::g3, ref(x), 1, 2, 3 )(); + + // 4 + + bind( type<void>(), &X::f4, &x, 1, 2, 3, 4 )(); + bind( type<void>(), &X::f4, ref(x), 1, 2, 3, 4 )(); + + bind( type<void>(), &X::g4, &x, 1, 2, 3, 4 )(); + bind( type<void>(), &X::g4, x, 1, 2, 3, 4 )(); + bind( type<void>(), &X::g4, ref(x), 1, 2, 3, 4 )(); + + // 5 + + bind( type<void>(), &X::f5, &x, 1, 2, 3, 4, 5 )(); + bind( type<void>(), &X::f5, ref(x), 1, 2, 3, 4, 5 )(); + + bind( type<void>(), &X::g5, &x, 1, 2, 3, 4, 5 )(); + bind( type<void>(), &X::g5, x, 1, 2, 3, 4, 5 )(); + bind( type<void>(), &X::g5, ref(x), 1, 2, 3, 4, 5 )(); + + // 6 + + bind( type<void>(), &X::f6, &x, 1, 2, 3, 4, 5, 6 )(); + bind( type<void>(), &X::f6, ref(x), 1, 2, 3, 4, 5, 6 )(); + + bind( type<void>(), &X::g6, &x, 1, 2, 3, 4, 5, 6 )(); + bind( type<void>(), &X::g6, x, 1, 2, 3, 4, 5, 6 )(); + bind( type<void>(), &X::g6, ref(x), 1, 2, 3, 4, 5, 6 )(); + + // 7 + + bind( type<void>(), &X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind( type<void>(), &X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind( type<void>(), &X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind( type<void>(), &X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind( type<void>(), &X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind( type<void>(), &X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind( type<void>(), &X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + + bind( type<void>(), &X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind( type<void>(), &X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind( type<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/bind/test/bind_nested_rv_test.cpp b/src/boost/libs/bind/test/bind_nested_rv_test.cpp new file mode 100644 index 00000000..281088fd --- /dev/null +++ b/src/boost/libs/bind/test/bind_nested_rv_test.cpp @@ -0,0 +1,177 @@ +#include <boost/config.hpp> + +// +// bind_nested_rv_test.cpp +// +// Copyright (c) 2016 Peter Dimov +// +// 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/make_shared.hpp> +#include <boost/function.hpp> +#include <boost/detail/lightweight_test.hpp> + +// + +bool f1( boost::shared_ptr<int> p1 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + return true; +} + +bool f2( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + BOOST_TEST( p2 != 0 && *p2 == 2 ); + return true; +} + +bool f3( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + BOOST_TEST( p2 != 0 && *p2 == 2 ); + BOOST_TEST( p3 != 0 && *p3 == 3 ); + return true; +} + +bool f4( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + BOOST_TEST( p2 != 0 && *p2 == 2 ); + BOOST_TEST( p3 != 0 && *p3 == 3 ); + BOOST_TEST( p4 != 0 && *p4 == 4 ); + return true; +} + +bool f5( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + BOOST_TEST( p2 != 0 && *p2 == 2 ); + BOOST_TEST( p3 != 0 && *p3 == 3 ); + BOOST_TEST( p4 != 0 && *p4 == 4 ); + BOOST_TEST( p5 != 0 && *p5 == 5 ); + return true; +} + +bool f6( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5, boost::shared_ptr<int> p6 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + BOOST_TEST( p2 != 0 && *p2 == 2 ); + BOOST_TEST( p3 != 0 && *p3 == 3 ); + BOOST_TEST( p4 != 0 && *p4 == 4 ); + BOOST_TEST( p5 != 0 && *p5 == 5 ); + BOOST_TEST( p6 != 0 && *p6 == 6 ); + return true; +} + +bool f7( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5, boost::shared_ptr<int> p6, boost::shared_ptr<int> p7 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + BOOST_TEST( p2 != 0 && *p2 == 2 ); + BOOST_TEST( p3 != 0 && *p3 == 3 ); + BOOST_TEST( p4 != 0 && *p4 == 4 ); + BOOST_TEST( p5 != 0 && *p5 == 5 ); + BOOST_TEST( p6 != 0 && *p6 == 6 ); + BOOST_TEST( p7 != 0 && *p7 == 7 ); + return true; +} + +bool f8( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5, boost::shared_ptr<int> p6, boost::shared_ptr<int> p7, boost::shared_ptr<int> p8 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + BOOST_TEST( p2 != 0 && *p2 == 2 ); + BOOST_TEST( p3 != 0 && *p3 == 3 ); + BOOST_TEST( p4 != 0 && *p4 == 4 ); + BOOST_TEST( p5 != 0 && *p5 == 5 ); + BOOST_TEST( p6 != 0 && *p6 == 6 ); + BOOST_TEST( p7 != 0 && *p7 == 7 ); + BOOST_TEST( p8 != 0 && *p8 == 8 ); + return true; +} + +bool f9( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5, boost::shared_ptr<int> p6, boost::shared_ptr<int> p7, boost::shared_ptr<int> p8, boost::shared_ptr<int> p9 ) +{ + BOOST_TEST( p1 != 0 && *p1 == 1 ); + BOOST_TEST( p2 != 0 && *p2 == 2 ); + BOOST_TEST( p3 != 0 && *p3 == 3 ); + BOOST_TEST( p4 != 0 && *p4 == 4 ); + BOOST_TEST( p5 != 0 && *p5 == 5 ); + BOOST_TEST( p6 != 0 && *p6 == 6 ); + BOOST_TEST( p7 != 0 && *p7 == 7 ); + BOOST_TEST( p8 != 0 && *p8 == 8 ); + BOOST_TEST( p9 != 0 && *p9 == 9 ); + return true; +} + +void test() +{ + { + boost::function<bool(boost::shared_ptr<int>)> f( f1 ); + + ( boost::bind( f, _1 ) && boost::bind( f1, _1 ) )( boost::make_shared<int>( 1 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f2 ); + + ( boost::bind( f, _1, _2 ) && boost::bind( f2, _1, _2 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f3 ); + + ( boost::bind( f, _1, _2, _3 ) && boost::bind( f3, _1, _2, _3 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f3 ); + + ( boost::bind( f, _1, _2, _3 ) && boost::bind( f3, _1, _2, _3 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f4 ); + + ( boost::bind( f, _1, _2, _3, _4 ) && boost::bind( f4, _1, _2, _3, _4 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f5 ); + + ( boost::bind( f, _1, _2, _3, _4, _5 ) && boost::bind( f5, _1, _2, _3, _4, _5 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f6 ); + + ( boost::bind( f, _1, _2, _3, _4, _5, _6 ) && boost::bind( f6, _1, _2, _3, _4, _5, _6 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ), boost::make_shared<int>( 6 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f7 ); + + ( boost::bind( f, _1, _2, _3, _4, _5, _6, _7 ) && boost::bind( f7, _1, _2, _3, _4, _5, _6, _7 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ), boost::make_shared<int>( 6 ), boost::make_shared<int>( 7 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f8 ); + + ( boost::bind( f, _1, _2, _3, _4, _5, _6, _7, _8 ) && boost::bind( f8, _1, _2, _3, _4, _5, _6, _7, _8 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ), boost::make_shared<int>( 6 ), boost::make_shared<int>( 7 ), boost::make_shared<int>( 8 ) ); + } + + { + boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f9 ); + + ( boost::bind( f, _1, _2, _3, _4, _5, _6, _7, _8, _9 ) && boost::bind( f9, _1, _2, _3, _4, _5, _6, _7, _8, _9 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ), boost::make_shared<int>( 6 ), boost::make_shared<int>( 7 ), boost::make_shared<int>( 8 ), boost::make_shared<int>( 9 ) ); + } +} + +int main() +{ + test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_no_placeholders_test.cpp b/src/boost/libs/bind/test/bind_no_placeholders_test.cpp new file mode 100644 index 00000000..840823d8 --- /dev/null +++ b/src/boost/libs/bind/test/bind_no_placeholders_test.cpp @@ -0,0 +1,99 @@ +// +// bind_no_placeholders_test.cpp - test for BOOST_BIND_NO_PLACEHOLDERS +// +// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2001 David Abrahams +// Copyright (c) 2015 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// + +#define BOOST_BIND_NO_PLACEHOLDERS +#include <boost/bind.hpp> +#include <boost/core/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; +} + +void function_test() +{ + using namespace boost; + + arg<1> _1; + arg<2> _2; + arg<3> _3; + arg<4> _4; + arg<5> _5; + arg<6> _6; + arg<7> _7; + arg<8> _8; + arg<9> _9; + + BOOST_TEST( bind(f_0)() == 17041L ); + BOOST_TEST( bind(f_1, _1)(1) == 1L ); + BOOST_TEST( bind(f_2, _1, _2)(1, 2) == 21L ); + BOOST_TEST( bind(f_3, _1, _2, _3)(1, 2, 3) == 321L ); + BOOST_TEST( bind(f_4, _1, _2, _3, _4)(1, 2, 3, 4) == 4321L ); + BOOST_TEST( bind(f_5, _1, _2, _3, _4, _5)(1, 2, 3, 4, 5) == 54321L ); + BOOST_TEST( bind(f_6, _1, _2, _3, _4, _5, _6)(1, 2, 3, 4, 5, 6) == 654321L ); + BOOST_TEST( bind(f_7, _1, _2, _3, _4, _5, _6, _7)(1, 2, 3, 4, 5, 6, 7) == 7654321L ); + BOOST_TEST( bind(f_8, _1, _2, _3, _4, _5, _6, _7, _8)(1, 2, 3, 4, 5, 6, 7, 8) == 87654321L ); + BOOST_TEST( bind(f_9, _1, _2, _3, _4, _5, _6, _7, _8, _9)(1, 2, 3, 4, 5, 6, 7, 8, 9) == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_noexcept_mf_test.cpp b/src/boost/libs/bind/test/bind_noexcept_mf_test.cpp new file mode 100644 index 00000000..752861c6 --- /dev/null +++ b/src/boost/libs/bind/test/bind_noexcept_mf_test.cpp @@ -0,0 +1,154 @@ +// +// bind_noexcept_mf_test.cpp +// +// Copyright 2017 Peter Dimov +// +// 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> +#include <boost/core/lightweight_test.hpp> +#include <boost/config.hpp> + +#if defined(BOOST_NO_CXX11_NOEXCEPT) + +int main() +{ +} + +#else + +// + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int f0() noexcept { f1(17); return 0; } + int g0() const noexcept { g1(17); return 0; } + + int f1(int a1) noexcept { hash = (hash * 17041 + a1) % 32768; return 0; } + int g1(int a1) const noexcept { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int f2(int a1, int a2) noexcept { f1(a1); f1(a2); return 0; } + int g2(int a1, int a2) const noexcept { g1(a1); g1(a2); return 0; } + + int f3(int a1, int a2, int a3) noexcept { f2(a1, a2); f1(a3); return 0; } + int g3(int a1, int a2, int a3) const noexcept { g2(a1, a2); g1(a3); return 0; } + + int f4(int a1, int a2, int a3, int a4) noexcept { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) const noexcept { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) noexcept { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) const noexcept { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) noexcept { 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 noexcept { 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) noexcept { 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 noexcept { 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) noexcept { 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 noexcept { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + X x; + + // 0 + + boost::bind(&X::f0, &x)(); + boost::bind(&X::f0, boost::ref(x))(); + + boost::bind(&X::g0, &x)(); + boost::bind(&X::g0, x)(); + boost::bind(&X::g0, boost::ref(x))(); + + // 1 + + boost::bind(&X::f1, &x, 1)(); + boost::bind(&X::f1, boost::ref(x), 1)(); + + boost::bind(&X::g1, &x, 1)(); + boost::bind(&X::g1, x, 1)(); + boost::bind(&X::g1, boost::ref(x), 1)(); + + // 2 + + boost::bind(&X::f2, &x, 1, 2)(); + boost::bind(&X::f2, boost::ref(x), 1, 2)(); + + boost::bind(&X::g2, &x, 1, 2)(); + boost::bind(&X::g2, x, 1, 2)(); + boost::bind(&X::g2, boost::ref(x), 1, 2)(); + + // 3 + + boost::bind(&X::f3, &x, 1, 2, 3)(); + boost::bind(&X::f3, boost::ref(x), 1, 2, 3)(); + + boost::bind(&X::g3, &x, 1, 2, 3)(); + boost::bind(&X::g3, x, 1, 2, 3)(); + boost::bind(&X::g3, boost::ref(x), 1, 2, 3)(); + + // 4 + + boost::bind(&X::f4, &x, 1, 2, 3, 4)(); + boost::bind(&X::f4, boost::ref(x), 1, 2, 3, 4)(); + + boost::bind(&X::g4, &x, 1, 2, 3, 4)(); + boost::bind(&X::g4, x, 1, 2, 3, 4)(); + boost::bind(&X::g4, boost::ref(x), 1, 2, 3, 4)(); + + // 5 + + boost::bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + boost::bind(&X::f5, boost::ref(x), 1, 2, 3, 4, 5)(); + + boost::bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + boost::bind(&X::g5, x, 1, 2, 3, 4, 5)(); + boost::bind(&X::g5, boost::ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + boost::bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + boost::bind(&X::f6, boost::ref(x), 1, 2, 3, 4, 5, 6)(); + + boost::bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + boost::bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + boost::bind(&X::g6, boost::ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + boost::bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + boost::bind(&X::f7, boost::ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + boost::bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + boost::bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + boost::bind(&X::g7, boost::ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + boost::bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + boost::bind(&X::f8, boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + boost::bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + boost::bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + boost::bind(&X::g8, boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} + +#endif diff --git a/src/boost/libs/bind/test/bind_noexcept_test.cpp b/src/boost/libs/bind/test/bind_noexcept_test.cpp new file mode 100644 index 00000000..44af4f69 --- /dev/null +++ b/src/boost/libs/bind/test/bind_noexcept_test.cpp @@ -0,0 +1,97 @@ +// +// bind_noexcept_test.cpp +// +// Copyright 2017 Peter Dimov +// +// 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/core/lightweight_test.hpp> +#include <boost/config.hpp> + +#if defined(BOOST_NO_CXX11_NOEXCEPT) + +int main() +{ +} + +#else + +// + +long f_0() noexcept +{ + return 17041L; +} + +long f_1(long a) noexcept +{ + return a; +} + +long f_2(long a, long b) noexcept +{ + return a + 10 * b; +} + +long f_3(long a, long b, long c) noexcept +{ + return a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) noexcept +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) noexcept +{ + 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) noexcept +{ + 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) noexcept +{ + 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) noexcept +{ + 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) noexcept +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + int const i = 1; + + BOOST_TEST( boost::bind(f_0)(i) == 17041L ); + BOOST_TEST( boost::bind(f_1, _1)(i) == 1L ); + BOOST_TEST( boost::bind(f_2, _1, 2)(i) == 21L ); + BOOST_TEST( boost::bind(f_3, _1, 2, 3)(i) == 321L ); + BOOST_TEST( boost::bind(f_4, _1, 2, 3, 4)(i) == 4321L ); + BOOST_TEST( boost::bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L ); + BOOST_TEST( boost::bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L ); + BOOST_TEST( boost::bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); + BOOST_TEST( boost::bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); + BOOST_TEST( boost::bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} + +#endif diff --git a/src/boost/libs/bind/test/bind_not_test.cpp b/src/boost/libs/bind/test/bind_not_test.cpp new file mode 100644 index 00000000..27da3f23 --- /dev/null +++ b/src/boost/libs/bind/test/bind_not_test.cpp @@ -0,0 +1,57 @@ +#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_not_test.cpp - operator! +// +// Copyright (c) 2005 Peter Dimov +// +// 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> + +#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 test( 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() +{ + test( !boost::bind( f, true ), 0, !f( true ) ); + test( !boost::bind( g, _1 ), 5, !g( 5 ) ); + test( boost::bind( f, !boost::bind( f, true ) ), 0, f( !f( true ) ) ); + test( boost::bind( f, !boost::bind( f, _1 ) ), true, f( !f( true ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_placeholder_test.cpp b/src/boost/libs/bind/test/bind_placeholder_test.cpp new file mode 100644 index 00000000..174dd82b --- /dev/null +++ b/src/boost/libs/bind/test/bind_placeholder_test.cpp @@ -0,0 +1,83 @@ +#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_placeholder_test.cpp - test custom placeholders +// +// Copyright (c) 2006 Peter Dimov +// +// 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> + +#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 +{ +}; + +namespace boost +{ + +template< int I > struct is_placeholder< custom_placeholder< I > > +{ + enum { value = I }; +}; + +} // namespace boost + +int main() +{ + 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<1> p1; + custom_placeholder<2> p2; + custom_placeholder<3> p3; + custom_placeholder<4> p4; + custom_placeholder<5> p5; + custom_placeholder<6> p6; + custom_placeholder<7> p7; + custom_placeholder<8> p8; + custom_placeholder<9> p9; + + BOOST_TEST( + boost::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/bind/test/bind_ref_test.cpp b/src/boost/libs/bind/test/bind_ref_test.cpp new file mode 100644 index 00000000..f08172eb --- /dev/null +++ b/src/boost/libs/bind/test/bind_ref_test.cpp @@ -0,0 +1,36 @@ +// +// bind_ref_test.cpp - reference_wrapper +// +// Copyright (c) 2009 Peter Dimov +// +// 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> +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int f( int x ) + { + return x; + } + + int g( int x ) const + { + return -x; + } +}; + +int main() +{ + X x; + + BOOST_TEST( boost::bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 ); + BOOST_TEST( boost::bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_rel_test.cpp b/src/boost/libs/bind/test/bind_rel_test.cpp new file mode 100644 index 00000000..5c50b6fa --- /dev/null +++ b/src/boost/libs/bind/test/bind_rel_test.cpp @@ -0,0 +1,97 @@ +#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_rel_test.cpp - ==, !=, <, <=, >, >= operators +// +// Copyright (c) 2005 Peter Dimov +// +// 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> + +#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() +{ + int x = 4; + int y = x + x; + + // bind op value + + BOOST_TEST( ( boost::bind( f, _1 ) == y )( x ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) != y )( x ) ) ); + + BOOST_TEST( !( ( boost::bind( f, _1 ) < y )( x ) ) ); + BOOST_TEST( ( boost::bind( f, _1 ) < y + 1 )( x ) ); + + BOOST_TEST( !( ( boost::bind( f, _1 ) > y )( x ) ) ); + BOOST_TEST( ( boost::bind( f, _1 ) > y - 1 )( x ) ); + + BOOST_TEST( !( ( boost::bind( f, _1 ) <= y - 1 )( x ) ) ); + BOOST_TEST( ( boost::bind( f, _1 ) <= y )( x ) ); + BOOST_TEST( ( boost::bind( f, _1 ) <= y + 1 )( x ) ); + + BOOST_TEST( !( ( boost::bind( f, _1 ) >= y + 1 )( x ) ) ); + BOOST_TEST( ( boost::bind( f, _1 ) >= y )( x ) ); + BOOST_TEST( ( boost::bind( f, _1 ) >= y - 1 )( x ) ); + + // bind op ref + + BOOST_TEST( ( boost::bind( f, _1 ) == boost::ref( y ) )( x ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) != boost::ref( y ) )( x ) ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) < boost::ref( y ) )( x ) ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) > boost::ref( y ) )( x ) ) ); + BOOST_TEST( ( boost::bind( f, _1 ) <= boost::ref( y ) )( x ) ); + BOOST_TEST( ( boost::bind( f, _1 ) >= boost::ref( y ) )( x ) ); + + // bind op placeholder + + BOOST_TEST( ( boost::bind( f, _1 ) == _2 )( x, y ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) != _2 )( x, y ) ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) < _2 )( x, y ) ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) > _2 )( x, y ) ) ); + BOOST_TEST( ( boost::bind( f, _1 ) <= _2 )( x, y ) ); + BOOST_TEST( ( boost::bind( f, _1 ) >= _2 )( x, y ) ); + + // bind op bind + + // important: bind( f, _1 ) and bind( g, _1 ) have the same type + BOOST_TEST( ( boost::bind( f, _1 ) == boost::bind( g, _1 ) )( x ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) != boost::bind( g, _1 ) )( x ) ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) < boost::bind( g, _1 ) )( x ) ) ); + BOOST_TEST( ( boost::bind( f, _1 ) <= boost::bind( g, _1 ) )( x ) ); + BOOST_TEST( !( ( boost::bind( f, _1 ) > boost::bind( g, _1 ) )( x ) ) ); + BOOST_TEST( ( boost::bind( f, _1 ) >= boost::bind( g, _1 ) )( x ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_rv_sp_test.cpp b/src/boost/libs/bind/test/bind_rv_sp_test.cpp new file mode 100644 index 00000000..b5853cd4 --- /dev/null +++ b/src/boost/libs/bind/test/bind_rv_sp_test.cpp @@ -0,0 +1,64 @@ +#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_rv_sp_test.cpp - smart pointer returned by value from an inner bind +// +// Copyright (c) 2005 Peter Dimov +// +// 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> + +#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() +{ + Y y; + + BOOST_TEST( boost::bind( &X::f, boost::bind( &Y::f, &y ) )() == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_rvalue_test.cpp b/src/boost/libs/bind/test/bind_rvalue_test.cpp new file mode 100644 index 00000000..e0bd2291 --- /dev/null +++ b/src/boost/libs/bind/test/bind_rvalue_test.cpp @@ -0,0 +1,81 @@ +#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_rvalue_test.cpp +// +// Copyright (c) 2006 Peter Dimov +// +// 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> + +#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() +{ + BOOST_TEST( + boost::bind( f, _1 ) + ( 1 ) == 1 ); + + BOOST_TEST( + boost::bind( f, _2 ) + ( 1, 2 ) == 2 ); + + BOOST_TEST( + boost::bind( f, _3 ) + ( 1, 2, 3 ) == 3 ); + + BOOST_TEST( + boost::bind( f, _4 ) + ( 1, 2, 3, 4 ) == 4 ); + + BOOST_TEST( + boost::bind( f, _5 ) + ( 1, 2, 3, 4, 5 ) == 5 ); + + BOOST_TEST( + boost::bind( f, _6 ) + ( 1, 2, 3, 4, 5, 6 ) == 6 ); + + BOOST_TEST( + boost::bind( f, _7 ) + ( 1, 2, 3, 4, 5, 6, 7 ) == 7 ); + + BOOST_TEST( + boost::bind( f, _8 ) + ( 1, 2, 3, 4, 5, 6, 7, 8 ) == 8 ); + + BOOST_TEST( + boost::bind( f, _9 ) + ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) == 9 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_stateful_test.cpp b/src/boost/libs/bind/test/bind_stateful_test.cpp new file mode 100644 index 00000000..04fc0e87 --- /dev/null +++ b/src/boost/libs/bind/test/bind_stateful_test.cpp @@ -0,0 +1,227 @@ +#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_stateful_test.cpp +// +// Copyright (c) 2004 Peter Dimov +// +// 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> + +#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: + + int state_; + +public: + + X(): state_(0) + { + } + + // SGI-related compilers have odd compiler-synthesized ctors and dtors + #ifdef __PATHSCALE__ + ~X() {} + #endif + + int state() const + { + return state_; + } + + 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<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 ); +} + +void stateful_function_object_test() +{ + test( boost::bind<int>( X() ), 0, 17041 ); + test( boost::bind<int>( X(), 1 ), 0, 1 ); + test( boost::bind<int>( X(), 1, 2 ), 0, 1+2 ); + test( boost::bind<int>( X(), 1, 2, 3 ), 0, 1+2+3 ); + test( boost::bind<int>( X(), 1, 2, 3, 4 ), 0, 1+2+3+4 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5 ), 0, 1+2+3+4+5 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6 ), 0, 1+2+3+4+5+6 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7 ), 0, 1+2+3+4+5+6+7 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8 ), 0, 1+2+3+4+5+6+7+8 ); + test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 0, 1+2+3+4+5+6+7+8+9 ); + + X x; + + int n = x.state(); + + test( boost::bind<int>( boost::ref(x) ), n, 17041 ); + n += 3*17041; + + test( boost::bind<int>( boost::ref(x), 1 ), n, 1 ); + n += 3*1; + + test( boost::bind<int>( boost::ref(x), 1, 2 ), n, 1+2 ); + n += 3*(1+2); + + test( boost::bind<int>( boost::ref(x), 1, 2, 3 ), n, 1+2+3 ); + n += 3*(1+2+3); + + test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4 ), n, 1+2+3+4 ); + n += 3*(1+2+3+4); + + test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4, 5 ), n, 1+2+3+4+5 ); + n += 3*(1+2+3+4+5); + + test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4, 5, 6 ), n, 1+2+3+4+5+6 ); + n += 3*(1+2+3+4+5+6); + + test( boost::bind<int>( boost::ref(x), 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( boost::bind<int>( boost::ref(x), 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( boost::bind<int>( boost::ref(x), 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( x.state() == n ); +} + +void stateful_function_test() +{ + test( boost::bind( f0, 0 ), 0, 17041 ); + test( boost::bind( f1, 0, 1 ), 0, 1 ); + test( boost::bind( f2, 0, 1, 2 ), 0, 1+2 ); + test( boost::bind( f3, 0, 1, 2, 3 ), 0, 1+2+3 ); + test( boost::bind( f4, 0, 1, 2, 3, 4 ), 0, 1+2+3+4 ); + test( boost::bind( f5, 0, 1, 2, 3, 4, 5 ), 0, 1+2+3+4+5 ); + test( boost::bind( f6, 0, 1, 2, 3, 4, 5, 6 ), 0, 1+2+3+4+5+6 ); + test( boost::bind( f7, 0, 1, 2, 3, 4, 5, 6, 7 ), 0, 1+2+3+4+5+6+7 ); + test( boost::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/bind/test/bind_stdcall_mf_test.cpp b/src/boost/libs/bind/test/bind_stdcall_mf_test.cpp new file mode 100644 index 00000000..a7570c21 --- /dev/null +++ b/src/boost/libs/bind/test/bind_stdcall_mf_test.cpp @@ -0,0 +1,174 @@ +#include <boost/config.hpp> + +#ifndef BOOST_MSVC + +int main() +{ +} + +#else + +#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_stdcall_mf_test.cpp - test for bind.hpp + __stdcall (member functions) +// +// Copyright (c) 2001 Peter Dimov and Multi Media Ltd. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#define BOOST_MEM_FN_ENABLE_STDCALL + +#include <boost/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 namespace boost; + + 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(); +} + +#endif diff --git a/src/boost/libs/bind/test/bind_stdcall_test.cpp b/src/boost/libs/bind/test/bind_stdcall_test.cpp new file mode 100644 index 00000000..a009c9ac --- /dev/null +++ b/src/boost/libs/bind/test/bind_stdcall_test.cpp @@ -0,0 +1,122 @@ +#include <boost/config.hpp> + +#ifndef BOOST_MSVC + +int main() +{ +} + +#else + +#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_stdcall_test.cpp - test for bind.hpp + __stdcall (free functions) +// +// Copyright (c) 2001 Peter Dimov and Multi Media Ltd. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#define BOOST_BIND_ENABLE_STDCALL + +#include <boost/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 namespace boost; + + 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(); +} + +#endif diff --git a/src/boost/libs/bind/test/bind_test.cpp b/src/boost/libs/bind/test/bind_test.cpp new file mode 100644 index 00000000..ede5d496 --- /dev/null +++ b/src/boost/libs/bind/test/bind_test.cpp @@ -0,0 +1,521 @@ +#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_test.cpp - monolithic test for bind.hpp +// +// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2001 David Abrahams +// +// 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 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 namespace boost; + + 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 +{ + 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 namespace boost; + + short i(6); + + int const k = 3; + + BOOST_TEST( bind<short>(Y(), ref(i))() == 7 ); + BOOST_TEST( bind<short>(Y(), ref(i))() == 8 ); + BOOST_TEST( bind<int>(Y(), i, _1)(k) == 38 ); + BOOST_TEST( bind<long>(Y(), i, _1, 9)(k) == 938 ); + +#if !defined(__MWERKS__) || (__MWERKS__ > 0x2407) // Fails for this version of the compiler. + + global_result = 0; + bind<void>(Y(), i, _1, 9, 4)(k); + BOOST_TEST( global_result == 4938 ); + +#endif +} + +void function_object_test2() +{ + using namespace boost; + + short i(6); + + int const k = 3; + + BOOST_TEST( bind(type<short>(), Y(), ref(i))() == 7 ); + BOOST_TEST( bind(type<short>(), Y(), ref(i))() == 8 ); + BOOST_TEST( bind(type<int>(), Y(), i, _1)(k) == 38 ); + BOOST_TEST( bind(type<long>(), Y(), i, _1, 9)(k) == 938 ); + + global_result = 0; + bind(type<void>(), 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() +{ + BOOST_TEST( boost::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 namespace boost; + + 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 namespace boost; + + 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 namespace boost; + + 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/bind/test/bind_type_test.cpp b/src/boost/libs/bind/test/bind_type_test.cpp new file mode 100644 index 00000000..fc58bad8 --- /dev/null +++ b/src/boost/libs/bind/test/bind_type_test.cpp @@ -0,0 +1,75 @@ +#include <boost/config.hpp> + +// +// bind_type_test.cpp +// +// Copyright (c) 2015 Peter Dimov +// +// 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/detail/lightweight_test.hpp> + +// + +template<int I> struct X +{ +}; + +void fv1( X<1> ) +{ +} + +void fv2( X<1>, X<2> ) +{ +} + +void fv3( X<1>, X<2>, X<3> ) +{ +} + +void fv4( X<1>, X<2>, X<3>, X<4> ) +{ +} + +void fv5( X<1>, X<2>, X<3>, X<4>, X<5> ) +{ +} + +void fv6( X<1>, X<2>, X<3>, X<4>, X<5>, X<6> ) +{ +} + +void fv7( X<1>, X<2>, X<3>, X<4>, X<5>, X<6>, X<7> ) +{ +} + +void fv8( X<1>, X<2>, X<3>, X<4>, X<5>, X<6>, X<7>, X<8> ) +{ +} + +void fv9( X<1>, X<2>, X<3>, X<4>, X<5>, X<6>, X<7>, X<8>, X<9> ) +{ +} + +void test() +{ + boost::bind( fv1, _1 )( X<1>() ); + boost::bind( fv2, _1, _2 )( X<1>(), X<2>() ); + boost::bind( fv3, _1, _2, _3 )( X<1>(), X<2>(), X<3>() ); + boost::bind( fv4, _1, _2, _3, _4 )( X<1>(), X<2>(), X<3>(), X<4>() ); + boost::bind( fv5, _1, _2, _3, _4, _5 )( X<1>(), X<2>(), X<3>(), X<4>(), X<5>() ); + boost::bind( fv6, _1, _2, _3, _4, _5, _6 )( X<1>(), X<2>(), X<3>(), X<4>(), X<5>(), X<6>() ); + boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 )( X<1>(), X<2>(), X<3>(), X<4>(), X<5>(), X<6>(), X<7>() ); + boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 )( X<1>(), X<2>(), X<3>(), X<4>(), X<5>(), X<6>(), X<7>(), X<8>() ); + boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 )( X<1>(), X<2>(), X<3>(), X<4>(), X<5>(), X<6>(), X<7>(), X<8>(), X<9>() ); +} + +int main() +{ + test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_unary_addr.cpp b/src/boost/libs/bind/test/bind_unary_addr.cpp new file mode 100644 index 00000000..b211f0fe --- /dev/null +++ b/src/boost/libs/bind/test/bind_unary_addr.cpp @@ -0,0 +1,147 @@ +#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_unary_addr.cpp +// +// Copyright (c) 2005 Peter Dimov +// +// 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> + +#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: + + 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() +{ + test( boost::bind<void>( X() ) ); + test( boost::bind<void>( X(), 1 ) ); + test( boost::bind<void>( X(), 1, 2 ) ); + test( boost::bind<void>( X(), 1, 2, 3 ) ); + test( boost::bind<void>( X(), 1, 2, 3, 4 ) ); + test( boost::bind<void>( X(), 1, 2, 3, 4, 5 ) ); + test( boost::bind<void>( X(), 1, 2, 3, 4, 5, 6 ) ); + test( boost::bind<void>( X(), 1, 2, 3, 4, 5, 6, 7 ) ); + test( boost::bind<void>( X(), 1, 2, 3, 4, 5, 6, 7, 8 ) ); + test( boost::bind<void>( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ) ); + + return 0; +} diff --git a/src/boost/libs/bind/test/bind_unique_ptr_test.cpp b/src/boost/libs/bind/test/bind_unique_ptr_test.cpp new file mode 100644 index 00000000..4e648f54 --- /dev/null +++ b/src/boost/libs/bind/test/bind_unique_ptr_test.cpp @@ -0,0 +1,207 @@ +#include <boost/config.hpp> + +#if defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) || defined( BOOST_NO_CXX11_SMART_PTR ) + +int main() +{ +} + +#else + +// +// bind_unique_ptr_test.cpp +// +// Copyright (c) 2015 Peter Dimov +// +// 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/detail/lightweight_test.hpp> +#include <memory> + +// + +void fv1( std::unique_ptr<int> p1 ) +{ + BOOST_TEST( *p1 == 1 ); +} + +void fv2( std::unique_ptr<int> p1, std::unique_ptr<int> p2 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); +} + +void fv3( std::unique_ptr<int> p1, std::unique_ptr<int> p2, std::unique_ptr<int> p3 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); +} + +void fv4( std::unique_ptr<int> p1, std::unique_ptr<int> p2, std::unique_ptr<int> p3, std::unique_ptr<int> p4 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); +} + +void fv5( std::unique_ptr<int> p1, std::unique_ptr<int> p2, std::unique_ptr<int> p3, std::unique_ptr<int> p4, std::unique_ptr<int> p5 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); +} + +void fv6( std::unique_ptr<int> p1, std::unique_ptr<int> p2, std::unique_ptr<int> p3, std::unique_ptr<int> p4, std::unique_ptr<int> p5, std::unique_ptr<int> p6 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); + BOOST_TEST( *p6 == 6 ); +} + +void fv7( std::unique_ptr<int> p1, std::unique_ptr<int> p2, std::unique_ptr<int> p3, std::unique_ptr<int> p4, std::unique_ptr<int> p5, std::unique_ptr<int> p6, std::unique_ptr<int> p7 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); + BOOST_TEST( *p6 == 6 ); + BOOST_TEST( *p7 == 7 ); +} + +void fv8( std::unique_ptr<int> p1, std::unique_ptr<int> p2, std::unique_ptr<int> p3, std::unique_ptr<int> p4, std::unique_ptr<int> p5, std::unique_ptr<int> p6, std::unique_ptr<int> p7, std::unique_ptr<int> p8 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); + BOOST_TEST( *p6 == 6 ); + BOOST_TEST( *p7 == 7 ); + BOOST_TEST( *p8 == 8 ); +} + +void fv9( std::unique_ptr<int> p1, std::unique_ptr<int> p2, std::unique_ptr<int> p3, std::unique_ptr<int> p4, std::unique_ptr<int> p5, std::unique_ptr<int> p6, std::unique_ptr<int> p7, std::unique_ptr<int> p8, std::unique_ptr<int> p9 ) +{ + BOOST_TEST( *p1 == 1 ); + BOOST_TEST( *p2 == 2 ); + BOOST_TEST( *p3 == 3 ); + BOOST_TEST( *p4 == 4 ); + BOOST_TEST( *p5 == 5 ); + BOOST_TEST( *p6 == 6 ); + BOOST_TEST( *p7 == 7 ); + BOOST_TEST( *p8 == 8 ); + BOOST_TEST( *p9 == 9 ); +} + +void test() +{ + { + std::unique_ptr<int> p1( new int(1) ); + + boost::bind( fv1, _1 )( std::move( p1 ) ); + } + + { + std::unique_ptr<int> p1( new int(1) ); + std::unique_ptr<int> p2( new int(2) ); + + boost::bind( fv2, _1, _2 )( std::move( p1 ), std::move( p2 ) ); + } + + { + std::unique_ptr<int> p1( new int(1) ); + std::unique_ptr<int> p2( new int(2) ); + std::unique_ptr<int> p3( new int(3) ); + + boost::bind( fv3, _1, _2, _3 )( std::move( p1 ), std::move( p2 ), std::move( p3 ) ); + } + + { + std::unique_ptr<int> p1( new int(1) ); + std::unique_ptr<int> p2( new int(2) ); + std::unique_ptr<int> p3( new int(3) ); + std::unique_ptr<int> p4( new int(4) ); + + boost::bind( fv4, _1, _2, _3, _4 )( std::move( p1 ), std::move( p2 ), std::move( p3 ), std::move( p4 ) ); + } + + { + std::unique_ptr<int> p1( new int(1) ); + std::unique_ptr<int> p2( new int(2) ); + std::unique_ptr<int> p3( new int(3) ); + std::unique_ptr<int> p4( new int(4) ); + std::unique_ptr<int> p5( new int(5) ); + + boost::bind( fv5, _1, _2, _3, _4, _5 )( std::move( p1 ), std::move( p2 ), std::move( p3 ), std::move( p4 ), std::move( p5 ) ); + } + + { + std::unique_ptr<int> p1( new int(1) ); + std::unique_ptr<int> p2( new int(2) ); + std::unique_ptr<int> p3( new int(3) ); + std::unique_ptr<int> p4( new int(4) ); + std::unique_ptr<int> p5( new int(5) ); + std::unique_ptr<int> p6( new int(6) ); + + boost::bind( fv6, _1, _2, _3, _4, _5, _6 )( std::move( p1 ), std::move( p2 ), std::move( p3 ), std::move( p4 ), std::move( p5 ), std::move( p6 ) ); + } + + { + std::unique_ptr<int> p1( new int(1) ); + std::unique_ptr<int> p2( new int(2) ); + std::unique_ptr<int> p3( new int(3) ); + std::unique_ptr<int> p4( new int(4) ); + std::unique_ptr<int> p5( new int(5) ); + std::unique_ptr<int> p6( new int(6) ); + std::unique_ptr<int> p7( new int(7) ); + + boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 )( std::move( p1 ), std::move( p2 ), std::move( p3 ), std::move( p4 ), std::move( p5 ), std::move( p6 ), std::move( p7 ) ); + } + + { + std::unique_ptr<int> p1( new int(1) ); + std::unique_ptr<int> p2( new int(2) ); + std::unique_ptr<int> p3( new int(3) ); + std::unique_ptr<int> p4( new int(4) ); + std::unique_ptr<int> p5( new int(5) ); + std::unique_ptr<int> p6( new int(6) ); + std::unique_ptr<int> p7( new int(7) ); + std::unique_ptr<int> p8( new int(8) ); + + boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 )( std::move( p1 ), std::move( p2 ), std::move( p3 ), std::move( p4 ), std::move( p5 ), std::move( p6 ), std::move( p7 ), std::move( p8 ) ); + } + + { + std::unique_ptr<int> p1( new int(1) ); + std::unique_ptr<int> p2( new int(2) ); + std::unique_ptr<int> p3( new int(3) ); + std::unique_ptr<int> p4( new int(4) ); + std::unique_ptr<int> p5( new int(5) ); + std::unique_ptr<int> p6( new int(6) ); + std::unique_ptr<int> p7( new int(7) ); + std::unique_ptr<int> p8( new int(8) ); + std::unique_ptr<int> p9( new int(9) ); + + boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 )( std::move( p1 ), std::move( p2 ), std::move( p3 ), std::move( p4 ), std::move( p5 ), std::move( p6 ), std::move( p7 ), std::move( p8 ), std::move( p9 ) ); + } +} + +int main() +{ + test(); + return boost::report_errors(); +} + +#endif // #if defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) || defined( BOOST_NO_CXX11_SMART_PTR ) diff --git a/src/boost/libs/bind/test/bind_visit_test.cpp b/src/boost/libs/bind/test/bind_visit_test.cpp new file mode 100644 index 00000000..16299ddd --- /dev/null +++ b/src/boost/libs/bind/test/bind_visit_test.cpp @@ -0,0 +1,68 @@ +#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 +# pragma warning(disable: 4100) // unreferenced formal parameter (it is referenced!) +#endif + +// Copyright (c) 2006 Douglas Gregor <doug.gregor@gmail.com> +// Copyright (c) 2006 Peter Dimov +// +// 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/visit_each.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +# pragma warning(push, 3) +#endif + +#include <iostream> +#include <typeinfo> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +# pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct visitor +{ + int hash; + + visitor(): hash( 0 ) + { + } + + template<typename T> void operator()( T const & t ) + { + std::cout << "visitor::operator()( T ): " << typeid( t ).name() << std::endl; + } + + void operator()( int const & t ) + { + std::cout << "visitor::operator()( int ): " << t << std::endl; + hash = hash * 10 + t; + } +}; + +int f( int x, int y, int z ) +{ + return x + y + z; +} + +int main() +{ + visitor vis; + + boost::visit_each( vis, boost::bind( f, 3, _1, 4 ) ); + + BOOST_TEST( vis.hash == 34 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_void_dm_test.cpp b/src/boost/libs/bind/test/bind_void_dm_test.cpp new file mode 100644 index 00000000..ffa60f9a --- /dev/null +++ b/src/boost/libs/bind/test/bind_void_dm_test.cpp @@ -0,0 +1,72 @@ +#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> + +// + +struct Z +{ + int m; +}; + +void member_data_test() +{ + Z z = { 17041 }; + Z * pz = &z; + + boost::bind<void>( &Z::m, _1 )( z ); + boost::bind<void>( &Z::m, _1 )( pz ); + + boost::bind<void>( &Z::m, z )(); + boost::bind<void>( &Z::m, pz )(); + boost::bind<void>( &Z::m, boost::ref(z) )(); + + + Z const cz = z; + Z const * pcz = &cz; + + boost::bind<void>( &Z::m, _1 )( cz ); + boost::bind<void>( &Z::m, _1 )( pcz ); + + boost::bind<void>( &Z::m, cz )(); + boost::bind<void>( &Z::m, pcz )(); + boost::bind<void>( &Z::m, boost::ref(cz) )(); +} + +int main() +{ + member_data_test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/bind_void_mf_test.cpp b/src/boost/libs/bind/test/bind_void_mf_test.cpp new file mode 100644 index 00000000..e66a9c8f --- /dev/null +++ b/src/boost/libs/bind/test/bind_void_mf_test.cpp @@ -0,0 +1,198 @@ +#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; } + void h0() { h1(17); } + + int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + void h1(int a1) { hash = (hash * 17041 + a1 * 2) % 32768; } + + 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; } + void h2(int a1, int a2) { h1(a1); h1(a2); } + + 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; } + void h3(int a1, int a2, int a3) { h2(a1, a2); h1(a3); } + + 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; } + void h4(int a1, int a2, int a3, int a4) { h3(a1, a2, a3); h1(a4); } + + 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; } + void h5(int a1, int a2, int a3, int a4, int a5) { h4(a1, a2, a3, a4); h1(a5); } + + 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; } + void h6(int a1, int a2, int a3, int a4, int a5, int a6) { h5(a1, a2, a3, a4, a5); h1(a6); } + + 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; } + void h7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { h6(a1, a2, a3, a4, a5, a6); h1(a7); } + + 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 h8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { h7(a1, a2, a3, a4, a5, a6, a7); h1(a8); } +}; + +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))(); + + bind<void>(&X::h0, 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)(); + + bind<void>(&X::h1, 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)(); + + bind<void>(&X::h2, 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)(); + + bind<void>(&X::h3, 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)(); + + bind<void>(&X::h4, 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)(); + + bind<void>(&X::h5, 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)(); + + bind<void>(&X::h6, 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)(); + + bind<void>(&X::h7, 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)(); + + bind<void>(&X::h8, 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/bind/test/bind_void_test.cpp b/src/boost/libs/bind/test/bind_void_test.cpp new file mode 100644 index 00000000..bb1e80da --- /dev/null +++ b/src/boost/libs/bind/test/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(); +} diff --git a/src/boost/libs/bind/test/cmake_subdir_test/CMakeLists.txt b/src/boost/libs/bind/test/cmake_subdir_test/CMakeLists.txt new file mode 100644 index 00000000..8cac315f --- /dev/null +++ b/src/boost/libs/bind/test/cmake_subdir_test/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2018, 2019 Peter Dimov +# 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 + +cmake_minimum_required(VERSION 3.5) + +project(cmake_subdir_test LANGUAGES CXX) + +add_subdirectory(../.. boostorg/bind) +add_subdirectory(../../../assert boostorg/assert) +add_subdirectory(../../../config boostorg/config) +add_subdirectory(../../../core boostorg/core) + +add_executable(quick ../quick.cpp) +target_link_libraries(quick Boost::bind Boost::core) + +enable_testing() +add_test(quick quick) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>) diff --git a/src/boost/libs/bind/test/mem_fn_cdecl_test.cpp b/src/boost/libs/bind/test/mem_fn_cdecl_test.cpp new file mode 100644 index 00000000..ed5a47ce --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_cdecl_test.cpp @@ -0,0 +1,196 @@ +#include <boost/config.hpp> + +#ifndef BOOST_MSVC + +int main() +{ +} + +#else + +#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 + +// +// mem_fn_cdecl_test.cpp - a test for mem_fn.hpp + __cdecl +// +// Copyright (c) 2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#define BOOST_MEM_FN_ENABLE_CDECL + +#include <boost/mem_fn.hpp> +#include <boost/shared_ptr.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 + + +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; } +}; + +int detect_errors(bool x) +{ + if(x) + { + std::cerr << "no errors detected.\n"; + return 0; + } + else + { + std::cerr << "test failed.\n"; + return 1; + } +} + +int main() +{ + using boost::mem_fn; + + X x; + + X const & rcx = x; + X const * pcx = &x; + + boost::shared_ptr<X> sp(new X); + + mem_fn(&X::f0)(x); + mem_fn(&X::f0)(&x); + mem_fn(&X::f0)(sp); + + mem_fn(&X::g0)(x); + mem_fn(&X::g0)(rcx); + mem_fn(&X::g0)(&x); + mem_fn(&X::g0)(pcx); + mem_fn(&X::g0)(sp); + + mem_fn(&X::f1)(x, 1); + mem_fn(&X::f1)(&x, 1); + mem_fn(&X::f1)(sp, 1); + + mem_fn(&X::g1)(x, 1); + mem_fn(&X::g1)(rcx, 1); + mem_fn(&X::g1)(&x, 1); + mem_fn(&X::g1)(pcx, 1); + mem_fn(&X::g1)(sp, 1); + + mem_fn(&X::f2)(x, 1, 2); + mem_fn(&X::f2)(&x, 1, 2); + mem_fn(&X::f2)(sp, 1, 2); + + mem_fn(&X::g2)(x, 1, 2); + mem_fn(&X::g2)(rcx, 1, 2); + mem_fn(&X::g2)(&x, 1, 2); + mem_fn(&X::g2)(pcx, 1, 2); + mem_fn(&X::g2)(sp, 1, 2); + + mem_fn(&X::f3)(x, 1, 2, 3); + mem_fn(&X::f3)(&x, 1, 2, 3); + mem_fn(&X::f3)(sp, 1, 2, 3); + + mem_fn(&X::g3)(x, 1, 2, 3); + mem_fn(&X::g3)(rcx, 1, 2, 3); + mem_fn(&X::g3)(&x, 1, 2, 3); + mem_fn(&X::g3)(pcx, 1, 2, 3); + mem_fn(&X::g3)(sp, 1, 2, 3); + + mem_fn(&X::f4)(x, 1, 2, 3, 4); + mem_fn(&X::f4)(&x, 1, 2, 3, 4); + mem_fn(&X::f4)(sp, 1, 2, 3, 4); + + mem_fn(&X::g4)(x, 1, 2, 3, 4); + mem_fn(&X::g4)(rcx, 1, 2, 3, 4); + mem_fn(&X::g4)(&x, 1, 2, 3, 4); + mem_fn(&X::g4)(pcx, 1, 2, 3, 4); + mem_fn(&X::g4)(sp, 1, 2, 3, 4); + + mem_fn(&X::f5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::g5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + return detect_errors(x.hash == 17610 && sp->hash == 2155); +} + +#endif diff --git a/src/boost/libs/bind/test/mem_fn_derived_test.cpp b/src/boost/libs/bind/test/mem_fn_derived_test.cpp new file mode 100644 index 00000000..f8aa0e90 --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_derived_test.cpp @@ -0,0 +1,188 @@ +#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 + +// +// mem_fn_derived_test.cpp - tests mem_fn.hpp with derived objects +// +// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// +// 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/mem_fn.hpp> +#include <boost/shared_ptr.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 + + +struct B +{ + mutable unsigned int hash; + + B(): 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 X: public B +{ +}; + +int detect_errors(bool x) +{ + if(x) + { + std::cerr << "no errors detected.\n"; + return 0; + } + else + { + std::cerr << "test failed.\n"; + return 1; + } +} + +int main() +{ + using boost::mem_fn; + + X x; + + X const & rcx = x; + X const * pcx = &x; + + boost::shared_ptr<X> sp(new X); + + mem_fn(&X::f0)(x); + mem_fn(&X::f0)(&x); + mem_fn(&X::f0)(sp); + + mem_fn(&X::g0)(x); + mem_fn(&X::g0)(rcx); + mem_fn(&X::g0)(&x); + mem_fn(&X::g0)(pcx); + mem_fn(&X::g0)(sp); + + mem_fn(&X::f1)(x, 1); + mem_fn(&X::f1)(&x, 1); + mem_fn(&X::f1)(sp, 1); + + mem_fn(&X::g1)(x, 1); + mem_fn(&X::g1)(rcx, 1); + mem_fn(&X::g1)(&x, 1); + mem_fn(&X::g1)(pcx, 1); + mem_fn(&X::g1)(sp, 1); + + mem_fn(&X::f2)(x, 1, 2); + mem_fn(&X::f2)(&x, 1, 2); + mem_fn(&X::f2)(sp, 1, 2); + + mem_fn(&X::g2)(x, 1, 2); + mem_fn(&X::g2)(rcx, 1, 2); + mem_fn(&X::g2)(&x, 1, 2); + mem_fn(&X::g2)(pcx, 1, 2); + mem_fn(&X::g2)(sp, 1, 2); + + mem_fn(&X::f3)(x, 1, 2, 3); + mem_fn(&X::f3)(&x, 1, 2, 3); + mem_fn(&X::f3)(sp, 1, 2, 3); + + mem_fn(&X::g3)(x, 1, 2, 3); + mem_fn(&X::g3)(rcx, 1, 2, 3); + mem_fn(&X::g3)(&x, 1, 2, 3); + mem_fn(&X::g3)(pcx, 1, 2, 3); + mem_fn(&X::g3)(sp, 1, 2, 3); + + mem_fn(&X::f4)(x, 1, 2, 3, 4); + mem_fn(&X::f4)(&x, 1, 2, 3, 4); + mem_fn(&X::f4)(sp, 1, 2, 3, 4); + + mem_fn(&X::g4)(x, 1, 2, 3, 4); + mem_fn(&X::g4)(rcx, 1, 2, 3, 4); + mem_fn(&X::g4)(&x, 1, 2, 3, 4); + mem_fn(&X::g4)(pcx, 1, 2, 3, 4); + mem_fn(&X::g4)(sp, 1, 2, 3, 4); + + mem_fn(&X::f5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::g5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + return detect_errors(mem_fn(&X::hash)(x) == 17610 && mem_fn(&X::hash)(sp) == 2155); +} diff --git a/src/boost/libs/bind/test/mem_fn_dm_test.cpp b/src/boost/libs/bind/test/mem_fn_dm_test.cpp new file mode 100644 index 00000000..88fe428d --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_dm_test.cpp @@ -0,0 +1,67 @@ +#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 + +// +// mem_fn_dm_test.cpp - data members +// +// Copyright (c) 2005 Peter Dimov +// +// 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/mem_fn.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; +}; + +int main() +{ + X x = { 0 }; + + boost::mem_fn( &X::m )( x ) = 401; + + BOOST_TEST( x.m == 401 ); + BOOST_TEST( boost::mem_fn( &X::m )( x ) == 401 ); + + boost::mem_fn( &X::m )( &x ) = 502; + + BOOST_TEST( x.m == 502 ); + BOOST_TEST( boost::mem_fn( &X::m )( &x ) == 502 ); + + X * px = &x; + + boost::mem_fn( &X::m )( px ) = 603; + + BOOST_TEST( x.m == 603 ); + BOOST_TEST( boost::mem_fn( &X::m )( px ) == 603 ); + + X const & cx = x; + X const * pcx = &x; + + BOOST_TEST( boost::mem_fn( &X::m )( cx ) == 603 ); + BOOST_TEST( boost::mem_fn( &X::m )( pcx ) == 603 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/mem_fn_eq_test.cpp b/src/boost/libs/bind/test/mem_fn_eq_test.cpp new file mode 100644 index 00000000..544d6ff4 --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_eq_test.cpp @@ -0,0 +1,300 @@ +#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 + +// +// mem_fn_eq_test.cpp - boost::mem_fn equality operator +// +// Copyright (c) 2004 Peter Dimov +// +// 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/mem_fn.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 dm_1; + int dm_2; + + // 0 + + int mf0_1() { return 0; } + int mf0_2() { return 1; } + + int cmf0_1() const { return 0; } + int cmf0_2() const { return 1; } + + void mf0v_1() {} + void mf0v_2() { static int x; ++x; } + + void cmf0v_1() const {} + void cmf0v_2() const { static int x; ++x; } + + // 1 + + int mf1_1(int) { return 0; } + int mf1_2(int) { return 1; } + + int cmf1_1(int) const { return 0; } + int cmf1_2(int) const { return 1; } + + void mf1v_1(int) {} + void mf1v_2(int) { static int x; ++x; } + + void cmf1v_1(int) const {} + void cmf1v_2(int) const { static int x; ++x; } + + // 2 + + int mf2_1(int, int) { return 0; } + int mf2_2(int, int) { return 1; } + + int cmf2_1(int, int) const { return 0; } + int cmf2_2(int, int) const { return 1; } + + void mf2v_1(int, int) {} + void mf2v_2(int, int) { static int x; ++x; } + + void cmf2v_1(int, int) const {} + void cmf2v_2(int, int) const { static int x; ++x; } + + // 3 + + int mf3_1(int, int, int) { return 0; } + int mf3_2(int, int, int) { return 1; } + + int cmf3_1(int, int, int) const { return 0; } + int cmf3_2(int, int, int) const { return 1; } + + void mf3v_1(int, int, int) {} + void mf3v_2(int, int, int) { static int x; ++x; } + + void cmf3v_1(int, int, int) const {} + void cmf3v_2(int, int, int) const { static int x; ++x; } + + // 4 + + int mf4_1(int, int, int, int) { return 0; } + int mf4_2(int, int, int, int) { return 1; } + + int cmf4_1(int, int, int, int) const { return 0; } + int cmf4_2(int, int, int, int) const { return 1; } + + void mf4v_1(int, int, int, int) {} + void mf4v_2(int, int, int, int) { static int x; ++x; } + + void cmf4v_1(int, int, int, int) const {} + void cmf4v_2(int, int, int, int) const { static int x; ++x; } + + // 5 + + int mf5_1(int, int, int, int, int) { return 0; } + int mf5_2(int, int, int, int, int) { return 1; } + + int cmf5_1(int, int, int, int, int) const { return 0; } + int cmf5_2(int, int, int, int, int) const { return 1; } + + void mf5v_1(int, int, int, int, int) {} + void mf5v_2(int, int, int, int, int) { static int x; ++x; } + + void cmf5v_1(int, int, int, int, int) const {} + void cmf5v_2(int, int, int, int, int) const { static int x; ++x; } + + // 6 + + int mf6_1(int, int, int, int, int, int) { return 0; } + int mf6_2(int, int, int, int, int, int) { return 1; } + + int cmf6_1(int, int, int, int, int, int) const { return 0; } + int cmf6_2(int, int, int, int, int, int) const { return 1; } + + void mf6v_1(int, int, int, int, int, int) {} + void mf6v_2(int, int, int, int, int, int) { static int x; ++x; } + + void cmf6v_1(int, int, int, int, int, int) const {} + void cmf6v_2(int, int, int, int, int, int) const { static int x; ++x; } + + // 7 + + int mf7_1(int, int, int, int, int, int, int) { return 0; } + int mf7_2(int, int, int, int, int, int, int) { return 1; } + + int cmf7_1(int, int, int, int, int, int, int) const { return 0; } + int cmf7_2(int, int, int, int, int, int, int) const { return 1; } + + void mf7v_1(int, int, int, int, int, int, int) {} + void mf7v_2(int, int, int, int, int, int, int) { static int x; ++x; } + + void cmf7v_1(int, int, int, int, int, int, int) const {} + void cmf7v_2(int, int, int, int, int, int, int) const { static int x; ++x; } + + // 8 + + int mf8_1(int, int, int, int, int, int, int, int) { return 0; } + int mf8_2(int, int, int, int, int, int, int, int) { return 1; } + + int cmf8_1(int, int, int, int, int, int, int, int) const { return 0; } + int cmf8_2(int, int, int, int, int, int, int, int) const { return 1; } + + void mf8v_1(int, int, int, int, int, int, int, int) {} + void mf8v_2(int, int, int, int, int, int, int, int) { static int x; ++x; } + + void cmf8v_1(int, int, int, int, int, int, int, int) const {} + void cmf8v_2(int, int, int, int, int, int, int, int) const { static int x; ++x; } + +}; + +int main() +{ + BOOST_TEST( boost::mem_fn(&X::dm_1) == boost::mem_fn(&X::dm_1) ); + BOOST_TEST( boost::mem_fn(&X::dm_1) != boost::mem_fn(&X::dm_2) ); + + // 0 + + BOOST_TEST( boost::mem_fn(&X::mf0_1) == boost::mem_fn(&X::mf0_1) ); + BOOST_TEST( boost::mem_fn(&X::mf0_1) != boost::mem_fn(&X::mf0_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf0_1) == boost::mem_fn(&X::cmf0_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf0_1) != boost::mem_fn(&X::cmf0_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf0v_1) == boost::mem_fn(&X::mf0v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf0v_1) != boost::mem_fn(&X::mf0v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf0v_1) == boost::mem_fn(&X::cmf0v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf0v_1) != boost::mem_fn(&X::cmf0v_2) ); + + // 1 + + BOOST_TEST( boost::mem_fn(&X::mf1_1) == boost::mem_fn(&X::mf1_1) ); + BOOST_TEST( boost::mem_fn(&X::mf1_1) != boost::mem_fn(&X::mf1_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf1_1) == boost::mem_fn(&X::cmf1_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf1_1) != boost::mem_fn(&X::cmf1_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf1v_1) == boost::mem_fn(&X::mf1v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf1v_1) != boost::mem_fn(&X::mf1v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf1v_1) == boost::mem_fn(&X::cmf1v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf1v_1) != boost::mem_fn(&X::cmf1v_2) ); + + // 2 + + BOOST_TEST( boost::mem_fn(&X::mf2_1) == boost::mem_fn(&X::mf2_1) ); + BOOST_TEST( boost::mem_fn(&X::mf2_1) != boost::mem_fn(&X::mf2_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf2_1) == boost::mem_fn(&X::cmf2_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf2_1) != boost::mem_fn(&X::cmf2_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf2v_1) == boost::mem_fn(&X::mf2v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf2v_1) != boost::mem_fn(&X::mf2v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf2v_1) == boost::mem_fn(&X::cmf2v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf2v_1) != boost::mem_fn(&X::cmf2v_2) ); + + // 3 + + BOOST_TEST( boost::mem_fn(&X::mf3_1) == boost::mem_fn(&X::mf3_1) ); + BOOST_TEST( boost::mem_fn(&X::mf3_1) != boost::mem_fn(&X::mf3_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf3_1) == boost::mem_fn(&X::cmf3_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf3_1) != boost::mem_fn(&X::cmf3_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf3v_1) == boost::mem_fn(&X::mf3v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf3v_1) != boost::mem_fn(&X::mf3v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf3v_1) == boost::mem_fn(&X::cmf3v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf3v_1) != boost::mem_fn(&X::cmf3v_2) ); + + // 4 + + BOOST_TEST( boost::mem_fn(&X::mf4_1) == boost::mem_fn(&X::mf4_1) ); + BOOST_TEST( boost::mem_fn(&X::mf4_1) != boost::mem_fn(&X::mf4_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf4_1) == boost::mem_fn(&X::cmf4_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf4_1) != boost::mem_fn(&X::cmf4_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf4v_1) == boost::mem_fn(&X::mf4v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf4v_1) != boost::mem_fn(&X::mf4v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf4v_1) == boost::mem_fn(&X::cmf4v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf4v_1) != boost::mem_fn(&X::cmf4v_2) ); + + // 5 + + BOOST_TEST( boost::mem_fn(&X::mf5_1) == boost::mem_fn(&X::mf5_1) ); + BOOST_TEST( boost::mem_fn(&X::mf5_1) != boost::mem_fn(&X::mf5_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf5_1) == boost::mem_fn(&X::cmf5_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf5_1) != boost::mem_fn(&X::cmf5_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf5v_1) == boost::mem_fn(&X::mf5v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf5v_1) != boost::mem_fn(&X::mf5v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf5v_1) == boost::mem_fn(&X::cmf5v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf5v_1) != boost::mem_fn(&X::cmf5v_2) ); + + // 6 + + BOOST_TEST( boost::mem_fn(&X::mf6_1) == boost::mem_fn(&X::mf6_1) ); + BOOST_TEST( boost::mem_fn(&X::mf6_1) != boost::mem_fn(&X::mf6_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf6_1) == boost::mem_fn(&X::cmf6_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf6_1) != boost::mem_fn(&X::cmf6_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf6v_1) == boost::mem_fn(&X::mf6v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf6v_1) != boost::mem_fn(&X::mf6v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf6v_1) == boost::mem_fn(&X::cmf6v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf6v_1) != boost::mem_fn(&X::cmf6v_2) ); + + // 7 + + BOOST_TEST( boost::mem_fn(&X::mf7_1) == boost::mem_fn(&X::mf7_1) ); + BOOST_TEST( boost::mem_fn(&X::mf7_1) != boost::mem_fn(&X::mf7_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf7_1) == boost::mem_fn(&X::cmf7_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf7_1) != boost::mem_fn(&X::cmf7_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf7v_1) == boost::mem_fn(&X::mf7v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf7v_1) != boost::mem_fn(&X::mf7v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf7v_1) == boost::mem_fn(&X::cmf7v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf7v_1) != boost::mem_fn(&X::cmf7v_2) ); + + // 8 + + BOOST_TEST( boost::mem_fn(&X::mf8_1) == boost::mem_fn(&X::mf8_1) ); + BOOST_TEST( boost::mem_fn(&X::mf8_1) != boost::mem_fn(&X::mf8_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf8_1) == boost::mem_fn(&X::cmf8_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf8_1) != boost::mem_fn(&X::cmf8_2) ); + + BOOST_TEST( boost::mem_fn(&X::mf8v_1) == boost::mem_fn(&X::mf8v_1) ); + BOOST_TEST( boost::mem_fn(&X::mf8v_1) != boost::mem_fn(&X::mf8v_2) ); + + BOOST_TEST( boost::mem_fn(&X::cmf8v_1) == boost::mem_fn(&X::cmf8v_1) ); + BOOST_TEST( boost::mem_fn(&X::cmf8v_1) != boost::mem_fn(&X::cmf8v_2) ); + + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/mem_fn_fastcall_test.cpp b/src/boost/libs/bind/test/mem_fn_fastcall_test.cpp new file mode 100644 index 00000000..b7a6ab30 --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_fastcall_test.cpp @@ -0,0 +1,196 @@ +#include <boost/config.hpp> + +#ifndef BOOST_MSVC + +int main() +{ +} + +#else + +#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 + +// +// mem_fn_fastcall_test.cpp - a test for mem_fn.hpp + __fastcall +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#define BOOST_MEM_FN_ENABLE_FASTCALL + +#include <boost/mem_fn.hpp> +#include <boost/shared_ptr.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 + + +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); } +}; + +int detect_errors(bool x) +{ + if(x) + { + std::cerr << "no errors detected.\n"; + return 0; + } + else + { + std::cerr << "test failed.\n"; + return 1; + } +} + +int main() +{ + using boost::mem_fn; + + X x; + + X const & rcx = x; + X const * pcx = &x; + + boost::shared_ptr<X> sp(new X); + + mem_fn(&X::f0)(x); + mem_fn(&X::f0)(&x); + mem_fn(&X::f0)(sp); + + mem_fn(&X::g0)(x); + mem_fn(&X::g0)(rcx); + mem_fn(&X::g0)(&x); + mem_fn(&X::g0)(pcx); + mem_fn(&X::g0)(sp); + + mem_fn(&X::f1)(x, 1); + mem_fn(&X::f1)(&x, 1); + mem_fn(&X::f1)(sp, 1); + + mem_fn(&X::g1)(x, 1); + mem_fn(&X::g1)(rcx, 1); + mem_fn(&X::g1)(&x, 1); + mem_fn(&X::g1)(pcx, 1); + mem_fn(&X::g1)(sp, 1); + + mem_fn(&X::f2)(x, 1, 2); + mem_fn(&X::f2)(&x, 1, 2); + mem_fn(&X::f2)(sp, 1, 2); + + mem_fn(&X::g2)(x, 1, 2); + mem_fn(&X::g2)(rcx, 1, 2); + mem_fn(&X::g2)(&x, 1, 2); + mem_fn(&X::g2)(pcx, 1, 2); + mem_fn(&X::g2)(sp, 1, 2); + + mem_fn(&X::f3)(x, 1, 2, 3); + mem_fn(&X::f3)(&x, 1, 2, 3); + mem_fn(&X::f3)(sp, 1, 2, 3); + + mem_fn(&X::g3)(x, 1, 2, 3); + mem_fn(&X::g3)(rcx, 1, 2, 3); + mem_fn(&X::g3)(&x, 1, 2, 3); + mem_fn(&X::g3)(pcx, 1, 2, 3); + mem_fn(&X::g3)(sp, 1, 2, 3); + + mem_fn(&X::f4)(x, 1, 2, 3, 4); + mem_fn(&X::f4)(&x, 1, 2, 3, 4); + mem_fn(&X::f4)(sp, 1, 2, 3, 4); + + mem_fn(&X::g4)(x, 1, 2, 3, 4); + mem_fn(&X::g4)(rcx, 1, 2, 3, 4); + mem_fn(&X::g4)(&x, 1, 2, 3, 4); + mem_fn(&X::g4)(pcx, 1, 2, 3, 4); + mem_fn(&X::g4)(sp, 1, 2, 3, 4); + + mem_fn(&X::f5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::g5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + return detect_errors(x.hash == 17610 && sp->hash == 2155); +} + +#endif diff --git a/src/boost/libs/bind/test/mem_fn_ref_test.cpp b/src/boost/libs/bind/test/mem_fn_ref_test.cpp new file mode 100644 index 00000000..be989414 --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_ref_test.cpp @@ -0,0 +1,36 @@ +// +// mem_fn_ref_test.cpp - reference_wrapper +// +// Copyright (c) 2009 Peter Dimov +// +// 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/mem_fn.hpp> +#include <boost/ref.hpp> +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int f() + { + return 1; + } + + int g() const + { + return 2; + } +}; + +int main() +{ + X x; + + BOOST_TEST( boost::mem_fn( &X::f )( boost::ref( x ) ) == 1 ); + BOOST_TEST( boost::mem_fn( &X::g )( boost::cref( x ) ) == 2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/mem_fn_rv_test.cpp b/src/boost/libs/bind/test/mem_fn_rv_test.cpp new file mode 100644 index 00000000..4147105f --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_rv_test.cpp @@ -0,0 +1,117 @@ +#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 + +// +// mem_fn_test.cpp - mem_fn.hpp with rvalues +// +// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2005 Peter Dimov +// +// 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/mem_fn.hpp> +#include <boost/shared_ptr.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 + +unsigned int hash = 0; + +struct X +{ + 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; } +}; + +int detect_errors(bool x) +{ + if( x ) + { + std::cerr << "no errors detected.\n"; + return 0; + } + else + { + std::cerr << "test failed.\n"; + return 1; + } +} + +boost::shared_ptr<X> make() +{ + return boost::shared_ptr<X>( new X ); +} + +int main() +{ + using boost::mem_fn; + + mem_fn(&X::f0)( make() ); + mem_fn(&X::g0)( make() ); + + mem_fn(&X::f1)( make(), 1 ); + mem_fn(&X::g1)( make(), 1 ); + + mem_fn(&X::f2)( make(), 1, 2 ); + mem_fn(&X::g2)( make(), 1, 2 ); + + mem_fn(&X::f3)( make(), 1, 2, 3 ); + mem_fn(&X::g3)( make(), 1, 2, 3 ); + + mem_fn(&X::f4)( make(), 1, 2, 3, 4 ); + mem_fn(&X::g4)( make(), 1, 2, 3, 4 ); + + mem_fn(&X::f5)( make(), 1, 2, 3, 4, 5 ); + mem_fn(&X::g5)( make(), 1, 2, 3, 4, 5 ); + + mem_fn(&X::f6)( make(), 1, 2, 3, 4, 5, 6 ); + mem_fn(&X::g6)( make(), 1, 2, 3, 4, 5, 6 ); + + mem_fn(&X::f7)( make(), 1, 2, 3, 4, 5, 6, 7 ); + mem_fn(&X::g7)( make(), 1, 2, 3, 4, 5, 6, 7 ); + + mem_fn(&X::f8)( make(), 1, 2, 3, 4, 5, 6, 7, 8 ); + mem_fn(&X::g8)( make(), 1, 2, 3, 4, 5, 6, 7, 8 ); + + return detect_errors( hash == 2155 ); +} diff --git a/src/boost/libs/bind/test/mem_fn_stdcall_test.cpp b/src/boost/libs/bind/test/mem_fn_stdcall_test.cpp new file mode 100644 index 00000000..7f5645f3 --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_stdcall_test.cpp @@ -0,0 +1,196 @@ +#include <boost/config.hpp> + +#ifndef BOOST_MSVC + +int main() +{ +} + +#else + +#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 + +// +// mem_fn_stdcall_test.cpp - a test for mem_fn.hpp + __stdcall +// +// Copyright (c) 2001 Peter Dimov and Multi Media Ltd. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#define BOOST_MEM_FN_ENABLE_STDCALL + +#include <boost/mem_fn.hpp> +#include <boost/shared_ptr.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 + + +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; } +}; + +int detect_errors(bool x) +{ + if(x) + { + std::cerr << "no errors detected.\n"; + return 0; + } + else + { + std::cerr << "test failed.\n"; + return 1; + } +} + +int main() +{ + using boost::mem_fn; + + X x; + + X const & rcx = x; + X const * pcx = &x; + + boost::shared_ptr<X> sp(new X); + + mem_fn(&X::f0)(x); + mem_fn(&X::f0)(&x); + mem_fn(&X::f0)(sp); + + mem_fn(&X::g0)(x); + mem_fn(&X::g0)(rcx); + mem_fn(&X::g0)(&x); + mem_fn(&X::g0)(pcx); + mem_fn(&X::g0)(sp); + + mem_fn(&X::f1)(x, 1); + mem_fn(&X::f1)(&x, 1); + mem_fn(&X::f1)(sp, 1); + + mem_fn(&X::g1)(x, 1); + mem_fn(&X::g1)(rcx, 1); + mem_fn(&X::g1)(&x, 1); + mem_fn(&X::g1)(pcx, 1); + mem_fn(&X::g1)(sp, 1); + + mem_fn(&X::f2)(x, 1, 2); + mem_fn(&X::f2)(&x, 1, 2); + mem_fn(&X::f2)(sp, 1, 2); + + mem_fn(&X::g2)(x, 1, 2); + mem_fn(&X::g2)(rcx, 1, 2); + mem_fn(&X::g2)(&x, 1, 2); + mem_fn(&X::g2)(pcx, 1, 2); + mem_fn(&X::g2)(sp, 1, 2); + + mem_fn(&X::f3)(x, 1, 2, 3); + mem_fn(&X::f3)(&x, 1, 2, 3); + mem_fn(&X::f3)(sp, 1, 2, 3); + + mem_fn(&X::g3)(x, 1, 2, 3); + mem_fn(&X::g3)(rcx, 1, 2, 3); + mem_fn(&X::g3)(&x, 1, 2, 3); + mem_fn(&X::g3)(pcx, 1, 2, 3); + mem_fn(&X::g3)(sp, 1, 2, 3); + + mem_fn(&X::f4)(x, 1, 2, 3, 4); + mem_fn(&X::f4)(&x, 1, 2, 3, 4); + mem_fn(&X::f4)(sp, 1, 2, 3, 4); + + mem_fn(&X::g4)(x, 1, 2, 3, 4); + mem_fn(&X::g4)(rcx, 1, 2, 3, 4); + mem_fn(&X::g4)(&x, 1, 2, 3, 4); + mem_fn(&X::g4)(pcx, 1, 2, 3, 4); + mem_fn(&X::g4)(sp, 1, 2, 3, 4); + + mem_fn(&X::f5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::g5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + return detect_errors(x.hash == 17610 && sp->hash == 2155); +} + +#endif diff --git a/src/boost/libs/bind/test/mem_fn_test.cpp b/src/boost/libs/bind/test/mem_fn_test.cpp new file mode 100644 index 00000000..960a8286 --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_test.cpp @@ -0,0 +1,184 @@ +#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 + +// +// mem_fn_test.cpp - a test for mem_fn.hpp +// +// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// +// 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/mem_fn.hpp> +#include <boost/shared_ptr.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 + + +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; } +}; + +int detect_errors(bool x) +{ + if(x) + { + std::cerr << "no errors detected.\n"; + return 0; + } + else + { + std::cerr << "test failed.\n"; + return 1; + } +} + +int main() +{ + using boost::mem_fn; + + X x; + + X const & rcx = x; + X const * pcx = &x; + + boost::shared_ptr<X> sp(new X); + + mem_fn(&X::f0)(x); + mem_fn(&X::f0)(&x); + mem_fn(&X::f0)(sp); + + mem_fn(&X::g0)(x); + mem_fn(&X::g0)(rcx); + mem_fn(&X::g0)(&x); + mem_fn(&X::g0)(pcx); + mem_fn(&X::g0)(sp); + + mem_fn(&X::f1)(x, 1); + mem_fn(&X::f1)(&x, 1); + mem_fn(&X::f1)(sp, 1); + + mem_fn(&X::g1)(x, 1); + mem_fn(&X::g1)(rcx, 1); + mem_fn(&X::g1)(&x, 1); + mem_fn(&X::g1)(pcx, 1); + mem_fn(&X::g1)(sp, 1); + + mem_fn(&X::f2)(x, 1, 2); + mem_fn(&X::f2)(&x, 1, 2); + mem_fn(&X::f2)(sp, 1, 2); + + mem_fn(&X::g2)(x, 1, 2); + mem_fn(&X::g2)(rcx, 1, 2); + mem_fn(&X::g2)(&x, 1, 2); + mem_fn(&X::g2)(pcx, 1, 2); + mem_fn(&X::g2)(sp, 1, 2); + + mem_fn(&X::f3)(x, 1, 2, 3); + mem_fn(&X::f3)(&x, 1, 2, 3); + mem_fn(&X::f3)(sp, 1, 2, 3); + + mem_fn(&X::g3)(x, 1, 2, 3); + mem_fn(&X::g3)(rcx, 1, 2, 3); + mem_fn(&X::g3)(&x, 1, 2, 3); + mem_fn(&X::g3)(pcx, 1, 2, 3); + mem_fn(&X::g3)(sp, 1, 2, 3); + + mem_fn(&X::f4)(x, 1, 2, 3, 4); + mem_fn(&X::f4)(&x, 1, 2, 3, 4); + mem_fn(&X::f4)(sp, 1, 2, 3, 4); + + mem_fn(&X::g4)(x, 1, 2, 3, 4); + mem_fn(&X::g4)(rcx, 1, 2, 3, 4); + mem_fn(&X::g4)(&x, 1, 2, 3, 4); + mem_fn(&X::g4)(pcx, 1, 2, 3, 4); + mem_fn(&X::g4)(sp, 1, 2, 3, 4); + + mem_fn(&X::f5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::g5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + return detect_errors(mem_fn(&X::hash)(x) == 17610 && mem_fn(&X::hash)(sp) == 2155); +} diff --git a/src/boost/libs/bind/test/mem_fn_unary_addr_test.cpp b/src/boost/libs/bind/test/mem_fn_unary_addr_test.cpp new file mode 100644 index 00000000..61e9160f --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_unary_addr_test.cpp @@ -0,0 +1,151 @@ +#include <boost/config.hpp> +#include <boost/detail/workaround.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 + +// +// mem_fn_unary_addr_test.cpp - poisoned operator& test +// +// Copyright (c) 2009 Peter Dimov +// +// 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/mem_fn.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 + +unsigned int hash = 0; + +struct X +{ + 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; } +}; + +template<class T> class Y +{ +private: + + T * pt_; + + void operator& (); + void operator& () const; + +public: + + explicit Y( T * pt ): pt_( pt ) + { + } + + T * get() const + { + return pt_; + } +}; + +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) ) +namespace boost +{ +#endif + +template<class T> T * get_pointer( Y< T > const & y ) +{ + return y.get(); +} + +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) ) +} // namespace boost +#endif + +int detect_errors(bool x) +{ + if( x ) + { + std::cerr << "no errors detected.\n"; + return 0; + } + else + { + std::cerr << "test failed.\n"; + return 1; + } +} + +int main() +{ + using boost::mem_fn; + + X x; + + Y<X> px( &x ); + Y<X const> pcx( &x ); + + mem_fn(&X::f0)( px ); + mem_fn(&X::g0)( pcx ); + + mem_fn(&X::f1)( px, 1 ); + mem_fn(&X::g1)( pcx, 1 ); + + mem_fn(&X::f2)( px, 1, 2 ); + mem_fn(&X::g2)( pcx, 1, 2 ); + + mem_fn(&X::f3)( px, 1, 2, 3 ); + mem_fn(&X::g3)( pcx, 1, 2, 3 ); + + mem_fn(&X::f4)( px, 1, 2, 3, 4 ); + mem_fn(&X::g4)( pcx, 1, 2, 3, 4 ); + + mem_fn(&X::f5)( px, 1, 2, 3, 4, 5 ); + mem_fn(&X::g5)( pcx, 1, 2, 3, 4, 5 ); + + mem_fn(&X::f6)( px, 1, 2, 3, 4, 5, 6 ); + mem_fn(&X::g6)( pcx, 1, 2, 3, 4, 5, 6 ); + + mem_fn(&X::f7)( px, 1, 2, 3, 4, 5, 6, 7 ); + mem_fn(&X::g7)( pcx, 1, 2, 3, 4, 5, 6, 7 ); + + mem_fn(&X::f8)( px, 1, 2, 3, 4, 5, 6, 7, 8 ); + mem_fn(&X::g8)( pcx, 1, 2, 3, 4, 5, 6, 7, 8 ); + + return detect_errors( hash == 2155 ); +} diff --git a/src/boost/libs/bind/test/mem_fn_void_test.cpp b/src/boost/libs/bind/test/mem_fn_void_test.cpp new file mode 100644 index 00000000..9f52ccf8 --- /dev/null +++ b/src/boost/libs/bind/test/mem_fn_void_test.cpp @@ -0,0 +1,184 @@ +#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 + +// +// mem_fn_void_test.cpp - a test for mem_fn.hpp + void returns +// +// Copyright (c) 2001 Peter Dimov and Multi Media Ltd. +// +// 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/mem_fn.hpp> +#include <boost/shared_ptr.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 + + +struct X +{ + mutable unsigned int hash; + + X(): 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); } +}; + +int detect_errors(bool x) +{ + if(x) + { + std::cerr << "no errors detected.\n"; + return 0; + } + else + { + std::cerr << "test failed.\n"; + return 1; + } +} + +int main() +{ + using boost::mem_fn; + + X x; + + X const & rcx = x; + X const * pcx = &x; + + boost::shared_ptr<X> sp(new X); + + mem_fn(&X::f0)(x); + mem_fn(&X::f0)(&x); + mem_fn(&X::f0)(sp); + + mem_fn(&X::g0)(x); + mem_fn(&X::g0)(rcx); + mem_fn(&X::g0)(&x); + mem_fn(&X::g0)(pcx); + mem_fn(&X::g0)(sp); + + mem_fn(&X::f1)(x, 1); + mem_fn(&X::f1)(&x, 1); + mem_fn(&X::f1)(sp, 1); + + mem_fn(&X::g1)(x, 1); + mem_fn(&X::g1)(rcx, 1); + mem_fn(&X::g1)(&x, 1); + mem_fn(&X::g1)(pcx, 1); + mem_fn(&X::g1)(sp, 1); + + mem_fn(&X::f2)(x, 1, 2); + mem_fn(&X::f2)(&x, 1, 2); + mem_fn(&X::f2)(sp, 1, 2); + + mem_fn(&X::g2)(x, 1, 2); + mem_fn(&X::g2)(rcx, 1, 2); + mem_fn(&X::g2)(&x, 1, 2); + mem_fn(&X::g2)(pcx, 1, 2); + mem_fn(&X::g2)(sp, 1, 2); + + mem_fn(&X::f3)(x, 1, 2, 3); + mem_fn(&X::f3)(&x, 1, 2, 3); + mem_fn(&X::f3)(sp, 1, 2, 3); + + mem_fn(&X::g3)(x, 1, 2, 3); + mem_fn(&X::g3)(rcx, 1, 2, 3); + mem_fn(&X::g3)(&x, 1, 2, 3); + mem_fn(&X::g3)(pcx, 1, 2, 3); + mem_fn(&X::g3)(sp, 1, 2, 3); + + mem_fn(&X::f4)(x, 1, 2, 3, 4); + mem_fn(&X::f4)(&x, 1, 2, 3, 4); + mem_fn(&X::f4)(sp, 1, 2, 3, 4); + + mem_fn(&X::g4)(x, 1, 2, 3, 4); + mem_fn(&X::g4)(rcx, 1, 2, 3, 4); + mem_fn(&X::g4)(&x, 1, 2, 3, 4); + mem_fn(&X::g4)(pcx, 1, 2, 3, 4); + mem_fn(&X::g4)(sp, 1, 2, 3, 4); + + mem_fn(&X::f5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::g5)(x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5); + mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5); + + mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6); + mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6); + + mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7); + mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7); + + mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8); + mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8); + + return detect_errors(x.hash == 17610 && sp->hash == 2155); +} diff --git a/src/boost/libs/bind/test/placeholder_const_ref_test.cpp b/src/boost/libs/bind/test/placeholder_const_ref_test.cpp new file mode 100644 index 00000000..f0835b00 --- /dev/null +++ b/src/boost/libs/bind/test/placeholder_const_ref_test.cpp @@ -0,0 +1,37 @@ +// +// placeholder_const_ref_test.cpp - forming a const& to _1 +// +// Copyright 2015 Peter Dimov +// +// 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/placeholders.hpp> +#include <boost/is_placeholder.hpp> +#include <boost/core/lightweight_test.hpp> + +// + +template<class T> void test( T const &, int i ) +{ + BOOST_TEST_EQ( boost::is_placeholder<T>::value, i ); +} + +int main() +{ + using namespace boost::placeholders; + + test( _1, 1 ); + test( _2, 2 ); + test( _3, 3 ); + test( _4, 4 ); + test( _5, 5 ); + test( _6, 6 ); + test( _7, 7 ); + test( _8, 8 ); + test( _9, 9 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/placeholder_std_bind_test.cpp b/src/boost/libs/bind/test/placeholder_std_bind_test.cpp new file mode 100644 index 00000000..3034b8e0 --- /dev/null +++ b/src/boost/libs/bind/test/placeholder_std_bind_test.cpp @@ -0,0 +1,46 @@ +// +// placeholder_std_bind_test.cpp - std::bind with Boost's _1 +// +// Copyright 2016 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// + +#include <boost/config.hpp> + +#if defined( BOOST_NO_CXX11_HDR_FUNCTIONAL ) + +int main() +{ +} + +#else + +#include <boost/bind.hpp> +#include <boost/core/lightweight_test.hpp> +#include <functional> + +namespace std +{ + +template<int N> struct is_placeholder< boost::arg<N> >: public integral_constant<int, N> {}; + +} // namespace std + +int foo( int i ) +{ + return i; +} + +int main() +{ + BOOST_TEST_EQ( std::bind( foo, _1 )( 1 ), 1 ); + BOOST_TEST_EQ( std::bind( foo, _2 )( 1, 2 ), 2 ); + BOOST_TEST_EQ( std::bind( foo, _3 )( 1, 2, 3 ), 3 ); + + return boost::report_errors(); +} + +#endif diff --git a/src/boost/libs/bind/test/protect_test.cpp b/src/boost/libs/bind/test/protect_test.cpp new file mode 100644 index 00000000..0da7d517 --- /dev/null +++ b/src/boost/libs/bind/test/protect_test.cpp @@ -0,0 +1,281 @@ +// protect_test.cpp +// +// Copyright (c) 2009 Steven Watanabe +// +// 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/protect.hpp> +#include <boost/bind.hpp> + +#include <boost/detail/lightweight_test.hpp> + +int f(int x) +{ + return x; +} + +int& g(int& x) +{ + return x; +} + +template<class T> +const T& constify(const T& arg) +{ + return arg; +} + +int main() +{ + int i[9] = {0,1,2,3,4,5,6,7,8}; + + // non-const + + // test nullary + BOOST_TEST(boost::protect(boost::bind(f, 1))() == 1); + + // test lvalues + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0]) == &i[0]); + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1]) == &i[0]); + BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1]) == &i[1]); + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2]) == &i[0]); + BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2]) == &i[1]); + BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2]) == &i[2]); + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3]) == &i[0]); + BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3]) == &i[1]); + BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3]) == &i[2]); + BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3]) == &i[3]); + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4]) == &i[0]); + BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4]) == &i[1]); + BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4]) == &i[2]); + BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4]) == &i[3]); + BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4]) == &i[4]); + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[0]); + BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[1]); + BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[2]); + BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[3]); + BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[4]); + BOOST_TEST(&boost::protect(boost::bind(g, _6))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[5]); + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[0]); + BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[1]); + BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[2]); + BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[3]); + BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[4]); + BOOST_TEST(&boost::protect(boost::bind(g, _6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[5]); + BOOST_TEST(&boost::protect(boost::bind(g, _7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[6]); + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[0]); + BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[1]); + BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[2]); + BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[3]); + BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[4]); + BOOST_TEST(&boost::protect(boost::bind(g, _6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[5]); + BOOST_TEST(&boost::protect(boost::bind(g, _7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[6]); + BOOST_TEST(&boost::protect(boost::bind(g, _8))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[7]); + + BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[0]); + BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[1]); + BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[2]); + BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[3]); + BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[4]); + BOOST_TEST(&boost::protect(boost::bind(g, _6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[5]); + BOOST_TEST(&boost::protect(boost::bind(g, _7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[6]); + BOOST_TEST(&boost::protect(boost::bind(g, _8))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[7]); + BOOST_TEST(&boost::protect(boost::bind(g, _9))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[8]); + + // test rvalues + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0) == 0); + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1) == 1); + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2) == 1); + BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2) == 2); + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3) == 1); + BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3) == 2); + BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3) == 3); + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4) == 1); + BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4) == 2); + BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4) == 3); + BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4) == 4); + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4, 5) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4, 5) == 1); + BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4, 5) == 2); + BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4, 5) == 3); + BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4, 5) == 4); + BOOST_TEST(boost::protect(boost::bind(f, _6))(0, 1, 2, 3, 4, 5) == 5); + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4, 5, 6) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4, 5, 6) == 1); + BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4, 5, 6) == 2); + BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4, 5, 6) == 3); + BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4, 5, 6) == 4); + BOOST_TEST(boost::protect(boost::bind(f, _6))(0, 1, 2, 3, 4, 5, 6) == 5); + BOOST_TEST(boost::protect(boost::bind(f, _7))(0, 1, 2, 3, 4, 5, 6) == 6); + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4, 5, 6, 7) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4, 5, 6, 7) == 1); + BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4, 5, 6, 7) == 2); + BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4, 5, 6, 7) == 3); + BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4, 5, 6, 7) == 4); + BOOST_TEST(boost::protect(boost::bind(f, _6))(0, 1, 2, 3, 4, 5, 6, 7) == 5); + BOOST_TEST(boost::protect(boost::bind(f, _7))(0, 1, 2, 3, 4, 5, 6, 7) == 6); + BOOST_TEST(boost::protect(boost::bind(f, _8))(0, 1, 2, 3, 4, 5, 6, 7) == 7); + + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 1); + BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 2); + BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 3); + BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 4); + BOOST_TEST(boost::protect(boost::bind(f, _6))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 5); + BOOST_TEST(boost::protect(boost::bind(f, _7))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 6); + BOOST_TEST(boost::protect(boost::bind(f, _8))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 7); + BOOST_TEST(boost::protect(boost::bind(f, _9))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 8); + + // test mixed perfect forwarding + BOOST_TEST(boost::protect(boost::bind(f, _1))(i[0], 1) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(i[0], 1) == 1); + BOOST_TEST(boost::protect(boost::bind(f, _1))(0, i[1]) == 0); + BOOST_TEST(boost::protect(boost::bind(f, _2))(0, i[1]) == 1); + + // const + + // test nullary + BOOST_TEST(constify(constify(boost::protect(boost::bind(f, 1))))() == 1); + + // test lvalues + BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _1))))(i[0]) == &i[0]); + + BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _1))))(i[0], i[1]) == &i[0]); + BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _2))))(i[0], i[1]) == &i[1]); + + BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _1))))(i[0], i[1], i[2]) == &i[0]); + BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _2))))(i[0], i[1], i[2]) == &i[1]); + BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _3))))(i[0], i[1], i[2]) == &i[2]); + + BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3]) == &i[0]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3]) == &i[1]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3]) == &i[2]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3]) == &i[3]); + + BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4]) == &i[0]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4]) == &i[1]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4]) == &i[2]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4]) == &i[3]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4]) == &i[4]); + + BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[0]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[1]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[2]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[3]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[4]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _6)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[5]); + + BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[0]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[1]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[2]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[3]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[4]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[5]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[6]); + + BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[0]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[1]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[2]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[3]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[4]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[5]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[6]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _8)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[7]); + + BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[0]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[1]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[2]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[3]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[4]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[5]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[6]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _8)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[7]); + BOOST_TEST(&constify(boost::protect(boost::bind(g, _9)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[8]); + + // test rvalues + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0) == 0); + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1) == 1); + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2) == 1); + BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2) == 2); + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3) == 1); + BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3) == 2); + BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3) == 3); + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4) == 1); + BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4) == 2); + BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4) == 3); + BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4) == 4); + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4, 5) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4, 5) == 1); + BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4, 5) == 2); + BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4, 5) == 3); + BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4, 5) == 4); + BOOST_TEST(constify(boost::protect(boost::bind(f, _6)))(0, 1, 2, 3, 4, 5) == 5); + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4, 5, 6) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4, 5, 6) == 1); + BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4, 5, 6) == 2); + BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4, 5, 6) == 3); + BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4, 5, 6) == 4); + BOOST_TEST(constify(boost::protect(boost::bind(f, _6)))(0, 1, 2, 3, 4, 5, 6) == 5); + BOOST_TEST(constify(boost::protect(boost::bind(f, _7)))(0, 1, 2, 3, 4, 5, 6) == 6); + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4, 5, 6, 7) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4, 5, 6, 7) == 1); + BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4, 5, 6, 7) == 2); + BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4, 5, 6, 7) == 3); + BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4, 5, 6, 7) == 4); + BOOST_TEST(constify(boost::protect(boost::bind(f, _6)))(0, 1, 2, 3, 4, 5, 6, 7) == 5); + BOOST_TEST(constify(boost::protect(boost::bind(f, _7)))(0, 1, 2, 3, 4, 5, 6, 7) == 6); + BOOST_TEST(constify(boost::protect(boost::bind(f, _8)))(0, 1, 2, 3, 4, 5, 6, 7) == 7); + + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 1); + BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 2); + BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 3); + BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 4); + BOOST_TEST(constify(boost::protect(boost::bind(f, _6)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 5); + BOOST_TEST(constify(boost::protect(boost::bind(f, _7)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 6); + BOOST_TEST(constify(boost::protect(boost::bind(f, _8)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 7); + BOOST_TEST(constify(boost::protect(boost::bind(f, _9)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 8); + + // test mixed perfect forwarding + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(i[0], 1) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(i[0], 1) == 1); + BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, i[1]) == 0); + BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, i[1]) == 1); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/quick.cpp b/src/boost/libs/bind/test/quick.cpp new file mode 100644 index 00000000..9aa215c6 --- /dev/null +++ b/src/boost/libs/bind/test/quick.cpp @@ -0,0 +1,27 @@ +// +// quick.cpp - a quick test for boost/bind.hpp +// +// Copyright 2017 Peter Dimov +// +// 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/core/lightweight_test.hpp> + +int f( int a, int b, int c ) +{ + return a + 10 * b + 100 * c; +} + +int main() +{ + int const i = 1; + + BOOST_TEST_EQ( boost::bind( f, _1, 2, 3 )( i ), 321 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/bind/test/ref_fn_test.cpp b/src/boost/libs/bind/test/ref_fn_test.cpp new file mode 100644 index 00000000..aec54e82 --- /dev/null +++ b/src/boost/libs/bind/test/ref_fn_test.cpp @@ -0,0 +1,81 @@ +#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 + +// ref_fn_test.cpp: ref( f ) +// +// Copyright (c) 2008 Peter Dimov +// +// 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/ref.hpp> +#include <boost/detail/lightweight_test.hpp> + + +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) +{ +} + +#define BOOST_TEST_REF( f ) BOOST_TEST( &boost::ref( f ).get() == &f ) + +int main() +{ + int v = 0; + BOOST_TEST_REF( v ); + + BOOST_TEST_REF( f0 ); + BOOST_TEST_REF( f1 ); + BOOST_TEST_REF( f2 ); + BOOST_TEST_REF( f3 ); + BOOST_TEST_REF( f4 ); + BOOST_TEST_REF( f5 ); + BOOST_TEST_REF( f6 ); + BOOST_TEST_REF( f7 ); + BOOST_TEST_REF( f8 ); + BOOST_TEST_REF( f9 ); + + return boost::report_errors(); +} |