1 // Boost enable_if library
\r
3 // Copyright 2003 (c) The Trustees of Indiana University.
\r
5 // Use, modification, and distribution is subject to the Boost Software
\r
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
\r
7 // http://www.boost.org/LICENSE_1_0.txt)
\r
9 // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
\r
10 // Jeremiah Willcock (jewillco at osl.iu.edu)
\r
11 // Andrew Lumsdaine (lums at osl.iu.edu)
\r
14 #ifndef BOOST_UTILITY_ENABLE_IF_HPP
\r
15 #define BOOST_UTILITY_ENABLE_IF_HPP
\r
17 #include "boost/config.hpp"
\r
19 // Even the definition of enable_if causes problems on some compilers,
\r
20 // so it's macroed out for all compilers that do not support SFINAE
\r
22 #ifndef BOOST_NO_SFINAE
\r
27 template <bool B, class T = void>
\r
28 struct enable_if_c {
\r
33 struct enable_if_c<false, T> {};
\r
35 template <class Cond, class T = void>
\r
36 struct enable_if : public enable_if_c<Cond::value, T> {};
\r
38 template <bool B, class T>
\r
39 struct lazy_enable_if_c {
\r
40 typedef typename T::type type;
\r
44 struct lazy_enable_if_c<false, T> {};
\r
46 template <class Cond, class T>
\r
47 struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
\r
50 template <bool B, class T = void>
\r
51 struct disable_if_c {
\r
56 struct disable_if_c<true, T> {};
\r
58 template <class Cond, class T = void>
\r
59 struct disable_if : public disable_if_c<Cond::value, T> {};
\r
61 template <bool B, class T>
\r
62 struct lazy_disable_if_c {
\r
63 typedef typename T::type type;
\r
67 struct lazy_disable_if_c<true, T> {};
\r
69 template <class Cond, class T>
\r
70 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
\r
72 } // namespace boost
\r
78 namespace detail { typedef void enable_if_default_T; }
\r
80 template <typename T>
\r
81 struct enable_if_does_not_work_on_this_compiler;
\r
83 template <bool B, class T = detail::enable_if_default_T>
\r
84 struct enable_if_c : enable_if_does_not_work_on_this_compiler<T>
\r
87 template <bool B, class T = detail::enable_if_default_T>
\r
88 struct disable_if_c : enable_if_does_not_work_on_this_compiler<T>
\r
91 template <bool B, class T = detail::enable_if_default_T>
\r
92 struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler<T>
\r
95 template <bool B, class T = detail::enable_if_default_T>
\r
96 struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler<T>
\r
99 template <class Cond, class T = detail::enable_if_default_T>
\r
100 struct enable_if : enable_if_does_not_work_on_this_compiler<T>
\r
103 template <class Cond, class T = detail::enable_if_default_T>
\r
104 struct disable_if : enable_if_does_not_work_on_this_compiler<T>
\r
107 template <class Cond, class T = detail::enable_if_default_T>
\r
108 struct lazy_enable_if : enable_if_does_not_work_on_this_compiler<T>
\r
111 template <class Cond, class T = detail::enable_if_default_T>
\r
112 struct lazy_disable_if : enable_if_does_not_work_on_this_compiler<T>
\r
115 } // namespace boost
\r
117 #endif // BOOST_NO_SFINAE
\r