forked from boostorg/bind
Compare commits
156 Commits
boost-1.25
...
boost-1.34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b09a8d43f5 | ||
|
|
9ea5cf40da | ||
|
|
4d1f7d0411 | ||
|
|
967e9af0eb | ||
|
|
c5396f02c6 | ||
|
|
e8646fa260 | ||
|
|
a87638486b | ||
|
|
472f9e6ebe | ||
|
|
d43950f1a6 | ||
|
|
f57cb48b9f | ||
|
|
03bb04bb85 | ||
|
|
bba3d96bda | ||
|
|
cb2cca146f | ||
|
|
3304c00da3 | ||
|
|
3e980f8c34 | ||
|
|
42efa96a2f | ||
|
|
d90c96a7e4 | ||
|
|
d28a5cc23a | ||
|
|
98daeb3ad5 | ||
|
|
35b98458a1 | ||
|
|
2d6ccb09a7 | ||
|
|
a9deb8c577 | ||
|
|
840b39144c | ||
|
|
e5a60bfe1c | ||
|
|
5fbb6558ec | ||
|
|
3b89e4215b | ||
|
|
efc36ff07b | ||
|
|
b85adc3a58 | ||
|
|
0c96dbe3f1 | ||
|
|
2a21f7df2c | ||
|
|
9cfe194f80 | ||
|
|
66ed4fc9e1 | ||
|
|
23b64e1358 | ||
|
|
0aa407e77d | ||
|
|
27d1cf539b | ||
|
|
c7710aad38 | ||
|
|
4a1c4894c7 | ||
|
|
9f0a516068 | ||
|
|
6602068638 | ||
|
|
c25b216898 | ||
|
|
ed817c5b15 | ||
|
|
7b9a97a758 | ||
|
|
b1f05e7268 | ||
|
|
28cb8f8206 | ||
|
|
ccd0394b86 | ||
|
|
ee5ab38a63 | ||
|
|
35a2d208d5 | ||
|
|
424480e55b | ||
|
|
094d43c6e8 | ||
|
|
f01e59b682 | ||
|
|
9ffd0a08c5 | ||
|
|
4e287df40c | ||
|
|
5c53d7db2a | ||
|
|
0904a14c1a | ||
|
|
4377e763a5 | ||
|
|
cc984fad42 | ||
|
|
53c2e449d1 | ||
|
|
74fae199f6 | ||
|
|
4a41a09d27 | ||
|
|
2244135e86 | ||
|
|
807bbfd434 | ||
|
|
6fbbcd0d3c | ||
|
|
21f1171900 | ||
|
|
f8f4029628 | ||
|
|
dbf6e0cf4b | ||
|
|
8f1bb7f13f | ||
|
|
6601553820 | ||
|
|
b6a90777c8 | ||
|
|
ea8c0ef25e | ||
|
|
f91de70d8e | ||
|
|
4b97a70f64 | ||
|
|
7feefb7313 | ||
|
|
46ae046f41 | ||
|
|
673d6b0bf0 | ||
|
|
9ca672c10d | ||
|
|
016a3b8d96 | ||
|
|
6ed01de60f | ||
|
|
5f95e4d9de | ||
|
|
90069948ec | ||
|
|
367728cafe | ||
|
|
4be201beba | ||
|
|
04a438f5f4 | ||
|
|
b06f6a6d89 | ||
|
|
81c8af90ec | ||
|
|
c9db3c51ea | ||
|
|
8c09072ead | ||
|
|
4876b82a73 | ||
|
|
7b7784d470 | ||
|
|
eca328b27c | ||
|
|
ad46d513d7 | ||
|
|
cc3ebc18b8 | ||
|
|
5a10daef4d | ||
|
|
51e4031aaf | ||
|
|
55dbef0000 | ||
|
|
b63a6a5d99 | ||
|
|
52cc55329b | ||
|
|
5db80e9a33 | ||
|
|
3cbc321fa5 | ||
|
|
2f97add842 | ||
|
|
5345f14829 | ||
|
|
0053801ad2 | ||
|
|
ad043d1fff | ||
|
|
35ee2f3a52 | ||
|
|
5b1528f3f4 | ||
|
|
2277238db7 | ||
|
|
bdde6cd8b2 | ||
|
|
b1bfd36270 | ||
|
|
8a2ad8ca78 | ||
|
|
5bae1b9ad1 | ||
|
|
620c803fc1 | ||
|
|
6fb6b475db | ||
|
|
1dbea266a1 | ||
|
|
b482c43928 | ||
|
|
9ca2e6f064 | ||
|
|
8ec63f5ca5 | ||
|
|
866866c1df | ||
|
|
3179474c0e | ||
|
|
60a844927f | ||
|
|
27c104f1fb | ||
|
|
235feb0f62 | ||
|
|
b2b06ea204 | ||
|
|
d276e73ea0 | ||
|
|
70ec61e649 | ||
|
|
f37044ee57 | ||
|
|
9d389aa1e3 | ||
|
|
fc433254dc | ||
|
|
886d8b3079 | ||
|
|
b90421d2cd | ||
|
|
55f974d0b8 | ||
|
|
fe8a5204cc | ||
|
|
18f1b16872 | ||
|
|
e1b4cd5dcf | ||
|
|
00df4fc3bb | ||
|
|
389154b530 | ||
|
|
f6c95cf810 | ||
|
|
b19b0e4d66 | ||
|
|
16a07b2592 | ||
|
|
46a32f7547 | ||
|
|
f17fa79f2b | ||
|
|
9cd7fd58a1 | ||
|
|
5134310a5e | ||
|
|
463f513c23 | ||
|
|
ab0d3e94e1 | ||
|
|
4251ab4e83 | ||
|
|
e3bd44aa77 | ||
|
|
03dba9a279 | ||
|
|
7bdfb4acfc | ||
|
|
27a040d7ee | ||
|
|
223f7ef967 | ||
|
|
19d71a71f2 | ||
|
|
7776c66ffd | ||
|
|
b16c6a83dc | ||
|
|
0f75f57c30 | ||
|
|
277aa14329 | ||
|
|
c61d480cb6 | ||
|
|
b9bb33048f |
@@ -1,4 +1,6 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#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
|
||||
@@ -12,10 +14,9 @@
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// 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>
|
||||
|
||||
269
bind_test.cpp
269
bind_test.cpp
@@ -1,269 +0,0 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#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
|
||||
//
|
||||
// Version 1.00.0002 (2001-09-02)
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include <boost/test/test_tools.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;
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
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 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 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
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(&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 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 );
|
||||
}
|
||||
|
||||
int test_main(int, char * [])
|
||||
{
|
||||
function_test();
|
||||
function_object_test();
|
||||
member_function_test();
|
||||
nested_bind_test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
104
bind_test_1.cpp
104
bind_test_1.cpp
@@ -1,104 +0,0 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#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_1.cpp - tests bind.hpp with function pointers
|
||||
//
|
||||
// Version 1.00.0003 (2001-07-13)
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
unsigned long hash = 0;
|
||||
|
||||
template<class F> void test(F f)
|
||||
{
|
||||
int const i = 1;
|
||||
hash = (hash * 17041 + f(i)) % 32768;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
test(boost::bind(f_1, _1));
|
||||
test(boost::bind(f_2, _1, 2));
|
||||
test(boost::bind(f_3, _1, 2, 3));
|
||||
test(boost::bind(f_4, _1, 2, 3, 4));
|
||||
test(boost::bind(f_5, _1, 2, 3, 4, 5));
|
||||
test(boost::bind(f_6, _1, 2, 3, 4, 5, 6));
|
||||
test(boost::bind(f_7, _1, 2, 3, 4, 5, 6, 7));
|
||||
test(boost::bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8));
|
||||
test(boost::bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9));
|
||||
|
||||
return detect_errors(hash == 18797);
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#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_2.cpp - tests bind.hpp with function objects
|
||||
//
|
||||
// Version 1.00.0005 (2001-07-13)
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <iostream>
|
||||
|
||||
struct X
|
||||
{
|
||||
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; }
|
||||
};
|
||||
|
||||
unsigned long hash = 0;
|
||||
|
||||
template<class F> void test(F f, int const i)
|
||||
{
|
||||
hash = (hash * 17041 + f(i)) % 32768;
|
||||
}
|
||||
|
||||
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 namespace boost;
|
||||
|
||||
short i(6);
|
||||
|
||||
test(bind<short>(X(), ref(i)), 1);
|
||||
test(bind<short>(X(), ref(i)), 2);
|
||||
test(bind<int>(X(), i, _1), 3);
|
||||
test(bind<long>(X(), i, _1, 9), 4);
|
||||
|
||||
return detect_errors(hash == 24857);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#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
|
||||
@@ -6,56 +8,59 @@
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_test_4.cpp - tests bind.hpp with a visitor
|
||||
//
|
||||
// Version 1.00.0003 (2001-08-30)
|
||||
// bind_visitor.cpp - tests bind.hpp with a visitor
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// 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
|
||||
|
||||
// default implementation of visit_each
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template<class V, class T> void visit_each(V & v, T const & t, long)
|
||||
{
|
||||
v(t, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// visitor
|
||||
|
||||
int hash = 0;
|
||||
|
||||
struct ref_visitor
|
||||
struct visitor
|
||||
{
|
||||
template<class R, class F, class L> void operator()(boost::_bi::bind_t<R, F, L> const & b) const
|
||||
{
|
||||
b.accept(*this);
|
||||
}
|
||||
|
||||
template<class T> void operator()(boost::reference_wrapper<T> const & r) const
|
||||
template<class T> void operator()(boost::reference_wrapper<T> const & r, int) const
|
||||
{
|
||||
std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n";
|
||||
hash += r.get();
|
||||
}
|
||||
|
||||
#ifndef BOOST_MSVC
|
||||
|
||||
template<class T> void operator()(T const &) const
|
||||
template<class T> void operator()(T const &, long) const
|
||||
{
|
||||
std::cout << "Catch-all: " << typeid(T).name() << '\n';
|
||||
std::cout << "Value of type " << typeid(T).name() << '\n';
|
||||
++hash;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void operator()(...) const
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
int f(int & i, int & j)
|
||||
int f(int & i, int & j, int)
|
||||
{
|
||||
++i;
|
||||
--j;
|
||||
@@ -83,7 +88,8 @@ int main()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
ref_visitor()(bind<int>(bind(f, ref(x), _1), ref(y)));
|
||||
visitor v;
|
||||
visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
|
||||
|
||||
return detect_errors(hash == 9);
|
||||
return detect_errors(hash == 12);
|
||||
}
|
||||
240
doc/ref.xml
Normal file
240
doc/ref.xml
Normal file
@@ -0,0 +1,240 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<library name="Ref" dirname="ref" id="ref" last-revision="$Date$">
|
||||
<libraryinfo>
|
||||
<author>
|
||||
<firstname>Jaakko</firstname>
|
||||
<surname>Järvi</surname>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Peter</firstname>
|
||||
<surname>Dimov</surname>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Douglas</firstname>
|
||||
<surname>Gregor</surname>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Dave</firstname>
|
||||
<surname>Abrahams</surname>
|
||||
</author>
|
||||
|
||||
<copyright>
|
||||
<year>1999</year>
|
||||
<year>2000</year>
|
||||
<holder>Jaakko Järvi</holder>
|
||||
</copyright>
|
||||
|
||||
<copyright>
|
||||
<year>2001</year>
|
||||
<year>2002</year>
|
||||
<holder>Peter Dimov</holder>
|
||||
</copyright>
|
||||
|
||||
<copyright>
|
||||
<year>2002</year>
|
||||
<holder>David Abrahams</holder>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
<para>Subject to the Boost Software License, Version 1.0. See
|
||||
accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
|
||||
<ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>.
|
||||
</para>
|
||||
</legalnotice>
|
||||
|
||||
<librarypurpose>A utility library for passing references to generic functions</librarypurpose>
|
||||
<librarycategory name="category:higher-order"/>
|
||||
</libraryinfo>
|
||||
|
||||
<title>Boost.Ref</title>
|
||||
|
||||
<section id="ref.intro">
|
||||
<title>Introduction</title>
|
||||
|
||||
<using-namespace name="boost"/>
|
||||
|
||||
<para>The Ref library is a small library that is useful for passing
|
||||
references to function templates (algorithms) that would usually
|
||||
take copies of their arguments. It defines the class template
|
||||
<code><classname>boost::reference_wrapper<T></classname></code>,
|
||||
the two functions
|
||||
<code><functionname>boost::ref</functionname></code> and
|
||||
<code><functionname>boost::cref</functionname></code> that return
|
||||
instances of <code>boost::reference_wrapper<T></code>, and the
|
||||
two traits classes
|
||||
<code><classname>boost::is_reference_wrapper<T></classname></code>
|
||||
and
|
||||
<code><classname>boost::unwrap_reference<T></classname></code>.</para>
|
||||
|
||||
<para>The purpose of
|
||||
<code>boost::reference_wrapper<T></code> is to
|
||||
contain a reference to an object of type T. It is primarily used to
|
||||
"feed" references to function templates (algorithms) that take their
|
||||
parameter by value.</para>
|
||||
|
||||
<para>To support this usage,
|
||||
<code>boost::reference_wrapper<T></code> provides an implicit
|
||||
conversion to <code>T&</code>. This usually allows the function
|
||||
templates to work on references unmodified.</para>
|
||||
|
||||
<para><code>boost::reference_wrapper<T></code> is
|
||||
both CopyConstructible and Assignable (ordinary references are not
|
||||
Assignable).</para>
|
||||
|
||||
<para>The expression <code>boost::ref(x)</code>
|
||||
returns a
|
||||
<code>boost::reference_wrapper<X>(x)</code> where X
|
||||
is the type of x. Similarly,
|
||||
<code>boost::cref(x)</code> returns a
|
||||
<code>boost::reference_wrapper<X const>(x)</code>.</para>
|
||||
|
||||
<para>The expression
|
||||
<code>boost::is_reference_wrapper<T>::value</code>
|
||||
is true if T is a <code>reference_wrapper</code>, and
|
||||
false otherwise.</para>
|
||||
|
||||
<para>The type-expression
|
||||
<code>boost::unwrap_reference<T>::type</code> is T::type if T
|
||||
is a <code>reference_wrapper</code>, T otherwise.</para>
|
||||
</section>
|
||||
|
||||
<library-reference>
|
||||
<header name="boost/ref.hpp">
|
||||
<namespace name="boost">
|
||||
<class name="reference_wrapper">
|
||||
<template>
|
||||
<template-type-parameter name="T"/>
|
||||
</template>
|
||||
<purpose>
|
||||
Contains a reference to an object of type
|
||||
<computeroutput>T</computeroutput>.
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para><computeroutput><classname>reference_wrapper</classname></computeroutput>
|
||||
is primarily used to "feed" references to function templates
|
||||
(algorithms) that take their parameter by value. It provides
|
||||
an implicit conversion to
|
||||
<computeroutput>T&</computeroutput>, which usually allows
|
||||
the function templates to work on references
|
||||
unmodified.</para>
|
||||
</description>
|
||||
|
||||
<typedef name="type"><type>T</type></typedef>
|
||||
|
||||
<constructor specifiers="explicit">
|
||||
<parameter name="t">
|
||||
<paramtype>T&</paramtype>
|
||||
</parameter>
|
||||
|
||||
<effects><simpara>Constructs a
|
||||
<computeroutput><classname>reference_wrapper</classname></computeroutput>
|
||||
object that stores a reference to
|
||||
<computeroutput>t</computeroutput>.</simpara></effects>
|
||||
|
||||
<throws><simpara>Does not throw.</simpara></throws>
|
||||
</constructor>
|
||||
|
||||
<method-group name="access">
|
||||
<method name="conversion-operator" cv="const">
|
||||
<type>T&</type>
|
||||
<returns><simpara>The stored reference.</simpara></returns>
|
||||
<throws><simpara>Does not throw.</simpara></throws>
|
||||
</method>
|
||||
|
||||
<method name="get" cv="const">
|
||||
<type>T&</type>
|
||||
<returns><simpara>The stored reference.</simpara></returns>
|
||||
<throws><simpara>Does not throw.</simpara></throws>
|
||||
</method>
|
||||
|
||||
<method name="get_pointer" cv="const">
|
||||
<type>T*</type>
|
||||
<returns><simpara>A pointer to the object referenced by the stored reference.</simpara></returns>
|
||||
<throws><simpara>Does not throw.</simpara></throws>
|
||||
</method>
|
||||
</method-group>
|
||||
|
||||
<free-function-group name="constructors">
|
||||
<function name="ref">
|
||||
<type>reference_wrapper<T></type>
|
||||
<parameter name="t">
|
||||
<paramtype>T&</paramtype>
|
||||
</parameter>
|
||||
|
||||
<returns><simpara><computeroutput><classname>reference_wrapper</classname><T>(t)</computeroutput></simpara></returns>
|
||||
|
||||
<throws><simpara>Does not throw.</simpara></throws>
|
||||
</function>
|
||||
|
||||
<function name="cref">
|
||||
<type>reference_wrapper<T const></type>
|
||||
<parameter name="t">
|
||||
<paramtype>T const&</paramtype>
|
||||
</parameter>
|
||||
|
||||
<returns><simpara><computeroutput><classname>reference_wrapper</classname><T const>(t)</computeroutput></simpara></returns>
|
||||
|
||||
<throws><simpara>Does not throw.</simpara></throws>
|
||||
</function>
|
||||
</free-function-group>
|
||||
</class>
|
||||
|
||||
<class name="is_reference_wrapper">
|
||||
<template>
|
||||
<template-type-parameter name="T"/>
|
||||
</template>
|
||||
|
||||
<purpose>Determine if a type <computeroutput>T</computeroutput> is an instantiation of <computeroutput><classname>reference_wrapper</classname></computeroutput>.</purpose>
|
||||
|
||||
<description>
|
||||
<para>The <computeroutput>value</computeroutput> static
|
||||
constant will be <computeroutput>true</computeroutput> iff the
|
||||
type <computeroutput>T</computeroutput> is a specialization of
|
||||
<computeroutput><classname>reference_wrapper</classname></computeroutput>.</para>
|
||||
</description>
|
||||
|
||||
<static-constant name="value">
|
||||
<type>bool</type>
|
||||
<default><emphasis>unspecified</emphasis></default>
|
||||
</static-constant>
|
||||
</class>
|
||||
|
||||
<class name="unwrap_reference">
|
||||
<template>
|
||||
<template-type-parameter name="T"/>
|
||||
</template>
|
||||
|
||||
<purpose>Find the type in a <computeroutput><classname>reference_wrapper</classname></computeroutput>.</purpose>
|
||||
|
||||
<description>
|
||||
<para>The typedef <computeroutput>type</computeroutput> is
|
||||
<computeroutput>T::type</computeroutput> if
|
||||
<computeroutput>T</computeroutput> is a
|
||||
<computeroutput><classname>reference_wrapper</classname></computeroutput>,
|
||||
<computeroutput>T</computeroutput> otherwise.</para>
|
||||
</description>
|
||||
|
||||
<typedef name="type"><type><emphasis>unspecified</emphasis></type></typedef>
|
||||
</class>
|
||||
</namespace>
|
||||
</header>
|
||||
</library-reference>
|
||||
|
||||
<section id="ref.ack">
|
||||
<title>Acknowledgements</title>
|
||||
|
||||
<using-namespace name="boost"/>
|
||||
|
||||
<para><functionname>ref</functionname> and <functionname>cref</functionname>
|
||||
were originally part of the <libraryname>Tuple</libraryname> library
|
||||
by Jaakko Järvi. They were "promoted to boost:: status" by
|
||||
Peter Dimov because they are generally useful. Douglas Gregor and
|
||||
Dave Abrahams contributed
|
||||
<classname>is_reference_wrapper</classname> and
|
||||
<classname>unwrap_reference</classname>.</para>
|
||||
</section>
|
||||
|
||||
</library>
|
||||
File diff suppressed because it is too large
Load Diff
74
include/boost/bind/apply.hpp
Normal file
74
include/boost/bind/apply.hpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef BOOST_BIND_APPLY_HPP_INCLUDED
|
||||
#define BOOST_BIND_APPLY_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// apply.hpp
|
||||
//
|
||||
// Copyright (c) 2002, 2003 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)
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class R> struct apply
|
||||
{
|
||||
typedef R result_type;
|
||||
|
||||
template<class F> result_type operator()(F & f) const
|
||||
{
|
||||
return f();
|
||||
}
|
||||
|
||||
template<class F, class A1> result_type operator()(F & f, A1 & a1) const
|
||||
{
|
||||
return f(a1);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2> result_type operator()(F & f, A1 & a1, A2 & a2) const
|
||||
{
|
||||
return f(a1, a2);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3> result_type operator()(F & f, A1 & a1, A2 & a2, A3 & a3) const
|
||||
{
|
||||
return f(a1, a2, a3);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4> result_type operator()(F & f, A1 & a1, A2 & a2, A3 & a3, A4 & a4) const
|
||||
{
|
||||
return f(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5> result_type operator()(F & f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(F & f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(F & f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(F & f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(F & f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_APPLY_HPP_INCLUDED
|
||||
36
include/boost/bind/arg.hpp
Normal file
36
include/boost/bind/arg.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef BOOST_BIND_ARG_HPP_INCLUDED
|
||||
#define BOOST_BIND_ARG_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind/arg.hpp
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<int I> class arg
|
||||
{
|
||||
};
|
||||
|
||||
template<int I> bool operator==(arg<I> const &, arg<I> const &)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED
|
||||
117
include/boost/bind/bind_cc.hpp
Normal file
117
include/boost/bind/bind_cc.hpp
Normal file
@@ -0,0 +1,117 @@
|
||||
//
|
||||
// bind/bind_cc.hpp - support for different calling conventions
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
template<class R>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (), _bi::list0>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) ())
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) ();
|
||||
typedef _bi::list0 list_type;
|
||||
return _bi::bind_t<R, F, list_type> (f, list_type());
|
||||
}
|
||||
|
||||
template<class R, class B1, class A1>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1), typename _bi::list_av_1<A1>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1), A1 a1)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1);
|
||||
typedef typename _bi::list_av_1<A1>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type> (f, list_type(a1));
|
||||
}
|
||||
|
||||
template<class R, class B1, class B2, class A1, class A2>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2), typename _bi::list_av_2<A1, A2>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2), A1 a1, A2 a2)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2);
|
||||
typedef typename _bi::list_av_2<A1, A2>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3), typename _bi::list_av_3<A1, A2, A3>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3), A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3);
|
||||
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4), typename _bi::list_av_4<A1, A2, A3, A4>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4), A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4);
|
||||
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5), typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5);
|
||||
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6), typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6);
|
||||
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7), typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7);
|
||||
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7, B8), typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7, B8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7, B8);
|
||||
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8, class B9,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7, B8, B9), typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7, B8, B9), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7, B8, B9);
|
||||
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
227
include/boost/bind/bind_mf_cc.hpp
Normal file
227
include/boost/bind/bind_mf_cc.hpp
Normal file
@@ -0,0 +1,227 @@
|
||||
//
|
||||
// bind/bind_mf_cc.hpp - support for different calling conventions
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
// 0
|
||||
|
||||
template<class R, class T,
|
||||
class A1>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf0)<R, T>, typename _bi::list_av_1<A1>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (), A1 a1)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf0)<R, T> F;
|
||||
typedef typename _bi::list_av_1<A1>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class A1>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf0)<R, T>, typename _bi::list_av_1<A1>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) () const, A1 a1)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf0)<R, T> F;
|
||||
typedef typename _bi::list_av_1<A1>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1));
|
||||
}
|
||||
|
||||
// 1
|
||||
|
||||
template<class R, class T,
|
||||
class B1,
|
||||
class A1, class A2>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1), A1 a1, A2 a2)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf1)<R, T, B1> F;
|
||||
typedef typename _bi::list_av_2<A1, A2>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1,
|
||||
class A1, class A2>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1) const, A1 a1, A2 a2)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf1)<R, T, B1> F;
|
||||
typedef typename _bi::list_av_2<A1, A2>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2));
|
||||
}
|
||||
|
||||
// 2
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2), A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf2)<R, T, B1, B2> F;
|
||||
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2) const, A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf2)<R, T, B1, B2> F;
|
||||
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3));
|
||||
}
|
||||
|
||||
// 3
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf3)<R, T, B1, B2, B3>, typename _bi::list_av_4<A1, A2, A3, A4>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3), A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf3)<R, T, B1, B2, B3> F;
|
||||
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf3)<R, T, B1, B2, B3>, typename _bi::list_av_4<A1, A2, A3, A4>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) const, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf3)<R, T, B1, B2, B3> F;
|
||||
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4));
|
||||
}
|
||||
|
||||
// 4
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf4)<R, T, B1, B2, B3, B4>, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf4)<R, T, B1, B2, B3, B4> F;
|
||||
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf4)<R, T, B1, B2, B3, B4>, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf4)<R, T, B1, B2, B3, B4> F;
|
||||
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
|
||||
}
|
||||
|
||||
// 5
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf5)<R, T, B1, B2, B3, B4, B5>, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf5)<R, T, B1, B2, B3, B4, B5> F;
|
||||
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf5)<R, T, B1, B2, B3, B4, B5>, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf5)<R, T, B1, B2, B3, B4, B5> F;
|
||||
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
|
||||
// 6
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf6)<R, T, B1, B2, B3, B4, B5, B6>, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf6)<R, T, B1, B2, B3, B4, B5, B6> F;
|
||||
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf6)<R, T, B1, B2, B3, B4, B5, B6>, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf6)<R, T, B1, B2, B3, B4, B5, B6> F;
|
||||
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
|
||||
// 7
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf7)<R, T, B1, B2, B3, B4, B5, B6, B7>, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf7)<R, T, B1, B2, B3, B4, B5, B6, B7> F;
|
||||
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf7)<R, T, B1, B2, B3, B4, B5, B6, B7>, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf7)<R, T, B1, B2, B3, B4, B5, B6, B7> F;
|
||||
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
// 8
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8>, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8> F;
|
||||
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8>, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8> F;
|
||||
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
226
include/boost/bind/bind_template.hpp
Normal file
226
include/boost/bind/bind_template.hpp
Normal file
@@ -0,0 +1,226 @@
|
||||
//
|
||||
// bind/bind_template.hpp
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// Copyright (c) 2001-2004 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
typedef typename result_traits<R, F>::type result_type;
|
||||
|
||||
result_type operator()()
|
||||
{
|
||||
list0 a;
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
result_type operator()() const
|
||||
{
|
||||
list0 a;
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 & a1)
|
||||
{
|
||||
list1<A1 &> a(a1);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 & a1) const
|
||||
{
|
||||
list1<A1 &> a(a1);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
||||
|
||||
template<class A1> result_type operator()(A1 const & a1)
|
||||
{
|
||||
list1<A1 const &> a(a1);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 const & a1) const
|
||||
{
|
||||
list1<A1 const &> a(a1);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)
|
||||
{
|
||||
list2<A1 &, A2 &> a(a1, a2);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2) const
|
||||
{
|
||||
list2<A1 &, A2 &> a(a1, a2);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 & a2)
|
||||
{
|
||||
list2<A1 const &, A2 &> a(a1, a2);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 & a2) const
|
||||
{
|
||||
list2<A1 const &, A2 &> a(a1, a2);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 const & a2)
|
||||
{
|
||||
list2<A1 &, A2 const &> a(a1, a2);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 const & a2) const
|
||||
{
|
||||
list2<A1 &, A2 const &> a(a1, a2);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 const & a2)
|
||||
{
|
||||
list2<A1 const &, A2 const &> a(a1, a2);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 const & a2) const
|
||||
{
|
||||
list2<A1 const &, A2 const &> a(a1, a2);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3)
|
||||
{
|
||||
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3) const
|
||||
{
|
||||
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4)
|
||||
{
|
||||
list4<A1 &, A2 &, A3 &, A4 &> a(a1, a2, a3, a4);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4) const
|
||||
{
|
||||
list4<A1 &, A2 &, A3 &, A4 &> a(a1, a2, a3, a4);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5)
|
||||
{
|
||||
list5<A1 &, A2 &, A3 &, A4 &, A5 &> a(a1, a2, a3, a4, a5);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5) const
|
||||
{
|
||||
list5<A1 &, A2 &, A3 &, A4 &, A5 &> a(a1, a2, a3, a4, a5);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6)
|
||||
{
|
||||
list6<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &> a(a1, a2, a3, a4, a5, a6);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6) const
|
||||
{
|
||||
list6<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &> a(a1, a2, a3, a4, a5, a6);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7)
|
||||
{
|
||||
list7<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &> a(a1, a2, a3, a4, a5, a6, a7);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7) const
|
||||
{
|
||||
list7<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &> a(a1, a2, a3, a4, a5, a6, a7);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8)
|
||||
{
|
||||
list8<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &> a(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8) const
|
||||
{
|
||||
list8<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &> a(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9)
|
||||
{
|
||||
list9<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &, A9 &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9) const
|
||||
{
|
||||
list9<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &, A9 &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A> result_type eval(A & a)
|
||||
{
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class A> result_type eval(A & a) const
|
||||
{
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
#if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ )
|
||||
|
||||
using boost::visit_each;
|
||||
|
||||
#endif
|
||||
BOOST_BIND_VISIT_EACH(v, f_, 0);
|
||||
l_.accept(v);
|
||||
}
|
||||
|
||||
bool compare(this_type const & rhs) const
|
||||
{
|
||||
return ref_compare(f_, rhs.f_, 0) && l_ == rhs.l_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
L l_;
|
||||
187
include/boost/bind/make_adaptable.hpp
Normal file
187
include/boost/bind/make_adaptable.hpp
Normal file
@@ -0,0 +1,187 @@
|
||||
#ifndef BOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED
|
||||
#define BOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// make_adaptable.hpp
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
template<class R, class F> class af0
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
explicit af0(F f): f_(f)
|
||||
{
|
||||
}
|
||||
|
||||
result_type operator()()
|
||||
{
|
||||
return f_();
|
||||
}
|
||||
|
||||
result_type operator()() const
|
||||
{
|
||||
return f_();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
};
|
||||
|
||||
template<class R, class A1, class F> class af1
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
typedef A1 argument_type;
|
||||
typedef A1 arg1_type;
|
||||
|
||||
explicit af1(F f): f_(f)
|
||||
{
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1)
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1) const
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
};
|
||||
|
||||
template<class R, class A1, class A2, class F> class af2
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
typedef A1 first_argument_type;
|
||||
typedef A2 second_argument_type;
|
||||
typedef A1 arg1_type;
|
||||
typedef A2 arg2_type;
|
||||
|
||||
explicit af2(F f): f_(f)
|
||||
{
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2)
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2) const
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
};
|
||||
|
||||
template<class R, class A1, class A2, class A3, class F> class af3
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
typedef A1 arg1_type;
|
||||
typedef A2 arg2_type;
|
||||
typedef A3 arg3_type;
|
||||
|
||||
explicit af3(F f): f_(f)
|
||||
{
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
};
|
||||
|
||||
template<class R, class A1, class A2, class A3, class A4, class F> class af4
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
typedef A1 arg1_type;
|
||||
typedef A2 arg2_type;
|
||||
typedef A3 arg3_type;
|
||||
typedef A4 arg4_type;
|
||||
|
||||
explicit af4(F f): f_(f)
|
||||
{
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
};
|
||||
|
||||
} // namespace _bi
|
||||
|
||||
template<class R, class F> _bi::af0<R, F> make_adaptable(F f)
|
||||
{
|
||||
return _bi::af0<R, F>(f);
|
||||
}
|
||||
|
||||
template<class R, class A1, class F> _bi::af1<R, A1, F> make_adaptable(F f)
|
||||
{
|
||||
return _bi::af1<R, A1, F>(f);
|
||||
}
|
||||
|
||||
template<class R, class A1, class A2, class F> _bi::af2<R, A1, A2, F> make_adaptable(F f)
|
||||
{
|
||||
return _bi::af2<R, A1, A2, F>(f);
|
||||
}
|
||||
|
||||
template<class R, class A1, class A2, class A3, class F> _bi::af3<R, A1, A2, A3, F> make_adaptable(F f)
|
||||
{
|
||||
return _bi::af3<R, A1, A2, A3, F>(f);
|
||||
}
|
||||
|
||||
template<class R, class A1, class A2, class A3, class A4, class F> _bi::af4<R, A1, A2, A3, A4, F> make_adaptable(F f)
|
||||
{
|
||||
return _bi::af4<R, A1, A2, A3, A4, F>(f);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED
|
||||
103
include/boost/bind/mem_fn_cc.hpp
Normal file
103
include/boost/bind/mem_fn_cc.hpp
Normal file
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// bind/mem_fn_cc.hpp - support for different calling conventions
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
template<class R, class T> _mfi::BOOST_MEM_FN_NAME(mf0)<R, T> mem_fn(R (BOOST_MEM_FN_CC T::*f) ())
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf0)<R, T>(f);
|
||||
}
|
||||
|
||||
template<class R, class T> _mfi::BOOST_MEM_FN_NAME(cmf0)<R, T> mem_fn(R (BOOST_MEM_FN_CC T::*f) () const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf0)<R, T>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1> _mfi::BOOST_MEM_FN_NAME(mf1)<R, T, A1> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf1)<R, T, A1>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1> _mfi::BOOST_MEM_FN_NAME(cmf1)<R, T, A1> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf1)<R, T, A1>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2> _mfi::BOOST_MEM_FN_NAME(mf2)<R, T, A1, A2> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf2)<R, T, A1, A2>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2> _mfi::BOOST_MEM_FN_NAME(cmf2)<R, T, A1, A2> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf2)<R, T, A1, A2>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3> _mfi::BOOST_MEM_FN_NAME(mf3)<R, T, A1, A2, A3> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf3)<R, T, A1, A2, A3>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3> _mfi::BOOST_MEM_FN_NAME(cmf3)<R, T, A1, A2, A3> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf3)<R, T, A1, A2, A3>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4> _mfi::BOOST_MEM_FN_NAME(mf4)<R, T, A1, A2, A3, A4> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf4)<R, T, A1, A2, A3, A4>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4> _mfi::BOOST_MEM_FN_NAME(cmf4)<R, T, A1, A2, A3, A4> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf4)<R, T, A1, A2, A3, A4>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5> _mfi::BOOST_MEM_FN_NAME(mf5)<R, T, A1, A2, A3, A4, A5> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf5)<R, T, A1, A2, A3, A4, A5>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5> _mfi::BOOST_MEM_FN_NAME(cmf5)<R, T, A1, A2, A3, A4, A5> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf5)<R, T, A1, A2, A3, A4, A5>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> _mfi::BOOST_MEM_FN_NAME(mf6)<R, T, A1, A2, A3, A4, A5, A6> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf6)<R, T, A1, A2, A3, A4, A5, A6>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> _mfi::BOOST_MEM_FN_NAME(cmf6)<R, T, A1, A2, A3, A4, A5, A6> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf6)<R, T, A1, A2, A3, A4, A5, A6>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> _mfi::BOOST_MEM_FN_NAME(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> _mfi::BOOST_MEM_FN_NAME(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> _mfi::BOOST_MEM_FN_NAME(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7, A8))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> _mfi::BOOST_MEM_FN_NAME(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7, A8) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8>(f);
|
||||
}
|
||||
1020
include/boost/bind/mem_fn_template.hpp
Normal file
1020
include/boost/bind/mem_fn_template.hpp
Normal file
File diff suppressed because it is too large
Load Diff
130
include/boost/bind/mem_fn_vw.hpp
Normal file
130
include/boost/bind/mem_fn_vw.hpp
Normal file
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// bind/mem_fn_vw.hpp - void return helper wrappers
|
||||
//
|
||||
// Do not include this header directly
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
template<class R, class T> struct BOOST_MEM_FN_NAME(mf0): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf0)<R, T, R (BOOST_MEM_FN_CC T::*) ()>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) ();
|
||||
explicit BOOST_MEM_FN_NAME(mf0)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf0)<R, T, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T> struct BOOST_MEM_FN_NAME(cmf0): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf0)<R, T, R (BOOST_MEM_FN_CC T::*) () const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) () const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf0)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf0)<R, T, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1> struct BOOST_MEM_FN_NAME(mf1): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf1)<R, T, A1, R (BOOST_MEM_FN_CC T::*) (A1)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1);
|
||||
explicit BOOST_MEM_FN_NAME(mf1)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf1)<R, T, A1, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1> struct BOOST_MEM_FN_NAME(cmf1): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf1)<R, T, A1, R (BOOST_MEM_FN_CC T::*) (A1) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf1)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf1)<R, T, A1, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2> struct BOOST_MEM_FN_NAME(mf2): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf2)<R, T, A1, A2, R (BOOST_MEM_FN_CC T::*) (A1, A2)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2);
|
||||
explicit BOOST_MEM_FN_NAME(mf2)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf2)<R, T, A1, A2, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2> struct BOOST_MEM_FN_NAME(cmf2): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf2)<R, T, A1, A2, R (BOOST_MEM_FN_CC T::*) (A1, A2) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf2)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf2)<R, T, A1, A2, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3> struct BOOST_MEM_FN_NAME(mf3): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf3)<R, T, A1, A2, A3, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3);
|
||||
explicit BOOST_MEM_FN_NAME(mf3)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf3)<R, T, A1, A2, A3, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3> struct BOOST_MEM_FN_NAME(cmf3): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf3)<R, T, A1, A2, A3, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf3)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf3)<R, T, A1, A2, A3, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4> struct BOOST_MEM_FN_NAME(mf4): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf4)<R, T, A1, A2, A3, A4, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4);
|
||||
explicit BOOST_MEM_FN_NAME(mf4)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf4)<R, T, A1, A2, A3, A4, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4> struct BOOST_MEM_FN_NAME(cmf4): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf4)<R, T, A1, A2, A3, A4, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf4)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf4)<R, T, A1, A2, A3, A4, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5> struct BOOST_MEM_FN_NAME(mf5): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf5)<R, T, A1, A2, A3, A4, A5, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5);
|
||||
explicit BOOST_MEM_FN_NAME(mf5)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf5)<R, T, A1, A2, A3, A4, A5, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5> struct BOOST_MEM_FN_NAME(cmf5): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf5)<R, T, A1, A2, A3, A4, A5, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf5)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf5)<R, T, A1, A2, A3, A4, A5, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> struct BOOST_MEM_FN_NAME(mf6): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf6)<R, T, A1, A2, A3, A4, A5, A6, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6);
|
||||
explicit BOOST_MEM_FN_NAME(mf6)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf6)<R, T, A1, A2, A3, A4, A5, A6, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> struct BOOST_MEM_FN_NAME(cmf6): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf6)<R, T, A1, A2, A3, A4, A5, A6, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf6)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf6)<R, T, A1, A2, A3, A4, A5, A6, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct BOOST_MEM_FN_NAME(mf7): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7);
|
||||
explicit BOOST_MEM_FN_NAME(mf7)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct BOOST_MEM_FN_NAME(cmf7): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf7)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct BOOST_MEM_FN_NAME(mf8): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7, A8)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8);
|
||||
explicit BOOST_MEM_FN_NAME(mf8)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct BOOST_MEM_FN_NAME(cmf8): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7, A8) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf8)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, F>(f) {}
|
||||
};
|
||||
|
||||
68
include/boost/bind/placeholders.hpp
Normal file
68
include/boost/bind/placeholders.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
|
||||
#define BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind/placeholders.hpp - _N definitions
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/bind/arg.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
#if defined(__BORLANDC__) || defined(__GNUC__)
|
||||
|
||||
static inline boost::arg<1> _1() { return boost::arg<1>(); }
|
||||
static inline boost::arg<2> _2() { return boost::arg<2>(); }
|
||||
static inline boost::arg<3> _3() { return boost::arg<3>(); }
|
||||
static inline boost::arg<4> _4() { return boost::arg<4>(); }
|
||||
static inline boost::arg<5> _5() { return boost::arg<5>(); }
|
||||
static inline boost::arg<6> _6() { return boost::arg<6>(); }
|
||||
static inline boost::arg<7> _7() { return boost::arg<7>(); }
|
||||
static inline boost::arg<8> _8() { return boost::arg<8>(); }
|
||||
static inline boost::arg<9> _9() { return boost::arg<9>(); }
|
||||
|
||||
#elif defined(BOOST_MSVC) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031) || defined(__MWERKS__)
|
||||
|
||||
static boost::arg<1> _1;
|
||||
static boost::arg<2> _2;
|
||||
static boost::arg<3> _3;
|
||||
static boost::arg<4> _4;
|
||||
static boost::arg<5> _5;
|
||||
static boost::arg<6> _6;
|
||||
static boost::arg<7> _7;
|
||||
static boost::arg<8> _8;
|
||||
static boost::arg<9> _9;
|
||||
|
||||
#else
|
||||
|
||||
boost::arg<1> _1;
|
||||
boost::arg<2> _2;
|
||||
boost::arg<3> _3;
|
||||
boost::arg<4> _4;
|
||||
boost::arg<5> _5;
|
||||
boost::arg<6> _6;
|
||||
boost::arg<7> _7;
|
||||
boost::arg<8> _8;
|
||||
boost::arg<9> _9;
|
||||
|
||||
#endif
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
#endif // #ifndef BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
|
||||
144
include/boost/bind/protect.hpp
Normal file
144
include/boost/bind/protect.hpp
Normal file
@@ -0,0 +1,144 @@
|
||||
#ifndef BOOST_BIND_PROTECT_HPP_INCLUDED
|
||||
#define BOOST_BIND_PROTECT_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// protect.hpp
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
template<class F> class protected_bind_t
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename F::result_type result_type;
|
||||
|
||||
explicit protected_bind_t(F f): f_(f)
|
||||
{
|
||||
}
|
||||
|
||||
result_type operator()()
|
||||
{
|
||||
return f_();
|
||||
}
|
||||
|
||||
result_type operator()() const
|
||||
{
|
||||
return f_();
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 & a1)
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 & a1) const
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2) const
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3)
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3) const
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4)
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
};
|
||||
|
||||
} // namespace _bi
|
||||
|
||||
template<class F> _bi::protected_bind_t<F> protect(F f)
|
||||
{
|
||||
return _bi::protected_bind_t<F>(f);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_PROTECT_HPP_INCLUDED
|
||||
475
include/boost/bind/storage.hpp
Normal file
475
include/boost/bind/storage.hpp
Normal file
@@ -0,0 +1,475 @@
|
||||
#ifndef BOOST_BIND_STORAGE_HPP_INCLUDED
|
||||
#define BOOST_BIND_STORAGE_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind/storage.hpp
|
||||
//
|
||||
// boost/bind.hpp support header, optimized storage
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/bind/arg.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4512) // assignment operator could not be generated
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
// 1
|
||||
|
||||
template<class A1> struct storage1
|
||||
{
|
||||
explicit storage1( A1 a1 ): a1_( a1 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
BOOST_BIND_VISIT_EACH(v, a1_, 0);
|
||||
}
|
||||
|
||||
A1 a1_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( __BORLANDC__ )
|
||||
|
||||
template<int I> struct storage1< boost::arg<I> >
|
||||
{
|
||||
explicit storage1( boost::arg<I> ) {}
|
||||
|
||||
template<class V> void accept(V &) const { }
|
||||
|
||||
static boost::arg<I> a1_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<int I> struct storage1< boost::arg<I> (*) () >
|
||||
{
|
||||
explicit storage1( boost::arg<I> (*) () ) {}
|
||||
|
||||
template<class V> void accept(V &) const { }
|
||||
|
||||
static boost::arg<I> a1_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// 2
|
||||
|
||||
template<class A1, class A2> struct storage2: public storage1<A1>
|
||||
{
|
||||
typedef storage1<A1> inherited;
|
||||
|
||||
storage2( A1 a1, A2 a2 ): storage1<A1>( a1 ), a2_( a2 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
BOOST_BIND_VISIT_EACH(v, a2_, 0);
|
||||
}
|
||||
|
||||
A2 a2_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template<class A1, int I> struct storage2< A1, boost::arg<I> >: public storage1<A1>
|
||||
{
|
||||
typedef storage1<A1> inherited;
|
||||
|
||||
storage2( A1 a1, boost::arg<I> ): storage1<A1>( a1 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a2_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<class A1, int I> struct storage2< A1, boost::arg<I> (*) () >: public storage1<A1>
|
||||
{
|
||||
typedef storage1<A1> inherited;
|
||||
|
||||
storage2( A1 a1, boost::arg<I> (*) () ): storage1<A1>( a1 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a2_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// 3
|
||||
|
||||
template<class A1, class A2, class A3> struct storage3: public storage2< A1, A2 >
|
||||
{
|
||||
typedef storage2<A1, A2> inherited;
|
||||
|
||||
storage3( A1 a1, A2 a2, A3 a3 ): storage2<A1, A2>( a1, a2 ), a3_( a3 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
BOOST_BIND_VISIT_EACH(v, a3_, 0);
|
||||
}
|
||||
|
||||
A3 a3_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template<class A1, class A2, int I> struct storage3< A1, A2, boost::arg<I> >: public storage2< A1, A2 >
|
||||
{
|
||||
typedef storage2<A1, A2> inherited;
|
||||
|
||||
storage3( A1 a1, A2 a2, boost::arg<I> ): storage2<A1, A2>( a1, a2 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a3_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<class A1, class A2, int I> struct storage3< A1, A2, boost::arg<I> (*) () >: public storage2< A1, A2 >
|
||||
{
|
||||
typedef storage2<A1, A2> inherited;
|
||||
|
||||
storage3( A1 a1, A2 a2, boost::arg<I> (*) () ): storage2<A1, A2>( a1, a2 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a3_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// 4
|
||||
|
||||
template<class A1, class A2, class A3, class A4> struct storage4: public storage3< A1, A2, A3 >
|
||||
{
|
||||
typedef storage3<A1, A2, A3> inherited;
|
||||
|
||||
storage4( A1 a1, A2 a2, A3 a3, A4 a4 ): storage3<A1, A2, A3>( a1, a2, a3 ), a4_( a4 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
BOOST_BIND_VISIT_EACH(v, a4_, 0);
|
||||
}
|
||||
|
||||
A4 a4_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template<class A1, class A2, class A3, int I> struct storage4< A1, A2, A3, boost::arg<I> >: public storage3< A1, A2, A3 >
|
||||
{
|
||||
typedef storage3<A1, A2, A3> inherited;
|
||||
|
||||
storage4( A1 a1, A2 a2, A3 a3, boost::arg<I> ): storage3<A1, A2, A3>( a1, a2, a3 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a4_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<class A1, class A2, class A3, int I> struct storage4< A1, A2, A3, boost::arg<I> (*) () >: public storage3< A1, A2, A3 >
|
||||
{
|
||||
typedef storage3<A1, A2, A3> inherited;
|
||||
|
||||
storage4( A1 a1, A2 a2, A3 a3, boost::arg<I> (*) () ): storage3<A1, A2, A3>( a1, a2, a3 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a4_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// 5
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> struct storage5: public storage4< A1, A2, A3, A4 >
|
||||
{
|
||||
typedef storage4<A1, A2, A3, A4> inherited;
|
||||
|
||||
storage5( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ), a5_( a5 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
BOOST_BIND_VISIT_EACH(v, a5_, 0);
|
||||
}
|
||||
|
||||
A5 a5_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template<class A1, class A2, class A3, class A4, int I> struct storage5< A1, A2, A3, A4, boost::arg<I> >: public storage4< A1, A2, A3, A4 >
|
||||
{
|
||||
typedef storage4<A1, A2, A3, A4> inherited;
|
||||
|
||||
storage5( A1 a1, A2 a2, A3 a3, A4 a4, boost::arg<I> ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a5_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<class A1, class A2, class A3, class A4, int I> struct storage5< A1, A2, A3, A4, boost::arg<I> (*) () >: public storage4< A1, A2, A3, A4 >
|
||||
{
|
||||
typedef storage4<A1, A2, A3, A4> inherited;
|
||||
|
||||
storage5( A1 a1, A2 a2, A3 a3, A4 a4, boost::arg<I> (*) () ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a5_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// 6
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> struct storage6: public storage5< A1, A2, A3, A4, A5 >
|
||||
{
|
||||
typedef storage5<A1, A2, A3, A4, A5> inherited;
|
||||
|
||||
storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ), a6_( a6 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
BOOST_BIND_VISIT_EACH(v, a6_, 0);
|
||||
}
|
||||
|
||||
A6 a6_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, int I> struct storage6< A1, A2, A3, A4, A5, boost::arg<I> >: public storage5< A1, A2, A3, A4, A5 >
|
||||
{
|
||||
typedef storage5<A1, A2, A3, A4, A5> inherited;
|
||||
|
||||
storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, boost::arg<I> ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a6_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, int I> struct storage6< A1, A2, A3, A4, A5, boost::arg<I> (*) () >: public storage5< A1, A2, A3, A4, A5 >
|
||||
{
|
||||
typedef storage5<A1, A2, A3, A4, A5> inherited;
|
||||
|
||||
storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, boost::arg<I> (*) () ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a6_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// 7
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct storage7: public storage6< A1, A2, A3, A4, A5, A6 >
|
||||
{
|
||||
typedef storage6<A1, A2, A3, A4, A5, A6> inherited;
|
||||
|
||||
storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ), a7_( a7 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
BOOST_BIND_VISIT_EACH(v, a7_, 0);
|
||||
}
|
||||
|
||||
A7 a7_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, int I> struct storage7< A1, A2, A3, A4, A5, A6, boost::arg<I> >: public storage6< A1, A2, A3, A4, A5, A6 >
|
||||
{
|
||||
typedef storage6<A1, A2, A3, A4, A5, A6> inherited;
|
||||
|
||||
storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, boost::arg<I> ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a7_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, int I> struct storage7< A1, A2, A3, A4, A5, A6, boost::arg<I> (*) () >: public storage6< A1, A2, A3, A4, A5, A6 >
|
||||
{
|
||||
typedef storage6<A1, A2, A3, A4, A5, A6> inherited;
|
||||
|
||||
storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, boost::arg<I> (*) () ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a7_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// 8
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct storage8: public storage7< A1, A2, A3, A4, A5, A6, A7 >
|
||||
{
|
||||
typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited;
|
||||
|
||||
storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8 ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ), a8_( a8 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
BOOST_BIND_VISIT_EACH(v, a8_, 0);
|
||||
}
|
||||
|
||||
A8 a8_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, int I> struct storage8< A1, A2, A3, A4, A5, A6, A7, boost::arg<I> >: public storage7< A1, A2, A3, A4, A5, A6, A7 >
|
||||
{
|
||||
typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited;
|
||||
|
||||
storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, boost::arg<I> ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a8_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, int I> struct storage8< A1, A2, A3, A4, A5, A6, A7, boost::arg<I> (*) () >: public storage7< A1, A2, A3, A4, A5, A6, A7 >
|
||||
{
|
||||
typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited;
|
||||
|
||||
storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, boost::arg<I> (*) () ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a8_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// 9
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct storage9: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 >
|
||||
{
|
||||
typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited;
|
||||
|
||||
storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9 ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ), a9_( a9 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
BOOST_BIND_VISIT_EACH(v, a9_, 0);
|
||||
}
|
||||
|
||||
A9 a9_;
|
||||
};
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, int I> struct storage9< A1, A2, A3, A4, A5, A6, A7, A8, boost::arg<I> >: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 >
|
||||
{
|
||||
typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited;
|
||||
|
||||
storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, boost::arg<I> ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a9_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, int I> struct storage9< A1, A2, A3, A4, A5, A6, A7, A8, boost::arg<I> (*) () >: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 >
|
||||
{
|
||||
typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited;
|
||||
|
||||
storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, boost::arg<I> (*) () ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ) {}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
inherited::accept(v);
|
||||
}
|
||||
|
||||
static boost::arg<I> a9_() { return boost::arg<I>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace _bi
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(default: 4512) // assignment operator could not be generated
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_BIND_STORAGE_HPP_INCLUDED
|
||||
File diff suppressed because it is too large
Load Diff
16
index.html
Normal file
16
index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=bind.html">
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="bind.html">bind.html</a> or
|
||||
<a href="mem_fn.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
|
||||
-->
|
||||
273
mem_fn.html
273
mem_fn.html
@@ -1,267 +1,14 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>Boost: mem_fn.hpp documentation</title>
|
||||
<meta http-equiv="refresh" content="0; URL=../bind/mem_fn.html">
|
||||
</head>
|
||||
|
||||
<body bgcolor="White">
|
||||
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
<td width="277">
|
||||
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" WIDTH="277" HEIGHT="86">
|
||||
</td>
|
||||
<td align="center">
|
||||
<table border="0">
|
||||
<tr><td nowrap><h1>mem_fn.hpp</h1></td></tr>
|
||||
<tr><td align="right" nowrap><small> 1.02.0001 (2001-08-30)</small></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Files</h2>
|
||||
<ul>
|
||||
<li><a href="../../boost/mem_fn.hpp">mem_fn.hpp</a> (implementation)
|
||||
<li><a href="mem_fn_test.cpp">mem_fn_test.cpp</a> (test)
|
||||
</ul>
|
||||
|
||||
<h2>Purpose</h2>
|
||||
|
||||
<p>
|
||||
<b>boost::mem_fn</b> is a generalization of the standard functions
|
||||
<b>std::mem_fun</b> and <b>std::mem_fun_ref</b>. It supports member
|
||||
function pointers with more than one argument, and the returned function
|
||||
object can take a pointer, a reference, or a smart pointer to an object
|
||||
instance as its first argument.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>mem_fn</b> takes one argument, a pointer to a member function, and
|
||||
returns a function object suitable for use with standard or user-defined
|
||||
algorithms:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
struct X
|
||||
{
|
||||
void f();
|
||||
};
|
||||
|
||||
void g(std::vector<X> & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
|
||||
void h(std::vector<X *> const & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
|
||||
void k(std::vector<boost::shared_ptr<X> > const & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The returned function object takes the same arguments as the input member
|
||||
function plus a "flexible" first argument that represents the object instance.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
When the function object is invoked with a first argument <b>x</b> that is
|
||||
neither a pointer nor a reference to the appropriate class (<b>X</b> in the
|
||||
example above), it uses <tt>get_pointer(x)</tt> to obtain a pointer from
|
||||
<b>x</b>. Library authors can "register" their smart pointer classes by
|
||||
supplying an appropriate <b>get_pointer</b> overload, allowing <b>mem_fn</b>
|
||||
to recognize and support them.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A <b>get_pointer</b> overload for <b>boost::shared_ptr</b> is supplied.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
[Note: <b>get_pointer</b> is not restricted to return a pointer. Any object
|
||||
that can be used in a member function call expression <tt>(x->*pmf)(...)</tt>
|
||||
will work.]
|
||||
</p>
|
||||
|
||||
<p>
|
||||
[Note: the library uses an unqualified call to <b>get_pointer</b>. Therefore,
|
||||
it will find, through argument-dependent lookup, <b>get_pointer</b> overloads
|
||||
that are defined in the same namespace as the corresponding smart pointer
|
||||
class, in addition to any <b>boost::get_pointer</b> overloads.]
|
||||
</p>
|
||||
|
||||
<p>
|
||||
All function objects returned by <b>mem_fn</b> expose a <b>result_type</b>
|
||||
typedef that represents the return type of the member function.
|
||||
</p>
|
||||
|
||||
<h2>Interface</h2>
|
||||
|
||||
<h3>Synopsis</h3>
|
||||
|
||||
<pre>
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T> T * <a href="#get_pointer_1">get_pointer</a>(T * p);
|
||||
|
||||
template<class T> T * <a href="#get_pointer_2">get_pointer</a>(shared_ptr<T> const & p);
|
||||
|
||||
template<class R, class T> <i>implementation-defined-1</i> <a href="#mem_fn_1">mem_fn</a>(R (T::*pmf) ());
|
||||
|
||||
template<class R, class T> <i>implementation-defined-2</i> <a href="#mem_fn_2">mem_fn</a>(R (T::*pmf) () const);
|
||||
|
||||
template<class R, class T, class A1> <i>implementation-defined-3</i> <a href="#mem_fn_3">mem_fn</a>(R (T::*pmf) (A1));
|
||||
|
||||
template<class R, class T, class A1> <i>implementation-defined-4</i> <a href="#mem_fn_4">mem_fn</a>(R (T::*pmf) (A1) const);
|
||||
|
||||
template<class R, class T, class A1, class A2> <i>implementation-defined-5</i> <a href="#mem_fn_5">mem_fn</a>(R (T::*pmf) (A1, A2));
|
||||
|
||||
template<class R, class T, class A1, class A2> <i>implementation-defined-6</i> <a href="#mem_fn_6">mem_fn</a>(R (T::*pmf) (A1, A2) const);
|
||||
|
||||
// implementation defined number of additional overloads for more arguments
|
||||
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3>Common requirements</h3>
|
||||
|
||||
<p>
|
||||
All <tt><i>implementation-defined-N</i></tt> types mentioned in the Synopsis are
|
||||
<b>CopyConstructible</b> and <b>Assignable</b>.
|
||||
Their copy constructors and assignment operators do not throw exceptions.
|
||||
<tt><i>implementation-defined-N</i>::result_type</tt> is defined as
|
||||
the return type of the member function pointer passed as an argument to <b>mem_fn</b>
|
||||
(<b>R</b> in the Synopsis.)
|
||||
</p>
|
||||
|
||||
<h3>get_pointer</h3>
|
||||
|
||||
<h4><a name="get_pointer_1">template<class T> T * get_pointer(T * p)</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> <tt>p</tt>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h4><a name="get_pointer_2">template<class T> T * get_pointer(shared_ptr<T> const & p)</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> <tt>p.get()</tt>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h3>mem_fn</h3>
|
||||
|
||||
<h4><a name="mem_fn_1">template<class R, class T> <i>implementation-defined-1</i> mem_fn(R (T::*pmf) ())</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression
|
||||
<tt><i>f(t)</i></tt> is equivalent to <tt>(t.*pmf)()</tt> when <i>t</i>
|
||||
is an l-value of type <b>T</b>, <tt>(get_pointer(t)->*pmf)()</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h4><a name="mem_fn_2">template<class R, class T> <i>implementation-defined-2</i> mem_fn(R (T::*pmf) () const)</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression
|
||||
<tt><i>f(t)</i></tt> is equivalent to <tt>(t.*pmf)()</tt> when <i>t</i>
|
||||
is of type <b>T <i>[</i>const<i>]</i></b>, <tt>(get_pointer(t)->*pmf)()</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h4><a name="mem_fn_3">template<class R, class T, class A1> <i>implementation-defined-3</i> mem_fn(R (T::*pmf) (A1))</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression
|
||||
<tt><i>f(t, a1)</i></tt> is equivalent to <tt>(t.*pmf)(a1)</tt> when <i>t</i>
|
||||
is an l-value of type <b>T</b>, <tt>(get_pointer(t)->*pmf)(a1)</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h4><a name="mem_fn_4">template<class R, class T, class A1> <i>implementation-defined-4</i> mem_fn(R (T::*pmf) (A1) const)</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression
|
||||
<tt><i>f(t, a1)</i></tt> is equivalent to <tt>(t.*pmf)(a1)</tt> when <i>t</i>
|
||||
is of type <b>T <i>[</i>const<i>]</i></b>, <tt>(get_pointer(t)->*pmf)(a1)</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h4><a name="mem_fn_5">template<class R, class T, class A1, class A2> <i>implementation-defined-5</i> mem_fn(R (T::*pmf) (A1, A2))</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression
|
||||
<tt><i>f(t, a1, a2)</i></tt> is equivalent to <tt>(t.*pmf)(a1, a2)</tt> when <i>t</i>
|
||||
is an l-value of type <b>T</b>, <tt>(get_pointer(t)->*pmf)(a1, a2)</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h4><a name="mem_fn_6">template<class R, class T, class A1, class A2> <i>implementation-defined-6</i> mem_fn(R (T::*pmf) (A1, A2) const)</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression
|
||||
<tt><i>f(t, a1, a2)</i></tt> is equivalent to <tt>(t.*pmf)(a1, a2)</tt> when <i>t</i>
|
||||
is of type <b>T <i>[</i>const<i>]</i></b>, <tt>(get_pointer(t)->*pmf)(a1, a2)</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h2>Implementation</h2>
|
||||
|
||||
<p>
|
||||
This implementation supports member functions with up to eight arguments.
|
||||
This is not an inherent limitation of the design, but an implementation
|
||||
detail.
|
||||
</p>
|
||||
|
||||
<h2>Acknowledgements</h2>
|
||||
|
||||
<p>
|
||||
Rene Jager's initial suggestion of using traits classes to make
|
||||
<b>mem_fn</b> adapt to user-defined smart pointers inspired the
|
||||
<b>get_pointer</b>-based design.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Numerous improvements were suggested during the formal review period by
|
||||
Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager
|
||||
was Darin Adler.
|
||||
</p>
|
||||
|
||||
|
||||
<p><br><br><br><small>Copyright © 2001 by Peter Dimov and Multi Media
|
||||
Ltd. Permission to copy, use, modify, sell and distribute this document is
|
||||
granted provided this copyright notice appears in all copies. This document
|
||||
is provided "as is" without express or implied warranty, and with
|
||||
no claim as to its suitability for any purpose.</small></p>
|
||||
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../bind/mem_fn.html">../bind/mem_fn.html</a>. <hr>
|
||||
<p>© Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
<p> </p>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
167
ref.html
167
ref.html
@@ -1,162 +1,15 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>Boost: ref.hpp documentation</title>
|
||||
<meta http-equiv="refresh" content="0; URL=../../doc/html/ref.html">
|
||||
</head>
|
||||
|
||||
<body bgcolor="White">
|
||||
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
<td width="277">
|
||||
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86">
|
||||
</td>
|
||||
<td align="center">
|
||||
<table border="0">
|
||||
<tr><td nowrap><h1>ref.hpp</h1></td></tr>
|
||||
<tr><td align="right" nowrap><small> 1.00.0003 (2001-08-22)</small></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Files</h2>
|
||||
<ul>
|
||||
<li><a href="../../boost/ref.hpp">ref.hpp</a>
|
||||
</ul>
|
||||
|
||||
<h2>Purpose</h2>
|
||||
|
||||
<p>
|
||||
The header <a href="../../boost/ref.hpp">boost/ref.hpp</a> defines the class template
|
||||
<b>boost::reference_wrapper<T></b> and the two functions <b>boost::ref</b> and
|
||||
<b>boost::cref</b> that return instances of <b>boost::reference_wrapper<T></b>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The purpose of <b>boost::reference_wrapper<T></b> is to contain a reference to
|
||||
an object of type <b>T</b>. It is primarily used to "feed" references to
|
||||
function templates (algorithms) that take their parameter by value.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To support this usage, <b>boost::reference_wrapper<T></b> provides an implicit
|
||||
conversion to <b>T &</b>. This usually allows the function templates to
|
||||
work on references unmodified.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>boost::reference_wrapper<T></b> is <b>CopyConstructible</b>, but it is not
|
||||
<b>Assignable</b>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The expression <b>boost::ref(x)</b> returns a <b>boost::reference_wrapper<X>(x)</b>
|
||||
where <b>X</b> is the type of <b>x</b>. Similarly, <b>boost::cref(x)</b>
|
||||
returns a <b>boost::reference_wrapper<X const>(x)</b>.
|
||||
</p>
|
||||
|
||||
<h2>Interface</h2>
|
||||
|
||||
<h3>Synopsis</h3>
|
||||
|
||||
<pre>
|
||||
namespace boost
|
||||
{
|
||||
template<class T> class <a href="#reference_wrapper">reference_wrapper</a>;
|
||||
template<class T> reference_wrapper<T> <a href="#ref">ref</a>(T & t);
|
||||
template<class T> reference_wrapper<T const> <a href="#cref">cref</a>(T const & t);
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3><a name="reference_wrapper">reference_wrapper</a></h3>
|
||||
|
||||
<pre>
|
||||
template<class T> class reference_wrapper
|
||||
{
|
||||
public:
|
||||
|
||||
explicit <a href="#rt_construct">reference_wrapper</a>(T & t);
|
||||
|
||||
<a href="#rt_operator">operator T &</a> () const;
|
||||
|
||||
T & <a href="#rt_get">get</a>() const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<h4><a name="rt_construct">explicit reference_wrapper(T & t)</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Effects:</b> Constructs a <b>reference_wrapper</b> object that stores a reference to <b>t</b>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h4><a name="rt_operator">operator T & () const</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> the stored reference.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h4><a name="rt_get">T & get() const</a></h4>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> the stored reference.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h3><a name="ref">ref</a></h3>
|
||||
|
||||
<pre>
|
||||
template<class T> reference_wrapper<T> ref(T & t);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> <tt>reference_wrapper<T>(t)</tt>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h3><a name="cref">cref</a></h3>
|
||||
|
||||
<pre>
|
||||
template<class T> reference_wrapper<T const> cref(T const & t);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<b>Returns:</b> <tt>reference_wrapper<T const>(t)</tt>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
|
||||
<h2>Acknowledgements</h2>
|
||||
|
||||
<p>
|
||||
<b>ref</b> and <b>cref</b> were originally part of the Boost.Tuple library.
|
||||
They were "promoted to <b>boost::</b> status" because they are generally
|
||||
useful.
|
||||
</p>
|
||||
|
||||
|
||||
<p><br><br><br><small>Copyright © 2001 by Peter Dimov and Multi Media
|
||||
Ltd. Permission to copy, use, modify, sell and distribute this document is
|
||||
granted provided this copyright notice appears in all copies. This document
|
||||
is provided "as is" without express or implied warranty, and with
|
||||
no claim as to its suitability for any purpose.</small></p>
|
||||
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../../doc/html/ref.html">../../doc/html/ref.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
|
||||
-->
|
||||
|
||||
34
test/Jamfile.v2
Normal file
34
test/Jamfile.v2
Normal file
@@ -0,0 +1,34 @@
|
||||
# Boost.Bind Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2003-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)
|
||||
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
test-suite "bind"
|
||||
: [ 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 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 ]
|
||||
;
|
||||
164
test/bind_cdecl_mf_test.cpp
Normal file
164
test/bind_cdecl_mf_test.cpp
Normal file
@@ -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_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();
|
||||
}
|
||||
184
test/bind_const_test.cpp
Normal file
184
test/bind_const_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
158
test/bind_cv_test.cpp
Normal file
158
test/bind_cv_test.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
#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
|
||||
{
|
||||
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();
|
||||
}
|
||||
70
test/bind_dm2_test.cpp
Normal file
70
test/bind_dm2_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
46
test/bind_dm3_test.cpp
Normal file
46
test/bind_dm3_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
73
test/bind_dm_test.cpp
Normal file
73
test/bind_dm_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
427
test/bind_eq_test.cpp
Normal file
427
test/bind_eq_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#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
|
||||
@@ -6,71 +8,66 @@
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_test_3.cpp - tests bind.hpp with member function pointers
|
||||
//
|
||||
// Version 1.00.0003 (2001-07-13)
|
||||
// bind_stdcall_mf_test.cpp - test for bind.hpp + __stdcall (member functions)
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// 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>
|
||||
#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 X
|
||||
{
|
||||
mutable unsigned int hash;
|
||||
|
||||
X(): hash(0) {}
|
||||
|
||||
int f0() { f1(17); return 0; }
|
||||
int g0() const { g1(17); return 0; }
|
||||
void __fastcall f0() { f1(17); }
|
||||
void __fastcall g0() const { g1(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 __fastcall f1(int a1) { hash = (hash * 17041 + a1) % 32768; }
|
||||
void __fastcall g1(int a1) const { 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 __fastcall f2(int a1, int a2) { f1(a1); f1(a2); }
|
||||
void __fastcall g2(int a1, int a2) const { g1(a1); g1(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 __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); }
|
||||
|
||||
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 __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); }
|
||||
|
||||
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 __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); }
|
||||
|
||||
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 __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); }
|
||||
|
||||
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 __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); }
|
||||
|
||||
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 __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()
|
||||
void member_function_test()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
@@ -157,5 +154,11 @@ int main()
|
||||
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)();
|
||||
|
||||
return detect_errors(x.hash == 23558);
|
||||
BOOST_TEST( x.hash == 23558 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
110
test/bind_fastcall_test.cpp
Normal file
110
test/bind_fastcall_test.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#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_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();
|
||||
}
|
||||
77
test/bind_function_test.cpp
Normal file
77
test/bind_function_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
40
test/bind_lookup_problem_test.cpp
Normal file
40
test/bind_lookup_problem_test.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// bind_lookup_problem_test.cpp
|
||||
//
|
||||
// Copyright (C) Markus Schöpflin 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;
|
||||
}
|
||||
57
test/bind_not_test.cpp
Normal file
57
test/bind_not_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
97
test/bind_rel_test.cpp
Normal file
97
test/bind_rel_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
64
test/bind_rv_sp_test.cpp
Normal file
64
test/bind_rv_sp_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
222
test/bind_stateful_test.cpp
Normal file
222
test/bind_stateful_test.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
#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)
|
||||
{
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
164
test/bind_stdcall_mf_test.cpp
Normal file
164
test/bind_stdcall_mf_test.cpp
Normal file
@@ -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_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();
|
||||
}
|
||||
110
test/bind_stdcall_test.cpp
Normal file
110
test/bind_stdcall_test.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#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();
|
||||
}
|
||||
521
test/bind_test.cpp
Normal file
521
test/bind_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
147
test/bind_unary_addr.cpp
Normal file
147
test/bind_unary_addr.cpp
Normal file
@@ -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;
|
||||
}
|
||||
67
test/bind_visit_test.cpp
Normal file
67
test/bind_visit_test.cpp
Normal file
@@ -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
|
||||
|
||||
// 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();
|
||||
}
|
||||
186
test/mem_fn_cdecl_test.cpp
Normal file
186
test/mem_fn_cdecl_test.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
#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_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);
|
||||
}
|
||||
188
test/mem_fn_derived_test.cpp
Normal file
188
test/mem_fn_derived_test.cpp
Normal file
@@ -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);
|
||||
}
|
||||
67
test/mem_fn_dm_test.cpp
Normal file
67
test/mem_fn_dm_test.cpp
Normal file
@@ -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();
|
||||
}
|
||||
300
test/mem_fn_eq_test.cpp
Normal file
300
test/mem_fn_eq_test.cpp
Normal file
@@ -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 0; }
|
||||
|
||||
int cmf0_1() const { return 0; }
|
||||
int cmf0_2() const { return 0; }
|
||||
|
||||
void mf0v_1() {}
|
||||
void mf0v_2() {}
|
||||
|
||||
void cmf0v_1() const {}
|
||||
void cmf0v_2() const {}
|
||||
|
||||
// 1
|
||||
|
||||
int mf1_1(int) { return 0; }
|
||||
int mf1_2(int) { return 0; }
|
||||
|
||||
int cmf1_1(int) const { return 0; }
|
||||
int cmf1_2(int) const { return 0; }
|
||||
|
||||
void mf1v_1(int) {}
|
||||
void mf1v_2(int) {}
|
||||
|
||||
void cmf1v_1(int) const {}
|
||||
void cmf1v_2(int) const {}
|
||||
|
||||
// 2
|
||||
|
||||
int mf2_1(int, int) { return 0; }
|
||||
int mf2_2(int, int) { return 0; }
|
||||
|
||||
int cmf2_1(int, int) const { return 0; }
|
||||
int cmf2_2(int, int) const { return 0; }
|
||||
|
||||
void mf2v_1(int, int) {}
|
||||
void mf2v_2(int, int) {}
|
||||
|
||||
void cmf2v_1(int, int) const {}
|
||||
void cmf2v_2(int, int) const {}
|
||||
|
||||
// 3
|
||||
|
||||
int mf3_1(int, int, int) { return 0; }
|
||||
int mf3_2(int, int, int) { return 0; }
|
||||
|
||||
int cmf3_1(int, int, int) const { return 0; }
|
||||
int cmf3_2(int, int, int) const { return 0; }
|
||||
|
||||
void mf3v_1(int, int, int) {}
|
||||
void mf3v_2(int, int, int) {}
|
||||
|
||||
void cmf3v_1(int, int, int) const {}
|
||||
void cmf3v_2(int, int, int) const {}
|
||||
|
||||
// 4
|
||||
|
||||
int mf4_1(int, int, int, int) { return 0; }
|
||||
int mf4_2(int, int, int, int) { return 0; }
|
||||
|
||||
int cmf4_1(int, int, int, int) const { return 0; }
|
||||
int cmf4_2(int, int, int, int) const { return 0; }
|
||||
|
||||
void mf4v_1(int, int, int, int) {}
|
||||
void mf4v_2(int, int, int, int) {}
|
||||
|
||||
void cmf4v_1(int, int, int, int) const {}
|
||||
void cmf4v_2(int, int, int, int) const {}
|
||||
|
||||
// 5
|
||||
|
||||
int mf5_1(int, int, int, int, int) { return 0; }
|
||||
int mf5_2(int, int, int, int, int) { return 0; }
|
||||
|
||||
int cmf5_1(int, int, int, int, int) const { return 0; }
|
||||
int cmf5_2(int, int, int, int, int) const { return 0; }
|
||||
|
||||
void mf5v_1(int, int, int, int, int) {}
|
||||
void mf5v_2(int, int, int, int, int) {}
|
||||
|
||||
void cmf5v_1(int, int, int, int, int) const {}
|
||||
void cmf5v_2(int, int, int, int, int) const {}
|
||||
|
||||
// 6
|
||||
|
||||
int mf6_1(int, int, int, int, int, int) { return 0; }
|
||||
int mf6_2(int, int, int, int, int, int) { return 0; }
|
||||
|
||||
int cmf6_1(int, int, int, int, int, int) const { return 0; }
|
||||
int cmf6_2(int, int, int, int, int, int) const { return 0; }
|
||||
|
||||
void mf6v_1(int, int, int, int, int, int) {}
|
||||
void mf6v_2(int, int, int, int, int, int) {}
|
||||
|
||||
void cmf6v_1(int, int, int, int, int, int) const {}
|
||||
void cmf6v_2(int, int, int, int, int, int) const {}
|
||||
|
||||
// 7
|
||||
|
||||
int mf7_1(int, int, int, int, int, int, int) { return 0; }
|
||||
int mf7_2(int, int, int, int, int, int, int) { return 0; }
|
||||
|
||||
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 0; }
|
||||
|
||||
void mf7v_1(int, int, int, int, int, int, int) {}
|
||||
void mf7v_2(int, int, int, int, int, int, int) {}
|
||||
|
||||
void cmf7v_1(int, int, int, int, int, int, int) const {}
|
||||
void cmf7v_2(int, int, int, int, int, int, int) const {}
|
||||
|
||||
// 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 0; }
|
||||
|
||||
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 0; }
|
||||
|
||||
void mf8v_1(int, int, int, int, int, int, int, int) {}
|
||||
void mf8v_2(int, int, int, int, int, int, int, int) {}
|
||||
|
||||
void cmf8v_1(int, int, int, int, int, int, int, int) const {}
|
||||
void cmf8v_2(int, int, int, int, int, int, int, int) const {}
|
||||
|
||||
};
|
||||
|
||||
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();
|
||||
}
|
||||
186
test/mem_fn_fastcall_test.cpp
Normal file
186
test/mem_fn_fastcall_test.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
#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_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);
|
||||
}
|
||||
117
test/mem_fn_rv_test.cpp
Normal file
117
test/mem_fn_rv_test.cpp
Normal file
@@ -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 );
|
||||
}
|
||||
186
test/mem_fn_stdcall_test.cpp
Normal file
186
test/mem_fn_stdcall_test.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
#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_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);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#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
|
||||
@@ -8,20 +10,27 @@
|
||||
//
|
||||
// mem_fn_test.cpp - a test for mem_fn.hpp
|
||||
//
|
||||
// Version 1.02.0001 (2001-08-30)
|
||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// 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/smart_ptr.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;
|
||||
@@ -171,5 +180,5 @@ int main()
|
||||
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);
|
||||
return detect_errors(mem_fn(&X::hash)(x) == 17610 && mem_fn(&X::hash)(sp) == 2155);
|
||||
}
|
||||
184
test/mem_fn_void_test.cpp
Normal file
184
test/mem_fn_void_test.cpp
Normal file
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user