mirror of
https://github.com/boostorg/function.git
synced 2025-07-16 22:22:12 +02:00
Fixed broken testcases that came from tutorial sample code
[SVN r16935]
This commit is contained in:
@ -7,20 +7,22 @@
|
||||
|
||||
float mul_ints(int x, int y) { return ((float)x) * y; }
|
||||
|
||||
|
||||
struct int_div {
|
||||
float operator()(int x, int y) const { return ((float)x)/y; };
|
||||
};
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
boost::function<float (int x, int y)> f;
|
||||
|
||||
|
||||
struct int_div {
|
||||
float operator()(int x, int y) const { return ((float)x)/y; };
|
||||
};
|
||||
|
||||
f = int_div();
|
||||
|
||||
|
||||
std::cout << f(5, 3) >> std::endl;
|
||||
std::cout << f(5, 3) << std::endl;
|
||||
|
||||
|
||||
if (f)
|
||||
@ -34,5 +36,4 @@ f = 0;
|
||||
|
||||
f = &mul_ints;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,20 +6,21 @@
|
||||
|
||||
float mul_ints(int x, int y) { return ((float)x) * y; }
|
||||
|
||||
|
||||
struct int_div {
|
||||
float operator()(int x, int y) const { return ((float)x)/y; };
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
boost::function2<float, int, int> f;
|
||||
|
||||
|
||||
struct int_div {
|
||||
float operator()(int x, int y) const { return ((float)x)/y; };
|
||||
};
|
||||
|
||||
f = int_div();
|
||||
|
||||
|
||||
std::cout << f(5, 3) >> std::endl;
|
||||
std::cout << f(5, 3) << std::endl;
|
||||
|
||||
|
||||
if (f)
|
||||
@ -34,4 +35,3 @@ f = 0;
|
||||
f = &mul_ints;
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <iostream>
|
||||
|
||||
|
||||
struct stateful_type { int operator(int) const { return 0; } };
|
||||
struct stateful_type { int operator()(int) const { return 0; } };
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -16,4 +16,3 @@ int main()
|
||||
boost::function<int (int)> f2(f);
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <iostream>
|
||||
|
||||
|
||||
struct stateful_type { int operator(int) const { return 0; } };
|
||||
struct stateful_type { int operator()(int) const { return 0; } };
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -16,4 +16,3 @@ int main()
|
||||
boost::function1<int, int> f2(f);
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ int test_main(int, char*[])
|
||||
function <unsigned(double)> f2 = bind(f1, false, _1);
|
||||
function <unsigned()> f3 = bind(f2, 4.0);
|
||||
|
||||
unsigned result = f3();
|
||||
f3();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ struct X {
|
||||
int foo(int);
|
||||
};
|
||||
|
||||
int X::foo(int x) { return -x; }
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@ -20,4 +22,3 @@ X x;
|
||||
f(&x, 5);
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ struct X {
|
||||
int foo(int);
|
||||
};
|
||||
|
||||
int X::foo(int x) { return -x; }
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@ -20,4 +22,3 @@ X x;
|
||||
f(&x, 5);
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
struct stateless_integer_add {
|
||||
int operator()(int x, int y) const { return x+y; }
|
||||
|
||||
void* operator new(std::size_t, stateless_integer_add*)
|
||||
void* operator new(std::size_t, stateless_integer_add*) throw()
|
||||
{
|
||||
throw std::runtime_error("Cannot allocate a stateless_integer_add");
|
||||
return 0; // suppress warnings
|
||||
|
@ -9,6 +9,8 @@ struct X {
|
||||
int foo(int);
|
||||
};
|
||||
|
||||
int X::foo(int x) { return -x; }
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@ -19,4 +21,3 @@ int main()
|
||||
f(5); // Call x.foo(5)
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ struct X {
|
||||
int foo(int);
|
||||
};
|
||||
|
||||
int X::foo(int x) { return -x; }
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@ -19,4 +21,3 @@ int main()
|
||||
f(5); // Call x.foo(5)
|
||||
|
||||
}
|
||||
|
@ -21,4 +21,3 @@ boost::function<void (int values[], int n, int& sum, float& avg)> sum_avg;
|
||||
sum_avg = &do_sum_avg;
|
||||
|
||||
}
|
||||
|
@ -21,4 +21,3 @@ boost::function4<void, int[], int, int&, float> sum_avg;
|
||||
sum_avg = &do_sum_avg;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user