Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58287 - in sandbox/chrono/libs/chrono: example src/win test
From: vicente.botet_at_[hidden]
Date: 2009-12-11 03:33:18


Author: viboes
Date: 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
New Revision: 58287
URL: http://svn.boost.org/trac/boost/changeset/58287

Log:
Boost.Chrono: Version 0.2.4, Bug fixes
* Take care of Boost min/max recommendations

Text files modified:
   sandbox/chrono/libs/chrono/example/cycle_count.cpp | 3 ---
   sandbox/chrono/libs/chrono/example/i_dont_like_the_default_duration_behavior.cpp | 4 ----
   sandbox/chrono/libs/chrono/example/min_time_point.cpp | 7 ++-----
   sandbox/chrono/libs/chrono/example/runtime_resolution.cpp | 4 ----
   sandbox/chrono/libs/chrono/example/saturating.cpp | 7 ++-----
   sandbox/chrono/libs/chrono/example/simulated_thread_interface_demo.cpp | 9 ++-------
   sandbox/chrono/libs/chrono/example/time2_demo.cpp | 20 +++++++++-----------
   sandbox/chrono/libs/chrono/example/timeval_demo.cpp | 3 ---
   sandbox/chrono/libs/chrono/example/xtime.cpp | 3 ---
   sandbox/chrono/libs/chrono/src/win/chrono.cpp | 2 --
   sandbox/chrono/libs/chrono/test/manipulate_clock_object.cpp | 3 ---
   sandbox/chrono/libs/chrono/test/miscellaneous.cpp | 5 +----
   sandbox/chrono/libs/chrono/test/test_duration.cpp | 2 +-
   sandbox/chrono/libs/chrono/test/test_special_values.cpp | 10 ++++------
   sandbox/chrono/libs/chrono/test/test_system_clock.cpp | 3 ---
   15 files changed, 21 insertions(+), 64 deletions(-)

Modified: sandbox/chrono/libs/chrono/example/cycle_count.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/cycle_count.cpp (original)
+++ sandbox/chrono/libs/chrono/example/cycle_count.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -31,9 +31,6 @@
 
 #include <iostream>
 
-#undef min
-#undef max
-
 using namespace boost::chrono;
 
 

Modified: sandbox/chrono/libs/chrono/example/i_dont_like_the_default_duration_behavior.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/i_dont_like_the_default_duration_behavior.cpp (original)
+++ sandbox/chrono/libs/chrono/example/i_dont_like_the_default_duration_behavior.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -31,10 +31,6 @@
 
 #include <iostream>
 
-#undef min
-#undef max
-
-
 namespace I_dont_like_the_default_duration_behavior
 {
 

Modified: sandbox/chrono/libs/chrono/example/min_time_point.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/min_time_point.cpp (original)
+++ sandbox/chrono/libs/chrono/example/min_time_point.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -31,9 +31,6 @@
 
 #include <iostream>
 
-#undef min
-#undef max
-
 using namespace boost::chrono;
 
 template <class Rep, class Period>
@@ -48,7 +45,7 @@
 inline
 typename boost::common_type<time_point<Clock, Duration1>,
                      time_point<Clock, Duration2> >::type
-min(time_point<Clock, Duration1> t1, time_point<Clock, Duration2> t2)
+min BOOST_PREVENT_MACRO_SUBSTITUTION (time_point<Clock, Duration1> t1, time_point<Clock, Duration2> t2)
 {
     return t2 < t1 ? t2 : t1;
 }
@@ -62,7 +59,7 @@
     typedef boost::common_type<T1, T2>::type T3;
     /*auto*/ T1 t1 = system_clock::now() + seconds(3);
     /*auto*/ T2 t2 = system_clock::now() + nanoseconds(3);
- /*auto*/ T3 t3 = min(t1, t2);
+ /*auto*/ T3 t3 = (min)(t1, t2);
     print_duration(std::cout, t1 - t3);
     print_duration(std::cout, t2 - t3);
 }

Modified: sandbox/chrono/libs/chrono/example/runtime_resolution.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/runtime_resolution.cpp (original)
+++ sandbox/chrono/libs/chrono/example/runtime_resolution.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -61,10 +61,6 @@
 
 #endif
 
-
-//#undef min
-//#undef max
-
 // Handle duration with resolution not known until run time
 using namespace boost::chrono;
 

Modified: sandbox/chrono/libs/chrono/example/saturating.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/saturating.cpp (original)
+++ sandbox/chrono/libs/chrono/example/saturating.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -33,9 +33,6 @@
 
 #include <iostream>
 
-#undef min
-#undef max
-
 //////////////////////////////////////////////////////////
 //////////////////// User2 Example ///////////////////////
 //////////////////////////////////////////////////////////
@@ -423,8 +420,8 @@
     typedef User2::saturate<I> Rep;
 public:
     static Rep zero() {return Rep(0);}
