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// <functional>
10
11// reference_wrapper
12
13// reference_wrapper(const reference_wrapper<T>& x);
14
15#include <functional>
16#include <cassert>
17
18#include "test_macros.h"
19
20class functor1
21{
22};
23
24template <class T>
25void
26test(T& t)
27{
28 std::reference_wrapper<T> r(t);
29 std::reference_wrapper<T> r2 = r;
30 assert(&r2.get() == &t);
31}
32
33void f() {}
34
35int main(int, char**)
36{
37 void (*fp)() = f;
38 test(t&: fp);
39 test(t&: f);
40 functor1 f1;
41 test(t&: f1);
42 int i = 0;
43 test(t&: i);
44 const int j = 0;
45 test(t: j);
46
47 return 0;
48}
49

source code of libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp