1 // Boost enable_if library
3 // Copyright 2003 (c) The Trustees of Indiana University.
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)
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)
14 #ifndef BOOST_CORE_ENABLE_IF_HPP
15 #define BOOST_CORE_ENABLE_IF_HPP
17 #include "boost/config.hpp"
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
22 #ifndef BOOST_NO_SFINAE
26 template<typename T
, typename R
=void>
27 struct enable_if_has_type
32 template <bool B
, class T
= void>
38 struct enable_if_c
<false, T
> {};
40 template <class Cond
, class T
= void>
41 struct enable_if
: public enable_if_c
<Cond::value
, T
> {};
43 template <bool B
, class T
>
44 struct lazy_enable_if_c
{
45 typedef typename
T::type type
;
49 struct lazy_enable_if_c
<false, T
> {};
51 template <class Cond
, class T
>
52 struct lazy_enable_if
: public lazy_enable_if_c
<Cond::value
, T
> {};
55 template <bool B
, class T
= void>
61 struct disable_if_c
<true, T
> {};
63 template <class Cond
, class T
= void>
64 struct disable_if
: public disable_if_c
<Cond::value
, T
> {};
66 template <bool B
, class T
>
67 struct lazy_disable_if_c
{
68 typedef typename
T::type type
;
72 struct lazy_disable_if_c
<true, T
> {};
74 template <class Cond
, class T
>
75 struct lazy_disable_if
: public lazy_disable_if_c
<Cond::value
, T
> {};
83 namespace detail
{ typedef void enable_if_default_T
; }
86 struct enable_if_does_not_work_on_this_compiler
;
88 template<typename T
, typename R
=void>
89 struct enable_if_has_type
: enable_if_does_not_work_on_this_compiler
<T
>
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
>
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
>
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
>
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
>
108 template <class Cond
, class T
= detail::enable_if_default_T
>
109 struct enable_if
: enable_if_does_not_work_on_this_compiler
<T
>
112 template <class Cond
, class T
= detail::enable_if_default_T
>
113 struct disable_if
: enable_if_does_not_work_on_this_compiler
<T
>
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
>
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
>
126 #endif // BOOST_NO_SFINAE