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
24namespace boost
25{
26
27 template <bool B, class T = void>
28 struct enable_if_c {
29 typedef T type;
30 };
31
32 template <class T>
33 struct enable_if_c<false, T> {};
34
35 template <class Cond, class T = void>
36 struct enable_if : public enable_if_c<Cond::value, T> {};
37
38 template <bool B, class T>
39 struct lazy_enable_if_c {
40 typedef typename T::type type;
41 };
42
43 template <class T>
44 struct lazy_enable_if_c<false, T> {};
45
46 template <class Cond, class T>
47 struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
48
49
50 template <bool B, class T = void>
51 struct disable_if_c {
52 typedef T type;
53 };
54
55 template <class T>
56 struct disable_if_c<true, T> {};
57
58 template <class Cond, class T = void>
59 struct disable_if : public disable_if_c<Cond::value, T> {};
60
61 template <bool B, class T>
62 struct lazy_disable_if_c {
63 typedef typename T::type type;
64 };
65
66 template <class T>
67 struct lazy_disable_if_c<true, T> {};
68
69 template <class Cond, class T>
70 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
71
72} // namespace boost
73
74#else
75
76namespace boost {
77
78 namespace detail { typedef void enable_if_default_T; }
79
80 template <typename T>
81 struct enable_if_does_not_work_on_this_compiler;
82
83 template <bool B, class T = detail::enable_if_default_T>
84 struct enable_if_c : enable_if_does_not_work_on_this_compiler<T>
85 { };
86
87 template <bool B, class T = detail::enable_if_default_T>
88 struct disable_if_c : enable_if_does_not_work_on_this_compiler<T>
89 { };
90
91 template <bool B, class T = detail::enable_if_default_T>
92 struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler<T>
93 { };
94
95 template <bool B, class T = detail::enable_if_default_T>
96 struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler<T>
97 { };
98
99 template <class Cond, class T = detail::enable_if_default_T>
100 struct enable_if : enable_if_does_not_work_on_this_compiler<T>
101 { };
102
103 template <class Cond, class T = detail::enable_if_default_T>
104 struct disable_if : enable_if_does_not_work_on_this_compiler<T>
105 { };
106
107 template <class Cond, class T = detail::enable_if_default_T>
108 struct lazy_enable_if : enable_if_does_not_work_on_this_compiler<T>
109 { };
110
111 template <class Cond, class T = detail::enable_if_default_T>
112 struct lazy_disable_if : enable_if_does_not_work_on_this_compiler<T>
113 { };
114
115} // namespace boost
116
117#endif // BOOST_NO_SFINAE
118
119#endif
120