1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11// <functional>
12//
13// reference_wrapper
14//
15// template <ObjectType T> reference_wrapper<const T> cref(const T& t);
16//
17// where T is an incomplete type (since C++20)
18
19#include <functional>
20#include <cassert>
21
22#include "test_macros.h"
23
24
25struct Foo;
26
27Foo& get_foo();
28
29void test() {
30 Foo const& foo = get_foo();
31 std::reference_wrapper<Foo const> ref = std::cref(foo);
32 assert(&ref.get() == &foo);
33}
34
35struct Foo { };
36
37Foo& get_foo() {
38 static Foo foo;
39 return foo;
40}
41
42int main(int, char**) {
43 test();
44 return 0;
45}
46

source code of libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref.incomplete.pass.cpp