Skip to content

Commit

Permalink
Simplify sol::optional<T&>::emplace
Browse files Browse the repository at this point in the history
  • Loading branch information
cuavas committed Nov 17, 2024
1 parent 2b0d2fe commit c9f7c08
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions include/sol/optional_implementation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2186,12 +2186,8 @@ namespace sol {
/// one.
///
/// \group emplace
template <class... Args>
T& emplace(Args&&... args) noexcept {
static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args");

*this = nullopt;
new (static_cast<void*>(this)) optional(std::in_place, std::forward<Args>(args)...);
T& emplace(T& arg) noexcept {
m_value = &arg;
return **this;
}

Expand Down

0 comments on commit c9f7c08

Please sign in to comment.