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