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++98, c++03, c++11, c++14, c++17 10 11 // <functional> 12 // 13 // reference_wrapper 14 // 15 // template <ObjectType T> reference_wrapper<T> ref(T& t); 16 // 17 // where T is an incomplete type (since C++20) 18 19 #include <functional> 20 #include <cassert> 21 22 23 struct Foo; 24 25 Foo& get_foo(); 26 27 void test() { 28 Foo& foo = get_foo(); 29 std::reference_wrapper<Foo> ref = std::ref(foo); 30 assert(&ref.get() == &foo); 31 } 32 33 struct Foo { }; 34 35 Foo& get_foo() { 36 static Foo foo; 37 return foo; 38 } 39 40 int main() { 41 test(); 42 } 43