Fixed broken testcases that came from tutorial sample code

[SVN r16935]
This commit is contained in:
Douglas Gregor
2003-01-19 14:44:34 +00:00
parent 4a46b5e1b9
commit 09657f1134
12 changed files with 26 additions and 25 deletions

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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

View File

@ -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)
}

View File

@ -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)
}

View File

@ -21,4 +21,3 @@ boost::function<void (int values[], int n, int& sum, float& avg)> sum_avg;
sum_avg = &do_sum_avg;
}

View File

@ -21,4 +21,3 @@ boost::function4<void, int[], int, int&, float> sum_avg;
sum_avg = &do_sum_avg;
}