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