Skip to content

Commit 94bff02

Browse files
more messages
1 parent 0c61219 commit 94bff02

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

include/beman/optional26/optional.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,11 @@ class optional {
563563
template <class F>
564564
constexpr auto transform(F&& f) const&& {
565565
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
570571
return (has_value()) ? optional<U>{std::invoke(std::forward<F>(f), value_)} : optional<U>{};
571572
}
572573

@@ -654,7 +655,7 @@ class optional {
654655
/// one.
655656
template <class... Args>
656657
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");
658659
*this = nullopt;
659660
construct(std::forward<Args>(args)...);
660661
return value();
@@ -676,7 +677,7 @@ class optional {
676677
/// valueless.
677678
constexpr void swap(optional& rhs) noexcept(std::is_nothrow_move_constructible<T>::value &&
678679
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");
680681
using std::swap;
681682
if (has_value()) {
682683
if (rhs.has_value()) {
@@ -1139,7 +1140,7 @@ class optional<T&> {
11391140
template <class F>
11401141
constexpr optional or_else(F&& f) const {
11411142
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");
11431144
return has_value() ? *value_ : std::forward<F>(f)();
11441145
}
11451146

0 commit comments

Comments
 (0)