blob: df0b55a5d0609d6291cd9fbd1da676f1746ff6e6 [file] [log] [blame]
Howard Hinnant94b2dd02010-08-22 00:59:46 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant94b2dd02010-08-22 00:59:46 +00007//
8//===----------------------------------------------------------------------===//
9
10// <functional>
11
12// reference_wrapper
13
14// operator T& () const;
15
16#include <functional>
17#include <cassert>
18
19class functor1
20 : public std::unary_function<int, char>
21{
22};
23
24template <class T>
25void
26test(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()
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}