1 | // Boost.TypeErasure library |
---|---|
2 | // |
3 | // Copyright 2011 Steven Watanabe |
4 | // |
5 | // Distributed under the Boost Software License Version 1.0. (See |
6 | // accompanying file LICENSE_1_0.txt or copy at |
7 | // http://www.boost.org/LICENSE_1_0.txt) |
8 | // |
9 | // $Id$ |
10 | |
11 | #include <boost/type_erasure/any.hpp> |
12 | #include <boost/type_erasure/tuple.hpp> |
13 | #include <boost/type_erasure/builtin.hpp> |
14 | #include <boost/type_erasure/operators.hpp> |
15 | #include <boost/type_erasure/any_cast.hpp> |
16 | #include <boost/mpl/vector.hpp> |
17 | |
18 | #define BOOST_TEST_MAIN |
19 | #include <boost/test/unit_test.hpp> |
20 | |
21 | using namespace boost::type_erasure; |
22 | |
23 | template<class T = _self> |
24 | struct common : ::boost::mpl::vector< |
25 | copy_constructible<T>, |
26 | relaxed |
27 | > {}; |
28 | |
29 | BOOST_AUTO_TEST_CASE(test_typeid) { |
30 | any<common<> > val; |
31 | BOOST_CHECK(typeid_of(val) == typeid(void)); |
32 | } |
33 | |
34 | BOOST_AUTO_TEST_CASE(test_any_cast) { |
35 | any<common<> > val; |
36 | BOOST_CHECK_EQUAL(any_cast<void*>(&val), (void*)0); |
37 | BOOST_CHECK_EQUAL(any_cast<int*>(&val), (int*)0); |
38 | } |
39 | |
40 | BOOST_AUTO_TEST_CASE(test_copy) { |
41 | any<common<> > val; |
42 | any<common<> > val2(val); |
43 | BOOST_CHECK(typeid_of(val2) == typeid(void)); |
44 | } |
45 |