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