]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_erasure/example/convert.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / type_erasure / example / convert.cpp
1 // Boost.TypeErasure library
2 //
3 // Copyright 2012 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/type_erasure/operators.hpp>
14 #include <ostream>
15
16 namespace mpl = boost::mpl;
17 using namespace boost::type_erasure;
18
19 void convert1() {
20 //[convert1
21 /*`
22 An __any can be converted to another __any
23 as long as the conversion is an "upcast."
24 */
25
26 typedef any<
27 mpl::vector<
28 copy_constructible<>,
29 typeid_<>,
30 ostreamable<>
31 >
32 > any_printable;
33 typedef any<
34 mpl::vector<
35 copy_constructible<>,
36 typeid_<>
37 >
38 > common_any;
39 any_printable x(10);
40 common_any y(x);
41
42 /*`
43 This conversion is okay because the requirements of `common_any`
44 are a subset of the requirements of `any_printable`. Conversion
45 in the other direction is illegal.
46
47 ``
48 common_any x(10);
49 any_printable y(x); // error
50 ``
51 */
52 //]
53 }
54
55 //[convert
56 //` (For the source of the examples in this section see
57 //` [@boost:/libs/type_erasure/example/convert.cpp convert.cpp])
58 //` [convert1]
59 //]