1// (C) Copyright David Abrahams 2002.
2// (C) Copyright Jeremy Siek 2002.
3// (C) Copyright Thomas Witt 2002.
4// Distributed under the Boost Software License, Version 1.0. (See
5// accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7#ifndef BOOST_ENABLE_IF_23022003THW_HPP
8#define BOOST_ENABLE_IF_23022003THW_HPP
9
10#include <boost/config.hpp>
11#include <boost/iterator/detail/config_def.hpp>
12#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_IS_CONVERTIBLE)
13#include <boost/type_traits/type_identity.hpp>
14#endif
15
16//
17// Boost iterators uses its own enable_if cause we need
18// special semantics for deficient compilers.
19// 23/02/03 thw
20//
21
22namespace boost
23{
24
25 namespace iterators
26 {
27 //
28 // Base machinery for all kinds of enable if
29 //
30 template<bool>
31 struct enabled
32 {
33 template<typename T>
34 struct base
35 {
36 typedef T type;
37 };
38 };
39
40 //
41 // For compilers that don't support "Substitution Failure Is Not An Error"
42 // enable_if falls back to always enabled. See comments
43 // on operator implementation for consequences.
44 //
45 template<>
46 struct enabled<false>
47 {
48 template<typename T>
49 struct base
50 {
51#ifdef BOOST_NO_SFINAE
52 typedef T type;
53
54 // This way to do it would give a nice error message containing
55 // invalid overload, but has the big disadvantage that
56 // there is no reference to user code in the error message.
57 //
58 // struct invalid_overload;
59 // typedef invalid_overload type;
60 //
61#endif
62 };
63 };
64
65
66 template <class Cond,
67 class Return>
68 struct enable_if
69# if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_IS_CONVERTIBLE)
70 : enabled<(Cond::value)>::template base<Return>
71# else
72 : boost::type_identity<Return>
73# endif
74 {
75 };
76
77 } // namespace iterators
78
79} // namespace boost
80
81#include <boost/iterator/detail/config_undef.hpp>
82
83#endif // BOOST_ENABLE_IF_23022003THW_HPP
84

source code of boost/libs/iterator/include/boost/iterator/detail/enable_if.hpp