Skip to content

Commit 7a0f5e3

Browse files
committed
Work around clang bug
1 parent 9219f90 commit 7a0f5e3

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

source/bounded/construct_at.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,21 @@ constexpr auto is_noexcept_construct_at = noexcept(static_cast<T>(declval<Functi
5252
template<typename T, typename Function> requires is_no_lazy_construction<std::invoke_result_t<Function>>
5353
constexpr auto is_noexcept_construct_at<T, Function> = noexcept(static_cast<T>(declval<Function>()().value));
5454

55-
export constexpr auto construct_at = []<non_const T, construct_function_for<T> Function>(T & ref, Function && function) noexcept(is_noexcept_construct_at<T, Function>) -> T & {
56-
auto make = [&] {
57-
if constexpr (is_no_lazy_construction<std::invoke_result_t<Function>>) {
58-
return OPERATORS_FORWARD(function)().value;
59-
} else {
60-
return superconstructing_super_elider<T, Function &&>(OPERATORS_FORWARD(function));
61-
}
62-
};
63-
return *std::construct_at(std::addressof(ref), make());
55+
// https://github.com/llvm/llvm-project/issues/59513
56+
struct construct_at_t {
57+
template<non_const T, construct_function_for<T> Function>
58+
static constexpr auto operator()(T & ref, Function && function) noexcept(is_noexcept_construct_at<T, Function>) -> T & {
59+
auto make = [&] {
60+
if constexpr (is_no_lazy_construction<std::invoke_result_t<Function>>) {
61+
return OPERATORS_FORWARD(function)().value;
62+
} else {
63+
return superconstructing_super_elider<T, Function &&>(OPERATORS_FORWARD(function));
64+
}
65+
};
66+
return *std::construct_at(std::addressof(ref), make());
67+
}
6468
};
69+
export constexpr auto construct_at = construct_at_t();
6570

6671
} // namespace bounded
6772

0 commit comments

Comments
 (0)