constructor to be constexpr. This only works when the contained type has a constexpr copy/move ctor.
llvm-svn: 303268
public:
_LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
- _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
- _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default;
+ _LIBCPP_INLINE_VISIBILITY constexpr optional(const optional&) = default;
+ _LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default;
_LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
template <class... _Args, class = enable_if_t<
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <optional>
-// optional(const optional<T>& rhs);
+// constexpr optional(const optional<T>& rhs);
#include <optional>
#include <type_traits>
{
test_reference_extension();
}
+ {
+ constexpr std::optional<int> o1{4};
+ constexpr std::optional<int> o2 = o1;
+ static_assert( *o2 == 4, "" );
+ }
}
// <optional>
-// optional(optional<T>&& rhs);
+// constexpr optional(optional<T>&& rhs);
#include <optional>
#include <type_traits>
{
test_reference_extension();
}
+ {
+ constexpr std::optional<int> o1{4};
+ constexpr std::optional<int> o2 = std::move(o1);
+ static_assert( *o2 == 4, "" );
+ }
}