Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59010 - sandbox/chrono/libs/chrono/test
From: vicente.botet_at_[hidden]
Date: 2010-01-14 17:16:26


Author: viboes
Date: 2010-01-14 17:16:26 EST (Thu, 14 Jan 2010)
New Revision: 59010
URL: http://svn.boost.org/trac/boost/changeset/59010

Log:
Boost.Chrono: Version 0.3.0,
* Added common_type test
Added:
   sandbox/chrono/libs/chrono/test/common_type_test.cpp (contents, props changed)
Text files modified:
   sandbox/chrono/libs/chrono/test/Jamfile.v2 | 8 ++++----
   1 files changed, 4 insertions(+), 4 deletions(-)

Modified: sandbox/chrono/libs/chrono/test/Jamfile.v2
==============================================================================
--- sandbox/chrono/libs/chrono/test/Jamfile.v2 (original)
+++ sandbox/chrono/libs/chrono/test/Jamfile.v2 2010-01-14 17:16:26 EST (Thu, 14 Jan 2010)
@@ -28,10 +28,10 @@
         <toolset>msvc:<asynch-exceptions>on
     ;
 
-# test-suite "common_type"
-# :
-# [ run ../example/run_timer_example.cpp ]
-# ;
+ test-suite "common_type"
+ :
+ [ run common_type_test.cpp ]
+ ;
 
     test-suite "ratio"
         :

Added: sandbox/chrono/libs/chrono/test/common_type_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/common_type_test.cpp 2010-01-14 17:16:26 EST (Thu, 14 Jan 2010)
@@ -0,0 +1,56 @@
+// common_type_test.cpp ----------------------------------------------------//
+
+// Copyright 2010 Beman Dawes
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define _CRT_SECURE_NO_WARNINGS // disable VC++ foolishness
+
+#include <boost/type_traits/common_type.hpp>
+#include <iostream>
+
+struct A {};
+
+struct B {};
+
+struct C {
+ C() {}
+ C(A const&) {}
+ C(B const&) {}
+ C& operator=(C const&) {
+ return *this;
+ }
+};
+
+typedef boost::common_type<A, C>::type AC;
+typedef boost::common_type<B, C>::type BC;
+
+#if 0
+typedef boost::common_type<A, B, C>::type ABC; // DO not compile
+#else
+typedef boost::common_type<C, B, A>::type ABC;
+#endif
+void f(ABC const& rhs) {}
+
+int main()
+{
+ A a;
+ B b;
+ C c;
+ AC ac;
+ ac=a;
+ ac=c;
+
+ ABC abc;
+ c=b;
+ c=a;
+ abc=a;
+ abc=b;
+ abc=c;
+ f(abc);
+ f(a);
+ f(b);
+ f(c);
+ return 0;
+}


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