1*87cc95a9SLouis Dionne //===----------------------------------------------------------------------===//
2*87cc95a9SLouis Dionne //
3*87cc95a9SLouis Dionne // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*87cc95a9SLouis Dionne // See https://llvm.org/LICENSE.txt for license information.
5*87cc95a9SLouis Dionne // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*87cc95a9SLouis Dionne //
7*87cc95a9SLouis Dionne //===----------------------------------------------------------------------===//
8*87cc95a9SLouis Dionne
9*87cc95a9SLouis Dionne // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10*87cc95a9SLouis Dionne
11*87cc95a9SLouis Dionne // <functional>
12*87cc95a9SLouis Dionne
13*87cc95a9SLouis Dionne // template<class R, class F, class... Args>
14*87cc95a9SLouis Dionne // constexpr R invoke_r(F&& f, Args&&... args) // C++23
15*87cc95a9SLouis Dionne // noexcept(is_nothrow_invocable_r_v<R, F, Args...>);
16*87cc95a9SLouis Dionne //
17*87cc95a9SLouis Dionne // Make sure that we diagnose when std::invoke_r is used with a return type that
18*87cc95a9SLouis Dionne // would yield a dangling reference to a temporary.
19*87cc95a9SLouis Dionne
20*87cc95a9SLouis Dionne // TODO: We currently can't diagnose because we don't implement reference_converts_from_temporary.
21*87cc95a9SLouis Dionne // XFAIL: *
22*87cc95a9SLouis Dionne
23*87cc95a9SLouis Dionne #include <functional>
24*87cc95a9SLouis Dionne #include <cassert>
25*87cc95a9SLouis Dionne
26*87cc95a9SLouis Dionne #include "test_macros.h"
27*87cc95a9SLouis Dionne
f()28*87cc95a9SLouis Dionne void f() {
29*87cc95a9SLouis Dionne auto func = []() -> int { return 0; };
30*87cc95a9SLouis Dionne std::invoke_r<int&&>(func); // expected-error {{Returning from invoke_r would bind a temporary object}}
31*87cc95a9SLouis Dionne }
32