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