@@ -14,6 +14,7 @@ Distributed under the Boost Software License, Version 1.0.
14
14
15
15
#include < boost/hana/bool.hpp>
16
16
#include < boost/hana/core/tag_of.hpp>
17
+ #include < boost/hana/detail/as_container_element.hpp>
17
18
#include < boost/hana/detail/operators/adl.hpp>
18
19
#include < boost/hana/detail/operators/comparable.hpp>
19
20
#include < boost/hana/detail/operators/monad.hpp>
@@ -58,6 +59,9 @@ namespace boost { namespace hana {
58
59
constexpr optional (optional const &) = default;
59
60
constexpr optional (optional&&) = default;
60
61
62
+ template <typename U = T, typename = typename std::enable_if<
63
+ !std::is_reference<U>::value
64
+ >::type>
61
65
constexpr optional (T const & t)
62
66
: value_(t)
63
67
{ }
@@ -71,8 +75,15 @@ namespace boost { namespace hana {
71
75
constexpr optional& operator =(optional&&) = default ;
72
76
73
77
// 5.3.5, Observers
74
- constexpr T const * operator ->() const { return &value_; }
75
- constexpr T* operator ->() { return &value_; }
78
+ template <typename U = T, typename = typename std::enable_if<
79
+ !std::is_reference<U>::value
80
+ >::type>
81
+ constexpr U const * operator ->() const { return &value_; }
82
+
83
+ template <typename U = T, typename = typename std::enable_if<
84
+ !std::is_reference<U>::value
85
+ >::type>
86
+ constexpr U* operator ->() { return &value_; }
76
87
77
88
constexpr T& value () & { return value_; }
78
89
constexpr T const & value () const & { return value_; }
@@ -114,7 +125,7 @@ namespace boost { namespace hana {
114
125
115
126
template <typename T>
116
127
constexpr auto make_just_t::operator ()(T&& t) const {
117
- return optional<typename std::decay <T>::type >(
128
+ return optional<detail:: as_container_element_t <T>>(
118
129
static_cast <T&&>(t)
119
130
);
120
131
}
0 commit comments