|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65609 - sandbox/opaque/libs/opaque/test
From: vicente.botet_at_[hidden]
Date: 2010-09-26 10:59:49
Author: viboes
Date: 2010-09-26 10:59:44 EDT (Sun, 26 Sep 2010)
New Revision: 65609
URL: http://svn.boost.org/trac/boost/changeset/65609
Log:
Opaque: Check explicit conversion from private OT to UT
Added:
sandbox/opaque/libs/opaque/test/private_opaque_explicit_conversion_fail.cpp (contents, props changed)
Text files modified:
sandbox/opaque/libs/opaque/test/Jamfile.v2 | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
Modified: sandbox/opaque/libs/opaque/test/Jamfile.v2
==============================================================================
--- sandbox/opaque/libs/opaque/test/Jamfile.v2 (original)
+++ sandbox/opaque/libs/opaque/test/Jamfile.v2 2010-09-26 10:59:44 EDT (Sun, 26 Sep 2010)
@@ -54,6 +54,8 @@
test-suite "private"
:
[ run private_opaque_test.cpp ]
+ [ compile-fail private_opaque_explicit_conversion_fail.cpp ]
+
;
test-suite "compile_fail"
Added: sandbox/opaque/libs/opaque/test/private_opaque_explicit_conversion_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/private_opaque_explicit_conversion_fail.cpp 2010-09-26 10:59:44 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+
+BOOST_OPAQUE_PRIVATE_TYPEDEF(int,A);
+
+template <typename T> void f(T v) {}
+
+void public_multiple_levels_fail() {
+
+ A a;
+ #if !defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS)
+ // explicit conversion from OT to UT works in this case so make compile fail
+#error `struct A' used where a `int' was expected
+#else
+ int i;
+ i=int(a);
+ f(i);
+ //error: `OT' used where a `UT' was expected
+#endif
+
+}
+
+
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