- static Rep max() {return Rep(Rep::pos_inf-1);}
- static Rep min() {return -max();}
+ static Rep max BOOST_PREVENT_MACRO_SUBSTITUTION () {return Rep(Rep::pos_inf-1);}
+ static Rep min BOOST_PREVENT_MACRO_SUBSTITUTION () {return -(max)();}
 };
 
 } // namespace chrono

Modified: sandbox/chrono/libs/chrono/example/simulated_thread_interface_demo.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/simulated_thread_interface_demo.cpp (original)
+++ sandbox/chrono/libs/chrono/example/simulated_thread_interface_demo.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -36,9 +36,6 @@
 #include <stdexcept>
 #include <climits>
 
-#undef min
-#undef max
-
 #if defined(BOOST_CHRONO_WINDOWS_API)
 #include <windows.h>
 
@@ -68,8 +65,6 @@
 
 #endif
 
-#undef min
-#undef max
 
 //////////////////////////////////////////////////////////
 ///////////// simulated thread interface /////////////////
@@ -608,8 +603,8 @@
     typedef User2::saturate<I> Rep;
 public:
     static Rep zero() {return Rep(0);}
- static Rep max() {return Rep(Rep::pos_inf-1);}
- static Rep min() {return -max();}
+ static Rep max BOOST_PREVENT_MACRO_SUBSTITUTION () {return Rep(Rep::pos_inf-1);}
+ static Rep min BOOST_PREVENT_MACRO_SUBSTITUTION () {return -(max)();}
 };
 
 } // namespace chrono

Modified: sandbox/chrono/libs/chrono/example/time2_demo.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/time2_demo.cpp (original)
+++ sandbox/chrono/libs/chrono/example/time2_demo.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -37,8 +37,6 @@
 #include <stdexcept>
 
 #include <windows.h>
-#undef min
-#undef max
 
 namespace
 {
@@ -804,8 +802,8 @@
     typedef User2::saturate<I> Rep;
 public:
     static Rep zero() {return Rep(0);}
- static Rep max() {return Rep(Rep::pos_inf-1);}
- static Rep min() {return -max();}
+ static Rep max BOOST_PREVENT_MACRO_SUBSTITUTION () {return Rep(Rep::pos_inf-1);}
+ static Rep min BOOST_PREVENT_MACRO_SUBSTITUTION () {return -(max) ();}
 };
 
 } // namespace chrono
@@ -1206,7 +1204,7 @@
         boost::chrono::duration<double> dsec = d;
         std::cout << "The precision is " << dsec.count() << " seconds.\n";
     }
- d = Duration(std::numeric_limits<Rep>::max());
+ d = Duration((std::numeric_limits<Rep>::max)());
     using namespace boost::chrono;
     using namespace std;
     typedef duration<double, boost::ratio_multiply<boost::ratio<24*3652425,10000>, hours::period>::type> Years;
@@ -1469,7 +1467,7 @@
 inline
 typename boost::common_type<time_point<Clock, Duration1>,
                      time_point<Clock, Duration2> >::type
-min(time_point<Clock, Duration1> t1, time_point<Clock, Duration2> t2)
+min BOOST_PREVENT_MACRO_SUBSTITUTION (time_point<Clock, Duration1> t1, time_point<Clock, Duration2> t2)
 {
     return t2 < t1 ? t2 : t1;
 }
@@ -1483,7 +1481,7 @@
     typedef boost::common_type<T1, T2>::type T3;
     /*auto*/ T1 t1 = system_clock::now() + seconds(3);
     /*auto*/ T2 t2 = system_clock::now() + nanoseconds(3);
- /*auto*/ T3 t3 = min(t1, t2);
+ /*auto*/ T3 t3 = (min)(t1, t2);
     print_duration(cout, t1 - t3);
     print_duration(cout, t2 - t3);
 }
@@ -1611,12 +1609,12 @@
 
 void test_special_values()
 {
- std::cout << "duration<unsigned>::min().count() = " << duration<unsigned>::min().count() << '\n';
+ std::cout << "duration<unsigned>::min().count() = " << (duration<unsigned>::min()).count() << '\n';
     std::cout << "duration<unsigned>::zero().count() = " << duration<unsigned>::zero().count() << '\n';
- std::cout << "duration<unsigned>::max().count() = " << duration<unsigned>::max().count() << '\n';
- std::cout << "duration<int>::min().count() = " << duration<int>::min().count() << '\n';
+ std::cout << "duration<unsigned>::max().count() = " << (duration<unsigned>::max()).count() << '\n';
+ std::cout << "duration<int>::min().count() = " << (duration<int>::min().count()) << '\n';
     std::cout << "duration<int>::zero().count() = " << duration<int>::zero().count() << '\n';
- std::cout << "duration<int>::max().count() = " << duration<int>::max().count() << '\n';
+ std::cout << "duration<int>::max().count() = " << (duration<int>::max().count()) << '\n';
 }
 
 int main()

