forked from TartanLlama/optional
Fix implementation of optional<T&>::emplace()
This commit is contained in:
@ -1982,15 +1982,12 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Constructs the value in-place, destroying the current one if there is
|
||||
/// one.
|
||||
template <class... Args> T &emplace(Args &&... args) noexcept {
|
||||
static_assert(std::is_constructible<T, Args &&...>::value,
|
||||
"T must be constructible with Args");
|
||||
|
||||
*this = nullopt;
|
||||
this->construct(std::forward<Args>(args)...);
|
||||
return value();
|
||||
/// Rebinds this optional to `u`.
|
||||
template <class U = T,
|
||||
detail::enable_if_t<!detail::is_optional<detail::decay_t<U>>::value>
|
||||
* = nullptr>
|
||||
optional &emplace(U &&u) noexcept {
|
||||
return *this = std::forward<U>(u);
|
||||
}
|
||||
|
||||
void swap(optional &rhs) noexcept { std::swap(m_value, rhs.m_value); }
|
||||
|
Reference in New Issue
Block a user