Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54618 - in trunk/libs/function: doc test
From: daniel_james_at_[hidden]
Date: 2009-07-03 18:21:40


Author: danieljames
Date: 2009-07-03 18:21:40 EDT (Fri, 03 Jul 2009)
New Revision: 54618
URL: http://svn.boost.org/trac/boost/changeset/54618

Log:
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.
Text files modified:
   trunk/libs/function/doc/tutorial.xml | 4 ++--
   trunk/libs/function/test/function_test.cpp | 18 +++++++++---------
   trunk/libs/function/test/lambda_test.cpp | 12 ++++++------
   3 files changed, 17 insertions(+), 17 deletions(-)

Modified: trunk/libs/function/doc/tutorial.xml
==============================================================================
--- trunk/libs/function/doc/tutorial.xml (original)
+++ trunk/libs/function/doc/tutorial.xml 2009-07-03 18:21:40 EDT (Fri, 03 Jul 2009)
@@ -35,12 +35,12 @@
         <row>
           <entry>
             <itemizedlist spacing="compact">
- <listitem><simpara>GNU C++ since 2.95.x</simpara></listitem>
+ <listitem><simpara>GNU C++ 2.95.x, 3.0.x and later verseions</simpara></listitem>
               <listitem><simpara>Comeau C++ 4.2.45.2</simpara></listitem>
               <listitem><simpara>SGI MIPSpro 7.3.0</simpara></listitem>
               <listitem><simpara>Intel C++ 5.0, 6.0</simpara></listitem>
               <listitem><simpara>Compaq's cxx 6.2</simpara></listitem>
- <listitem><simpara>Microsoft Visual C++ since 7.1</simpara></listitem>
+ <listitem><simpara>Microsoft Visual C++ 7.1 and later versions</simpara></listitem>
             </itemizedlist>
           </entry>
           <entry>

Modified: trunk/libs/function/test/function_test.cpp
==============================================================================
--- trunk/libs/function/test/function_test.cpp (original)
+++ trunk/libs/function/test/function_test.cpp 2009-07-03 18:21:40 EDT (Fri, 03 Jul 2009)
@@ -13,8 +13,8 @@
 #include <string>
 #include <utility>
 
-using namespace boost;
-using namespace std;
+using boost::function;
+using std::string;
 
 int global_int;
 
@@ -525,7 +525,7 @@
 static void
 test_one_arg()
 {
- negate<int> neg;
+ std::negate<int> neg;
 
   function<int (int)> f1(neg);
   BOOST_CHECK(f1(5) == -5);
@@ -607,12 +607,12 @@
 
   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 @@
 {
   add_with_throw_on_copy atc;
   try {
- boost::function<int (int, int)> f(ref(atc));
+ boost::function<int (int, int)> 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 @@
     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.");
   }
 }

Modified: trunk/libs/function/test/lambda_test.cpp
==============================================================================
--- trunk/libs/function/test/lambda_test.cpp (original)
+++ trunk/libs/function/test/lambda_test.cpp 2009-07-03 18:21:40 EDT (Fri, 03 Jul 2009)
@@ -15,21 +15,21 @@
 #include <boost/lambda/bind.hpp>
 #include <boost/function.hpp>
 
-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<int>((arg2 ? arg1 : 2 * arg1) * arg3));
 }
 
 int test_main(int, char*[])
 {
+ using boost::function;
+ using namespace boost::lambda;
+
   function <unsigned(bool, double)> f1 = bind(func_impl, 15, _1, _2);
- function <unsigned(double)> f2 = bind(f1, false, _1);
- function <unsigned()> f3 = bind(f2, 4.0);
+ function <unsigned(double)> f2 = boost::lambda::bind(f1, false, _1);
+ function <unsigned()> f3 = boost::lambda::bind(f2, 4.0);
 
   f3();
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk