Skip to content

Commit 5cfd81d

Browse files
committed
Test exception propagation
1 parent 4689f86 commit 5cfd81d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

libcxx/test/std/utilities/function.objects/func.bind.partial/bind_front.nttp.pass.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <type_traits>
2222
#include <utility>
2323

24+
#include "test_macros.h"
2425
#include "types.h"
2526

2627
constexpr void test_basic_bindings() {
@@ -343,6 +344,23 @@ constexpr void test_return_type() {
343344
static_assert(!noexcept(never_noexcept()));
344345
}
345346

347+
#ifndef TEST_HAS_NO_EXCEPTIONS
348+
# ifndef __cpp_constexpr_exceptions
349+
if !consteval
350+
# endif
351+
{ // Test exception propagation
352+
auto throws = [](int x, int y) { throw x + y; };
353+
auto f = std::bind_front<throws>(10);
354+
static_assert(!noexcept(f(20)));
355+
356+
try {
357+
f(20);
358+
} catch (int z) {
359+
assert(z == 30);
360+
}
361+
}
362+
#endif // TEST_HAS_NO_EXCEPTIONS
363+
346364
{ // Test calling volatile wrapper -- we allow it as an extension
347365
using Fn = decltype(std::bind_front<std::integral_constant<int, 0>{}>());
348366
static_assert(std::invocable<volatile Fn&>);

0 commit comments

Comments
 (0)