1 | // (C) Copyright Jonathan Turkanis 2003. |
---|
2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) |
---|
4 | |
---|
5 | // See http://www.boost.org/libs/iostreams for documentation. |
---|
6 | |
---|
7 | // Contains the metafunction select, which mimics the effect of a chain of |
---|
8 | // nested mpl if_'s. |
---|
9 | // |
---|
10 | // ----------------------------------------------------------------------------- |
---|
11 | // |
---|
12 | // Usage: |
---|
13 | // |
---|
14 | // typedef typename select< |
---|
15 | // case1, type1, |
---|
16 | // case2, type2, |
---|
17 | // ... |
---|
18 | // true_, typen |
---|
19 | // >::type selection; |
---|
20 | // |
---|
21 | // Here case1, case2, ... are models of MPL::IntegralConstant with value type |
---|
22 | // bool, and n <= 10. |
---|
23 | |
---|
24 | #ifndef BOOST_IOSTREAMS_SELECT_HPP_INCLUDED |
---|
25 | #define BOOST_IOSTREAMS_SELECT_HPP_INCLUDED |
---|
26 | |
---|
27 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
---|
28 | # pragma once |
---|
29 | #endif |
---|
30 | |
---|
31 | #include <boost/type_traits/is_base_and_derived.hpp> |
---|
32 | #include <boost/mpl/eval_if.hpp> |
---|
33 | #include <boost/mpl/identity.hpp> |
---|
34 | #include <boost/mpl/if.hpp> |
---|
35 | #include <boost/mpl/void.hpp> |
---|
36 | |
---|
37 | namespace boost { namespace iostreams { |
---|
38 | |
---|
39 | typedef mpl::true_ else_; |
---|
40 | |
---|
41 | template< typename Case1 = mpl::true_, |
---|
42 | typename Type1 = mpl::void_, |
---|
43 | typename Case2 = mpl::true_, |
---|
44 | typename Type2 = mpl::void_, |
---|
45 | typename Case3 = mpl::true_, |
---|
46 | typename Type3 = mpl::void_, |
---|
47 | typename Case4 = mpl::true_, |
---|
48 | typename Type4 = mpl::void_, |
---|
49 | typename Case5 = mpl::true_, |
---|
50 | typename Type5 = mpl::void_, |
---|
51 | typename Case6 = mpl::true_, |
---|
52 | typename Type6 = mpl::void_, |
---|
53 | typename Case7 = mpl::true_, |
---|
54 | typename Type7 = mpl::void_, |
---|
55 | typename Case8 = mpl::true_, |
---|
56 | typename Type8 = mpl::void_, |
---|
57 | typename Case9 = mpl::true_, |
---|
58 | typename Type9 = mpl::void_, |
---|
59 | typename Case10 = mpl::true_, |
---|
60 | typename Type10 = mpl::void_ > |
---|
61 | struct select { |
---|
62 | typedef typename |
---|
63 | mpl::eval_if< |
---|
64 | Case1, mpl::identity<Type1>, mpl::eval_if< |
---|
65 | Case2, mpl::identity<Type2>, mpl::eval_if< |
---|
66 | Case3, mpl::identity<Type3>, mpl::eval_if< |
---|
67 | Case4, mpl::identity<Type4>, mpl::eval_if< |
---|
68 | Case5, mpl::identity<Type5>, mpl::eval_if< |
---|
69 | Case6, mpl::identity<Type6>, mpl::eval_if< |
---|
70 | Case7, mpl::identity<Type7>, mpl::eval_if< |
---|
71 | Case8, mpl::identity<Type8>, mpl::eval_if< |
---|
72 | Case9, mpl::identity<Type9>, mpl::if_< |
---|
73 | Case10, Type10, mpl::void_ > > > > > > > > > |
---|
74 | >::type type; |
---|
75 | }; |
---|
76 | |
---|
77 | } } // End namespaces iostreams, boost. |
---|
78 | |
---|
79 | #endif // #ifndef BOOST_IOSTREAMS_SELECT_HPP_INCLUDED |
---|