Modified: sandbox/chrono/libs/chrono/example/timeval_demo.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/timeval_demo.cpp (original)
+++ sandbox/chrono/libs/chrono/example/timeval_demo.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -35,9 +35,6 @@
 # include <windows.h>
 #endif
 
-#undef min
-#undef max
-
 // timeval clock demo
 // Demonstrate the use of a timeval-like struct to be used as the representation
 // type for both duraiton and time_point.

Modified: sandbox/chrono/libs/chrono/example/xtime.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/xtime.cpp (original)
+++ sandbox/chrono/libs/chrono/example/xtime.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -31,9 +31,6 @@
 
 #include <iostream>
 
-#undef min
-#undef max
-
 using namespace boost::chrono;
 
 // Example round_up utility: converts d to To, rounding up for inexact conversions

Modified: sandbox/chrono/libs/chrono/src/win/chrono.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/src/win/chrono.cpp (original)
+++ sandbox/chrono/libs/chrono/src/win/chrono.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -10,8 +10,6 @@
 //----------------------------------------------------------------------------//
 
 #include <windows.h>
-#undef min
-#undef max
 
 namespace
 {

Modified: sandbox/chrono/libs/chrono/test/manipulate_clock_object.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/manipulate_clock_object.cpp (original)
+++ sandbox/chrono/libs/chrono/test/manipulate_clock_object.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -31,9 +31,6 @@
 
 #include <iostream>
 
-#undef min
-#undef max
-
 using namespace boost::chrono;
 
 

Modified: sandbox/chrono/libs/chrono/test/miscellaneous.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/miscellaneous.cpp (original)
+++ sandbox/chrono/libs/chrono/test/miscellaneous.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -31,9 +31,6 @@
 
 #include <iostream>
 
-#undef min
-#undef max
-
 // miscellaneous tests and demos:
 
 #include <cassert>
@@ -105,7 +102,7 @@
         boost::chrono::duration<double> dsec = d;
         std::cout << "The precision is " << dsec.count() << " seconds.\n";
     }
- d = Duration(std::numeric_limits<Rep>::max());
+ d = Duration((std::numeric_limits<Rep>::max)());
     using namespace boost::chrono;
     using namespace std;
     typedef duration<double, boost::ratio_multiply<boost::ratio<24*3652425,10000>, hours::period>::type> Years;

Modified: sandbox/chrono/libs/chrono/test/test_duration.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/test_duration.cpp (original)
+++ sandbox/chrono/libs/chrono/test/test_duration.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -60,7 +60,7 @@
         boost::chrono::duration<double> dsec = d;
         std::cout << "The precision is " << dsec.count() << " seconds.\n";
     }
- d = Duration(std::numeric_limits<Rep>::max());
+ d = Duration((std::numeric_limits<Rep>::max)());
     using namespace boost::chrono;
     using namespace std;
     typedef duration<double, boost::ratio_multiply<boost::ratio<24*3652425,10000>, hours::period>::type> Years;

Modified: sandbox/chrono/libs/chrono/test/test_special_values.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/test_special_values.cpp (original)
+++ sandbox/chrono/libs/chrono/test/test_special_values.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -31,18 +31,16 @@
 
 #include <iostream>
 
-#undef min
-#undef max
 using namespace boost::chrono;
 
 void test_special_values()
 {
- std::cout << "duration<unsigned>::min().count() = " << duration<unsigned>::min().count() << '\n';
+ std::cout << "duration<unsigned>::min().count() = " << (duration<unsigned>::min()).count() << '\n';
     std::cout << "duration<unsigned>::zero().count() = " << duration<unsigned>::zero().count() << '\n';
- std::cout << "duration<unsigned>::max().count() = " << duration<unsigned>::max().count() << '\n';
- std::cout << "duration<int>::min().count() = " << duration<int>::min().count() << '\n';
+ std::cout << "duration<unsigned>::max().count() = " << (duration<unsigned>::max()).count() << '\n';
+ std::cout << "duration<int>::min().count() = " << (duration<int>::min()).count() << '\n';
     std::cout << "duration<int>::zero().count() = " << duration<int>::zero().count() << '\n';
- std::cout << "duration<int>::max().count() = " << duration<int>::max().count() << '\n';
+ std::cout << "duration<int>::max().count() = " << (duration<int>::max()).count() << '\n';
 }
 
 int main()

Modified: sandbox/chrono/libs/chrono/test/test_system_clock.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/test_system_clock.cpp (original)
+++ sandbox/chrono/libs/chrono/test/test_system_clock.cpp 2009-12-11 03:33:16 EST (Fri, 11 Dec 2009)
@@ -31,9 +31,6 @@
 
 #include <iostream>
 
-#undef min
-#undef max
-
 using namespace boost::chrono;
 
 void test_system_clock()


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