1
// Copyright Daniel Wallin 2006. Use, modification and distribution is
2
// subject to the Boost Software License, Version 1.0. (See accompanying
3
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
#ifndef BOOST_PARAMETER_MAYBE_060211_HPP
6
# define BOOST_PARAMETER_MAYBE_060211_HPP
8
# include <boost/mpl/if.hpp>
9
# include <boost/mpl/identity.hpp>
10
# include <boost/type_traits/is_reference.hpp>
11
# include <boost/type_traits/add_reference.hpp>
12
# include <boost/optional.hpp>
13
# include <boost/python/detail/referent_storage.hpp>
14
# include <boost/type_traits/remove_cv.hpp>
15
# include <boost/type_traits/add_const.hpp>
17
namespace boost { namespace parameter { namespace aux {
22
struct maybe : maybe_base
24
typedef typename add_reference<
25
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
28
typename add_const<T>::type
32
typedef typename remove_cv<
33
BOOST_DEDUCED_TYPENAME remove_reference<reference>::type
36
explicit maybe(T value)
51
reference construct(reference value) const
57
reference construct2(U const& value) const
59
new (m_storage.bytes) non_cv_value(value);
61
return *(non_cv_value*)m_storage.bytes;
65
reference construct(U const& value) const
67
return this->construct2(value);
72
((non_cv_value*)m_storage.bytes)->~non_cv_value();
75
typedef reference(maybe<T>::*safe_bool)() const;
77
operator safe_bool() const
79
return value ? &maybe<T>::get : 0 ;
88
boost::optional<T> value;
89
mutable bool constructed;
90
mutable typename boost::python::detail::referent_storage<
95
}}} // namespace boost::parameter::aux
97
#endif // BOOST_PARAMETER_MAYBE_060211_HPP