@@ -563,10 +563,11 @@ class optional {
563
563
template <class F >
564
564
constexpr auto transform (F&& f) const && {
565
565
using U = std::invoke_result_t <F, const T&>;
566
- static_assert (!std::is_array_v<U>);
567
- static_assert (!std::is_same_v<U, in_place_t >);
568
- static_assert (!std::is_same_v<U, nullopt_t >);
569
- static_assert (std::is_object_v<U> || std::is_reference_v<U>); // / References now allowed
566
+ static_assert (!std::is_array_v<U>, " U must not be an array" );
567
+ static_assert (!std::is_same_v<U, in_place_t >, " U must not be an inplace type" );
568
+ static_assert (!std::is_same_v<U, nullopt_t >, " U must not be nullopt_t type" );
569
+ static_assert (std::is_object_v<U> || std::is_reference_v<U>,
570
+ " U must be either an objecy or a reference" ); // / References now allowed
570
571
return (has_value ()) ? optional<U>{std::invoke (std::forward<F>(f), value_)} : optional<U>{};
571
572
}
572
573
@@ -654,7 +655,7 @@ class optional {
654
655
// / one.
655
656
template <class ... Args>
656
657
constexpr T& emplace (Args&&... args) {
657
- static_assert (std::is_constructible_v<T, Args&&...>);
658
+ static_assert (std::is_constructible_v<T, Args&&...>, " each parameter pack must be constructible to T " );
658
659
*this = nullopt ;
659
660
construct (std::forward<Args>(args)...);
660
661
return value ();
@@ -676,7 +677,7 @@ class optional {
676
677
// / valueless.
677
678
constexpr void swap (optional& rhs) noexcept (std::is_nothrow_move_constructible<T>::value &&
678
679
std::is_nothrow_swappable<T>::value) {
679
- static_assert (std::is_move_constructible_v<T>);
680
+ static_assert (std::is_move_constructible_v<T>, " T must be move-constructible " );
680
681
using std::swap;
681
682
if (has_value ()) {
682
683
if (rhs.has_value ()) {
@@ -1139,7 +1140,7 @@ class optional<T&> {
1139
1140
template <class F >
1140
1141
constexpr optional or_else (F&& f) const {
1141
1142
using U = std::invoke_result_t <F>;
1142
- static_assert (std::is_same_v<std::remove_cvref_t <U>, optional>);
1143
+ static_assert (std::is_same_v<std::remove_cvref_t <U>, optional>, " F must return an optional " );
1143
1144
return has_value () ? *value_ : std::forward<F>(f)();
1144
1145
}
1145
1146
0 commit comments