Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions libcxx/include/__type_traits/invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD

#if __has_builtin(__builtin_invoke)

template <class... _Args>
using __invoke_result_t _LIBCPP_NODEBUG = decltype(__builtin_invoke(std::declval<_Args>()...));

template <class, class... _Args>
struct __invoke_result_impl {};

template <class... _Args>
struct __invoke_result_impl<__void_t<__invoke_result_t<_Args...> >, _Args...> {
using type _LIBCPP_NODEBUG = __invoke_result_t<_Args...>;
struct __invoke_result_impl<__void_t<decltype(__builtin_invoke(std::declval<_Args>()...))>, _Args...> {
using type _LIBCPP_NODEBUG = decltype(__builtin_invoke(std::declval<_Args>()...));
};

template <class... _Args>
using __invoke_result _LIBCPP_NODEBUG = __invoke_result_impl<void, _Args...>;

template <class... _Args>
using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Args...>::type;

template <class... _Args>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __invoke_result_t<_Args...> __invoke(_Args&&... __args)
_NOEXCEPT_(noexcept(__builtin_invoke(std::forward<_Args>(__args)...))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,28 @@ void test_vector_bool() {
assert(std::get<0>(v) == true);
}

struct ConvertibleFromAny {
template <class V>
ConvertibleFromAny(V) {}
};

int main(int, char**) {
test_T_ctor_basic();
test_T_ctor_noexcept();
test_T_ctor_sfinae();
test_no_narrowing_check_for_class_types();
test_construction_with_repeated_types();
test_vector_bool();

{ // Check that the constraints are evaluated lazily (see https://github.com/llvm/llvm-project/issues/151328)
struct Matcher {
Matcher() {}
Matcher(std::variant<ConvertibleFromAny>) {}
};

Matcher vec;
[[maybe_unused]] Matcher m = std::move(vec);
}

return 0;
}
Loading