From ae534d73424b93bc1f78bc88e50984bee404013c Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 3 Jul 2009 22:21:40 +0000 Subject: [PATCH] Fix Boost.Function unit tests for C++0x. Fixes #3012 Based on a patch from Richard Webb. Changed a bit so that it also works for the Visual C++ 10 beta. [SVN r54618] --- doc/tutorial.xml | 4 ++-- test/function_test.cpp | 18 +++++++++--------- test/lambda_test.cpp | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/tutorial.xml b/doc/tutorial.xml index f8f2294..1e2eba8 100644 --- a/doc/tutorial.xml +++ b/doc/tutorial.xml @@ -35,12 +35,12 @@ form to use for your compiler. - GNU C++ since 2.95.x + GNU C++ 2.95.x, 3.0.x and later verseions Comeau C++ 4.2.45.2 SGI MIPSpro 7.3.0 Intel C++ 5.0, 6.0 Compaq's cxx 6.2 - Microsoft Visual C++ since 7.1 + Microsoft Visual C++ 7.1 and later versions diff --git a/test/function_test.cpp b/test/function_test.cpp index faf4bfb..65d6e58 100644 --- a/test/function_test.cpp +++ b/test/function_test.cpp @@ -13,8 +13,8 @@ #include #include -using namespace boost; -using namespace std; +using boost::function; +using std::string; int global_int; @@ -525,7 +525,7 @@ test_zero_args() static void test_one_arg() { - negate neg; + std::negate neg; function f1(neg); BOOST_CHECK(f1(5) == -5); @@ -607,12 +607,12 @@ struct add_with_throw_on_copy { add_with_throw_on_copy(const add_with_throw_on_copy&) { - throw runtime_error("But this CAN'T throw"); + throw std::runtime_error("But this CAN'T throw"); } add_with_throw_on_copy& operator=(const add_with_throw_on_copy&) { - throw runtime_error("But this CAN'T throw"); + throw std::runtime_error("But this CAN'T throw"); } }; @@ -621,10 +621,10 @@ test_ref() { add_with_throw_on_copy atc; try { - boost::function f(ref(atc)); + boost::function f(boost::ref(atc)); BOOST_CHECK(f(1, 3) == 4); } - catch(runtime_error e) { + catch(std::runtime_error e) { BOOST_ERROR("Nonthrowing constructor threw an exception"); } } @@ -640,14 +640,14 @@ static void test_empty_ref() f2(); BOOST_ERROR("Exception didn't throw for reference to empty function."); } - catch(runtime_error e) {} + catch(std::runtime_error e) {} f1 = dummy; try { f2(); } - catch(runtime_error e) { + catch(std::runtime_error e) { BOOST_ERROR("Error calling referenced function."); } } diff --git a/test/lambda_test.cpp b/test/lambda_test.cpp index 97fa7f8..2abca54 100644 --- a/test/lambda_test.cpp +++ b/test/lambda_test.cpp @@ -15,21 +15,21 @@ #include #include -using namespace std; -using namespace boost; -using namespace boost::lambda; - static unsigned func_impl(int arg1, bool arg2, double arg3) { + using namespace std; return abs (static_cast((arg2 ? arg1 : 2 * arg1) * arg3)); } int test_main(int, char*[]) { + using boost::function; + using namespace boost::lambda; + function f1 = bind(func_impl, 15, _1, _2); - function f2 = bind(f1, false, _1); - function f3 = bind(f2, 4.0); + function f2 = boost::lambda::bind(f1, false, _1); + function f3 = boost::lambda::bind(f2, 4.0); f3();