source: NonGTP/Boost/boost/python/detail/if_else.hpp @ 857

Revision 857, 2.3 KB checked in by igarcia, 19 years ago (diff)
Line 
1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef IF_ELSE_DWA2002322_HPP
6# define IF_ELSE_DWA2002322_HPP
7# include <boost/config.hpp>
8
9namespace boost { namespace python { namespace detail {
10
11template <class T> struct elif_selected;
12
13template <class T>
14struct if_selected
15{
16    template <bool b>
17    struct elif : elif_selected<T>
18    {
19    };
20
21    template <class U>
22    struct else_
23    {
24        typedef T type;
25    };
26};
27
28# if defined(BOOST_MSVC) && (BOOST_MSVC == 1300)
29namespace msvc70_aux {
30
31template< bool > struct inherit_from
32{
33    template< typename T > struct result
34    {
35        typedef T type;
36    };
37};
38
39template<> struct inherit_from<true>
40{
41    template< typename T > struct result
42    {
43        struct type {};
44    };
45};
46
47template< typename T >
48struct never_true
49{
50    BOOST_STATIC_CONSTANT(bool, value = false);
51};
52
53} // namespace msvc70_aux
54
55#endif // # if defined(BOOST_MSVC) && (BOOST_MSVC == 1300)
56
57template <class T>
58struct elif_selected
59{
60# if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__MWERKS__) && __MWERKS__ <= 0x2407)
61    template <class U> class then;
62# elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300)
63    template <class U>
64    struct then : msvc70_aux::inherit_from< msvc70_aux::never_true<U>::value >
65        ::template result< if_selected<T> >::type
66    {
67    };
68# else
69    template <class U>
70    struct then : if_selected<T>
71    {
72    };
73# endif
74};
75
76# if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__MWERKS__) && __MWERKS__ <= 0x2407)
77template <class T>
78template <class U>
79class elif_selected<T>::then : public if_selected<T>
80{
81};
82# endif
83
84template <bool b> struct if_
85{
86    template <class T>
87    struct then : if_selected<T>
88    {
89    };
90};
91
92struct if_unselected
93{
94    template <bool b> struct elif : if_<b>
95    {
96    };
97
98    template <class U>
99    struct else_
100    {
101        typedef U type;
102    };
103};
104
105template <>
106struct if_<false>
107{
108    template <class T>
109    struct then : if_unselected
110    {
111    };
112};
113
114}}} // namespace boost::python::detail
115
116#endif // IF_ELSE_DWA2002322_HPP
Note: See TracBrowser for help on using the repository browser.