1 // This header intentionally has no include guards.
3 // Copyright (c) 2010 Neil Groves
4 // Distributed under the Boost Software License, Version 1.0.
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // This code utilises the experience gained during the evolution of
9 // <boost/smart_ptr/operator_bool.hpp>
10 #ifndef BOOST_RANGE_SAFE_BOOL_INCLUDED_HPP
11 #define BOOST_RANGE_SAFE_BOOL_INCLUDED_HPP
13 #include <boost/config.hpp>
14 #include <boost/range/config.hpp>
18 namespace range_detail
21 template<class DataMemberPtr>
25 typedef safe_bool this_type;
27 #if (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570)) || defined(__CINT_)
28 typedef bool unspecified_bool_type;
29 static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
33 #elif defined(_MANAGED)
34 static void unspecified_bool(this_type***)
37 typedef void(*unspecified_bool_type)(this_type***);
38 static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
40 return x ? unspecified_bool : 0;
43 ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
44 ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
45 ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
47 typedef bool (this_type::*unspecified_bool_type)() const;
49 static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
51 return x ? &this_type::detail_safe_bool_member_fn : 0;
54 bool detail_safe_bool_member_fn() const { return false; }
56 typedef DataMemberPtr unspecified_bool_type;
57 static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr p)
64 safe_bool(const safe_bool&);
65 void operator=(const safe_bool&);
69 } // namespace range_detail
72 #endif // include guard