]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost enable_if library |
2 | ||
3 | // Copyright 2003 (c) The Trustees of Indiana University. | |
4 | ||
5 | // Use, modification, and distribution is subject to the Boost Software | |
6 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) | |
10 | // Jeremiah Willcock (jewillco at osl.iu.edu) | |
11 | // Andrew Lumsdaine (lums at osl.iu.edu) | |
12 | ||
13 | ||
14 | #ifndef BOOST_CORE_ENABLE_IF_HPP | |
15 | #define BOOST_CORE_ENABLE_IF_HPP | |
16 | ||
17 | #include "boost/config.hpp" | |
18 | ||
19 | // Even the definition of enable_if causes problems on some compilers, | |
20 | // so it's macroed out for all compilers that do not support SFINAE | |
21 | ||
22 | #ifndef BOOST_NO_SFINAE | |
23 | ||
24 | namespace boost | |
25 | { | |
26 | template<typename T, typename R=void> | |
27 | struct enable_if_has_type | |
28 | { | |
29 | typedef R type; | |
30 | }; | |
31 | ||
32 | template <bool B, class T = void> | |
33 | struct enable_if_c { | |
34 | typedef T type; | |
35 | }; | |
36 | ||
37 | template <class T> | |
38 | struct enable_if_c<false, T> {}; | |
39 | ||
40 | template <class Cond, class T = void> | |
41 | struct enable_if : public enable_if_c<Cond::value, T> {}; | |
42 | ||
43 | template <bool B, class T> | |
44 | struct lazy_enable_if_c { | |
45 | typedef typename T::type type; | |
46 | }; | |
47 | ||
48 | template <class T> | |
49 | struct lazy_enable_if_c<false, T> {}; | |
50 | ||
51 | template <class Cond, class T> | |
52 | struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {}; | |
53 | ||
54 | ||
55 | template <bool B, class T = void> | |
56 | struct disable_if_c { | |
57 | typedef T type; | |
58 | }; | |
59 | ||
60 | template <class T> | |
61 | struct disable_if_c<true, T> {}; | |
62 | ||
63 | template <class Cond, class T = void> | |
64 | struct disable_if : public disable_if_c<Cond::value, T> {}; | |
65 | ||
66 | template <bool B, class T> | |
67 | struct lazy_disable_if_c { | |
68 | typedef typename T::type type; | |
69 | }; | |
70 | ||
71 | template <class T> | |
72 | struct lazy_disable_if_c<true, T> {}; | |
73 | ||
74 | template <class Cond, class T> | |
75 | struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {}; | |
76 | ||
77 | } // namespace boost | |
78 | ||
79 | #else | |
80 | ||
81 | namespace boost { | |
82 | ||
83 | namespace detail { typedef void enable_if_default_T; } | |
84 | ||
85 | template <typename T> | |
86 | struct enable_if_does_not_work_on_this_compiler; | |
87 | ||
88 | template<typename T, typename R=void> | |
89 | struct enable_if_has_type : enable_if_does_not_work_on_this_compiler<T> | |
90 | { }; | |
91 | ||
92 | template <bool B, class T = detail::enable_if_default_T> | |
93 | struct enable_if_c : enable_if_does_not_work_on_this_compiler<T> | |
94 | { }; | |
95 | ||
96 | template <bool B, class T = detail::enable_if_default_T> | |
97 | struct disable_if_c : enable_if_does_not_work_on_this_compiler<T> | |
98 | { }; | |
99 | ||
100 | template <bool B, class T = detail::enable_if_default_T> | |
101 | struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler<T> | |
102 | { }; | |
103 | ||
104 | template <bool B, class T = detail::enable_if_default_T> | |
105 | struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler<T> | |
106 | { }; | |
107 | ||
108 | template <class Cond, class T = detail::enable_if_default_T> | |
109 | struct enable_if : enable_if_does_not_work_on_this_compiler<T> | |
110 | { }; | |
111 | ||
112 | template <class Cond, class T = detail::enable_if_default_T> | |
113 | struct disable_if : enable_if_does_not_work_on_this_compiler<T> | |
114 | { }; | |
115 | ||
116 | template <class Cond, class T = detail::enable_if_default_T> | |
117 | struct lazy_enable_if : enable_if_does_not_work_on_this_compiler<T> | |
118 | { }; | |
119 | ||
120 | template <class Cond, class T = detail::enable_if_default_T> | |
121 | struct lazy_disable_if : enable_if_does_not_work_on_this_compiler<T> | |
122 | { }; | |
123 | ||
124 | } // namespace boost | |
125 | ||
126 | #endif // BOOST_NO_SFINAE | |
127 | ||
128 | #endif |