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/builtin.hpp> |
13 | #include <boost/mpl/vector.hpp> |
14 | #include <boost/mpl/assert.hpp> |
15 | #include <boost/type_traits/is_same.hpp> |
16 | |
17 | using namespace boost::type_erasure; |
18 | namespace mpl = boost::mpl; |
19 | |
20 | template<class T = _self> |
21 | struct common : mpl::vector< |
22 | copy_constructible<T> |
23 | > {}; |
24 | |
25 | template<class T = _self> |
26 | struct concept1 : mpl::vector<copy_constructible<T> > {}; |
27 | |
28 | template<class T = _self> |
29 | struct concept2 : mpl::vector<concept1<T> > {}; |
30 | |
31 | namespace boost { |
32 | namespace type_erasure { |
33 | |
34 | template<class T, class Base> |
35 | struct concept_interface<concept1<T>, Base, T> : Base |
36 | { |
37 | typedef int id_type; |
38 | }; |
39 | |
40 | template<class T, class Base> |
41 | struct concept_interface<concept2<T>, Base, T> : Base |
42 | { |
43 | typedef char id_type; |
44 | }; |
45 | |
46 | } |
47 | } |
48 | |
49 | BOOST_MPL_ASSERT((boost::is_same<any<concept2<> >::id_type, char>)); |
50 | BOOST_MPL_ASSERT((boost::is_same<any<mpl::vector<concept2<>, concept1<> > >::id_type, char>)); |
51 | BOOST_MPL_ASSERT((boost::is_same<any<mpl::vector<concept1<>, concept2<> > >::id_type, char>)); |
52 | |