Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54481 - sandbox/monotonic/libs/monotonic/test/clones
From: christian.schladetsch_at_[hidden]
Date: 2009-06-28 18:30:58


Author: cschladetsch
Date: 2009-06-28 18:30:58 EDT (Sun, 28 Jun 2009)
New Revision: 54481
URL: http://svn.boost.org/trac/boost/changeset/54481

Log:
added test_any
Text files modified:
   sandbox/monotonic/libs/monotonic/test/clones/tests.cpp | 18 ++++++++++++++++++
   1 files changed, 18 insertions(+), 0 deletions(-)

Modified: sandbox/monotonic/libs/monotonic/test/clones/tests.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/clones/tests.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/clones/tests.cpp 2009-06-28 18:30:58 EDT (Sun, 28 Jun 2009)
@@ -10,6 +10,7 @@
 #include <iostream>
 #include <boost/heterogenous/vector.hpp>
 #include <boost/bind.hpp>
+#include <boost/any.hpp>
 
 using namespace std;
 using namespace boost;
@@ -58,8 +59,12 @@
 {
 };
 
+void test_any();
+
 int main()
 {
+ test_any();
+
         // a 'heterogenous' container of objects of any type that derives from common_base
         typedef heterogenous::vector<> vec;
 
@@ -116,4 +121,17 @@
         return 0;
 }
 
+void test_any()
+{
+ typedef std::vector<any, monotonic::allocator<any> > vec;
+ vec v;
+ v.push_back(derived(42));
+ v.push_back(derived2("foo"));
+
+ // this works, but doesn't use the correct allocator
+ vec v2 = v;
+
+ BOOST_ASSERT(any_cast<derived2 &>(v2[1]).str == "foo");
+}
+
 //EOF


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