forked from TartanLlama/optional
More constexpr
This commit is contained in:
18
optional.hpp
18
optional.hpp
@@ -284,9 +284,9 @@ namespace tl {
|
|||||||
constexpr optional_storage_base() noexcept
|
constexpr optional_storage_base() noexcept
|
||||||
: m_dummy(), m_has_value(false) {}
|
: m_dummy(), m_has_value(false) {}
|
||||||
|
|
||||||
template <class U>
|
template <class... U>
|
||||||
constexpr optional_storage_base(in_place_t, U&& u) noexcept
|
constexpr optional_storage_base(in_place_t, U&&... u) noexcept
|
||||||
: m_value(std::forward<U>(u)), m_has_value(true) {}
|
: m_value(std::forward<U>(u)...), m_has_value(true) {}
|
||||||
|
|
||||||
~optional_storage_base() {
|
~optional_storage_base() {
|
||||||
if (m_has_value) {
|
if (m_has_value) {
|
||||||
@@ -310,9 +310,9 @@ namespace tl {
|
|||||||
: m_dummy(), m_has_value(false) {}
|
: m_dummy(), m_has_value(false) {}
|
||||||
|
|
||||||
|
|
||||||
template <class U>
|
template <class... U>
|
||||||
constexpr optional_storage_base(in_place_t, U&& u) noexcept
|
constexpr optional_storage_base(in_place_t, U&&... u) noexcept
|
||||||
: m_value(std::forward<U>(u)), m_has_value(true) {}
|
: m_value(std::forward<U>(u)...), m_has_value(true) {}
|
||||||
|
|
||||||
~optional_storage_base() = default;
|
~optional_storage_base() = default;
|
||||||
|
|
||||||
@@ -351,10 +351,8 @@ namespace tl {
|
|||||||
}
|
}
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
constexpr explicit optional(enable_if_t<std::is_constructible<T, Args...>::value, in_place_t>,
|
constexpr explicit optional(enable_if_t<std::is_constructible<T, Args...>::value, in_place_t>,
|
||||||
Args&&... args) {
|
Args&&... args)
|
||||||
this->m_has_value = true;
|
: base(in_place, std::forward<Args>(args)...) {}
|
||||||
new (std::addressof(this->m_value)) T (std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
template <class U, class... Args>
|
template <class U, class... Args>
|
||||||
constexpr explicit optional(
|
constexpr explicit optional(
|
||||||
enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value, in_place_t>,
|
enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value, in_place_t>,
|
||||||
|
Reference in New Issue
Block a user