forked from boostorg/optional
Adds forwarding make_optional helpers, resolves #30
This commit is contained in:
committed by
Andrzej Krzemienski
parent
e9f5641be3
commit
c695be11b5
@ -1276,6 +1276,25 @@ class optional<T&&>
|
|||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
|
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline
|
||||||
|
optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type> make_optional ( T && v )
|
||||||
|
{
|
||||||
|
return optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type>(boost::forward<T>(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns optional<T>(cond,v)
|
||||||
|
template<class T>
|
||||||
|
inline
|
||||||
|
optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type> make_optional ( bool cond, T && v )
|
||||||
|
{
|
||||||
|
return optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type>(cond,boost::forward<T>(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
// Returns optional<T>(v)
|
// Returns optional<T>(v)
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
@ -1292,6 +1311,8 @@ optional<T> make_optional ( bool cond, T const& v )
|
|||||||
return optional<T>(cond,v);
|
return optional<T>(cond,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||||
|
|
||||||
// Returns a reference to the value if this is initialized, otherwise, the behaviour is UNDEFINED.
|
// Returns a reference to the value if this is initialized, otherwise, the behaviour is UNDEFINED.
|
||||||
// No-throw
|
// No-throw
|
||||||
template<class T>
|
template<class T>
|
||||||
|
Reference in New Issue
Block a user