Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 320039 | Differences between
and this patch

Collapse All | Expand All

(-)boost/parameter/aux_/maybe.hpp (-14 / +37 lines)
Lines 2-21 Link Here
2
// subject to the Boost Software License, Version 1.0. (See accompanying
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)
3
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
4
5
#ifndef BOOST_PARAMETER_MAYBE_060211_HPP
5
//
6
# define BOOST_PARAMETER_MAYBE_060211_HPP
6
// 2009.10.21 TDS remove depenency on boost::python::detail::referent_storage
7
//
8
#ifndef BOOST_PARAMETER_MAYBE_091021_HPP
9
# define BOOST_PARAMETER_MAYBE_091021_HPP
7
10
8
# include <boost/mpl/if.hpp>
11
# include <boost/mpl/if.hpp>
9
# include <boost/mpl/identity.hpp>
12
# include <boost/mpl/identity.hpp>
10
# include <boost/type_traits/is_reference.hpp>
13
# include <boost/type_traits/is_reference.hpp>
11
# include <boost/type_traits/add_reference.hpp>
14
# include <boost/type_traits/add_reference.hpp>
12
# include <boost/optional.hpp>
15
# include <boost/optional.hpp>
13
# include <boost/python/detail/referent_storage.hpp>
16
# include <boost/aligned_storage.hpp>
14
# include <boost/type_traits/remove_cv.hpp>
17
# include <boost/type_traits/remove_cv.hpp>
15
# include <boost/type_traits/add_const.hpp>
18
# include <boost/type_traits/add_const.hpp>
16
19
17
namespace boost { namespace parameter { namespace aux {
20
namespace boost { namespace parameter { namespace aux {
18
21
22
template <class T> struct referent_size;
23
24
template <class T>
25
struct referent_size<T&>
26
{
27
  BOOST_STATIC_CONSTANT(std::size_t, value = sizeof(T));
28
};
29
30
// A metafunction returning a POD type which can store U, where T ==
31
// U&. If T is not a reference type, returns a POD which can store T.
32
template <class T>
33
struct referent_storage
34
{
35
  typedef typename boost::aligned_storage<
36
    referent_size<T>::value
37
    >::type type;
38
};
39
19
struct maybe_base {};
40
struct maybe_base {};
20
41
21
template <class T>
42
template <class T>
Lines 33-40 Link Here
33
        BOOST_DEDUCED_TYPENAME remove_reference<reference>::type
54
        BOOST_DEDUCED_TYPENAME remove_reference<reference>::type
34
    >::type non_cv_value;
55
    >::type non_cv_value;
35
        
56
        
36
    explicit maybe(T value)
57
    explicit maybe(T value_)
37
      : value(value)
58
      : value(value_)
38
      , constructed(false)
59
      , constructed(false)
39
    {}
60
    {}
40
61
Lines 48-75 Link Here
48
            this->destroy();
69
            this->destroy();
49
    }
70
    }
50
71
51
    reference construct(reference value) const
72
    reference construct(reference value_) const
52
    {
73
    {
53
        return value;
74
        return value_;
54
    }
75
    }
55
76
56
    template <class U>
77
    template <class U>
57
    reference construct2(U const& value) const
78
    reference construct2(U const& value_) const
58
    {
79
    {
59
        new (m_storage.bytes) non_cv_value(value);
80
        new (m_storage.address()) non_cv_value(value_);
60
        constructed = true;
81
        constructed = true;
61
        return *(non_cv_value*)m_storage.bytes;
82
        return *(non_cv_value*)m_storage.address();
62
    }
83
    }
63
84
64
    template <class U>
85
    template <class U>
65
    reference construct(U const& value) const
86
    reference construct(U const& value_) const
66
    {
87
    {
67
        return this->construct2(value);
88
        return this->construct2(value_);
68
    }
89
    }
69
90
70
    void destroy()
91
    void destroy()
71
    {
92
    {
72
        ((non_cv_value*)m_storage.bytes)->~non_cv_value();
93
        ((non_cv_value*)m_storage.address())->~non_cv_value();
73
    }
94
    }
74
95
75
    typedef reference(maybe<T>::*safe_bool)() const;
96
    typedef reference(maybe<T>::*safe_bool)() const;
Lines 87-93 Link Here
87
private:
108
private:
88
    boost::optional<T> value;
109
    boost::optional<T> value;
89
    mutable bool constructed;
110
    mutable bool constructed;
90
    mutable typename boost::python::detail::referent_storage<
111
112
113
    mutable typename referent_storage<
91
        reference
114
        reference
92
    >::type m_storage;
115
    >::type m_storage;
93
};
116
};

Return to bug 320039