Skip to content

Commit 6dbbc0a

Browse files
committed
🔧 [expect]
1 parent d0c6975 commit 6dbbc0a

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

mp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ constexpr auto for_each(auto&& fn);
285285
```cpp
286286
/**
287287
* Asserts that condition is satisfied
288-
* - constant evaluation: calls undefined function `failed()`
289-
* - run-time evaluation: #ifndef NDEBUG calls `breakpoint()` otherwise empty call
288+
* - #ifndef NDEBUG calls `breakpoint()` (which is not constexpr) otherwise empty call
290289
*/
291290
constexpr void expect(auto cond) requires requires { bool(cond); };
292291
```
@@ -469,7 +468,6 @@ template<class T> struct meta {
469468
static constexpr auto id = mp::info{gen()};
470469
constexpr auto friend get(info<id>) { return meta{}; }
471470
};
472-
void failed();
473471
} // namespace detail
474472

475473
/**
@@ -598,25 +596,18 @@ constexpr auto for_each(auto&& fn) {
598596

599597
/**
600598
* Asserts that condition is satisfied
601-
* - constant evaluation: calls undefined function `failed()`
602-
* - run-time evaluation: #ifndef NDEBUG calls `breakpoint()` otherwise empty call
599+
* - #ifndef NDEBUG calls `breakpoint()` (which is not constexpr) otherwise empty call
603600
*/
604601
constexpr void expect(auto cond) requires requires { bool(cond); } {
605-
if (__builtin_is_constant_evaluated()) {
602+
#ifndef NDEBUG
606603
if (not cond) {
607-
detail::failed();
604+
#if defined (_MSC_VER)
605+
__debugbreak();
606+
#else
607+
__builtin_trap();
608+
#endif
608609
}
609-
} else {
610-
#ifndef NDEBUG
611-
if (not cond) {
612-
#if defined (_MSC_VER)
613-
__debugbreak();
614-
#else
615-
__builtin_trap();
616-
#endif
617-
}
618-
#endif
619-
}
610+
#endif
620611
}
621612
} // namespace mp
622613

0 commit comments

Comments
 (0)