Skip to content

Commit

Permalink
Merge branch 'develop' into feature/requires-cxx11
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Jan 4, 2024
2 parents e391ef6 + 74308ee commit 6a73daa
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ run apply_test.cpp ;
run apply_test2.cpp ;
run apply_rv_test.cpp ;
run apply_rv_test2.cpp ;
run bind_over_test.cpp ;
run bind_over_mf_test.cpp ;
run bind_over_mf2_test.cpp ;
run mem_fn_cdecl_ref_test.cpp ;
run mem_fn_stdcall_ref_test.cpp ;
run mem_fn_fastcall_ref_test.cpp ;
93 changes: 93 additions & 0 deletions test/bind_over_mf2_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// bind_over_mf2_test.cpp - overloaded member functions, type<> syntax
//
// Copyright 2017, 2024 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/bind.hpp>
#include <boost/type.hpp>
#include <boost/core/lightweight_test.hpp>

//

struct X
{
int f() { return 17041; }
int f( int x1 ) { return x1; }
int f( int x1, int x2 ) { return x1+x2; }
int f( int x1, int x2, int x3 ) { return x1+x2+x3; }
int f( int x1, int x2, int x3, int x4 ) { return x1+x2+x3+x4; }
int f( int x1, int x2, int x3, int x4, int x5 ) { return x1+x2+x3+x4+x5; }
int f( int x1, int x2, int x3, int x4, int x5, int x6 ) { return x1+x2+x3+x4+x5+x6; }
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7 ) { return x1+x2+x3+x4+x5+x6+x7; }
int f( 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 f( 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 g() const { return 17041; }
int g( int x1 ) const { return x1; }
int g( int x1, int x2 ) const { return x1+x2; }
int g( int x1, int x2, int x3 ) const { return x1+x2+x3; }
int g( int x1, int x2, int x3, int x4 ) const { return x1+x2+x3+x4; }
int g( int x1, int x2, int x3, int x4, int x5 ) const { return x1+x2+x3+x4+x5; }
int g( int x1, int x2, int x3, int x4, int x5, int x6 ) const { return x1+x2+x3+x4+x5+x6; }
int g( int x1, int x2, int x3, int x4, int x5, int x6, int x7 ) const { return x1+x2+x3+x4+x5+x6+x7; }
int g( 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 g( 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; }
};

void overloaded_member_function_test()
{
X x;

BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x )(), 17041 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );

BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x )(), 17041 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );

X const* pcx = &x;

BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx )(), 17041 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );

BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx )(), 17041 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
}

int main()
{
overloaded_member_function_test();
return boost::report_errors();
}
112 changes: 112 additions & 0 deletions test/bind_over_mf_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
//
// bind_over_mf_test.cpp - overloaded member functions
//
// Copyright 2017, 2024 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/bind.hpp>
#include <boost/core/lightweight_test.hpp>

//

struct X
{
int f() { return 17041; }
int f( int x1 ) { return x1; }
int f( int x1, int x2 ) { return x1+x2; }
int f( int x1, int x2, int x3 ) { return x1+x2+x3; }
int f( int x1, int x2, int x3, int x4 ) { return x1+x2+x3+x4; }
int f( int x1, int x2, int x3, int x4, int x5 ) { return x1+x2+x3+x4+x5; }
int f( int x1, int x2, int x3, int x4, int x5, int x6 ) { return x1+x2+x3+x4+x5+x6; }
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7 ) { return x1+x2+x3+x4+x5+x6+x7; }
int f( 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 f( 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 g() const { return 17041; }
int g( int x1 ) const { return x1; }
int g( int x1, int x2 ) const { return x1+x2; }
int g( int x1, int x2, int x3 ) const { return x1+x2+x3; }
int g( int x1, int x2, int x3, int x4 ) const { return x1+x2+x3+x4; }
int g( int x1, int x2, int x3, int x4, int x5 ) const { return x1+x2+x3+x4+x5; }
int g( int x1, int x2, int x3, int x4, int x5, int x6 ) const { return x1+x2+x3+x4+x5+x6; }
int g( int x1, int x2, int x3, int x4, int x5, int x6, int x7 ) const { return x1+x2+x3+x4+x5+x6+x7; }
int g( 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 g( 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; }
};

void overloaded_member_function_test()
{
X x;

BOOST_TEST_EQ( boost::bind( &X::f, &x )(), 17041 );
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );

BOOST_TEST_EQ( boost::bind<int>( &X::f, &x )(), 17041 );
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );

BOOST_TEST_EQ( boost::bind<long>( &X::f, &x )(), 17041 );
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );

X const* pcx = &x;

BOOST_TEST_EQ( boost::bind( &X::g, pcx )(), 17041 );
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );

BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx )(), 17041 );
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );

BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx )(), 17041 );
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
}

int main()
{
overloaded_member_function_test();
return boost::report_errors();
}
86 changes: 86 additions & 0 deletions test/bind_over_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// bind_over_test.cpp - overloaded functions
//
// Copyright 2017, 2024 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/bind.hpp>
#include <boost/core/lightweight_test.hpp>

using namespace boost::placeholders;

//

int f()
{
return 17041;
}

int f( int x1 )
{
return x1;
}

int f( int x1, int x2 )
{
return x1+x2;
}

int f( int x1, int x2, int x3 )
{
return x1+x2+x3;
}

int f( int x1, int x2, int x3, int x4 )
{
return x1+x2+x3+x4;
}

int f( int x1, int x2, int x3, int x4, int x5 )
{
return x1+x2+x3+x4+x5;
}

int f( int x1, int x2, int x3, int x4, int x5, int x6 )
{
return x1+x2+x3+x4+x5+x6;
}

int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7 )
{
return x1+x2+x3+x4+x5+x6+x7;
}

int f( 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 f( 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;
}

void overloaded_function_test()
{
BOOST_TEST_EQ( boost::bind( f )(), 17041 );
BOOST_TEST_EQ( boost::bind( f, 1 )(), 1 );
BOOST_TEST_EQ( boost::bind( f, 1, 2 )(), 1+2 );
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3 )(), 1+2+3 );
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4 )(), 1+2+3+4 );
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(), 1+2+3+4+5+6+7+8+9 );
}

int main()
{
overloaded_function_test();
return boost::report_errors();
}

0 comments on commit 6a73daa

Please sign in to comment.