Update copyright in libstdc++-v3.
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / result_of / 1.cc
blob3a0a8b1bf57f4a7a132ac0782545d78c273d802d
1 // { dg-options "-std=gnu++0x" }
2 // { dg-do compile }
4 // Copyright (C) 2012-2013 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <functional>
22 #include <type_traits>
24 struct X {
25 int i;
26 void f1() { }
27 void f2() volatile { }
30 typedef int X::*pm;
31 typedef void (X::*pmf1)();
32 typedef void (X::*pmf2)() volatile;
34 typedef std::result_of<pm const&(X&)>::type result;
35 static_assert(std::is_same<result, int&>::value,
36 "invoking cv-qualified pointer-to-member-object");
38 typedef std::result_of<pmf1 const&(X&)>::type result1;
39 static_assert(std::is_void<result1>::value,
40 "invoking cv-qualified pointer-to-member-function");
42 typedef std::result_of<pmf2 const&(X&)>::type result2;
43 static_assert(std::is_void<result2>::value,
44 "invoking cv-qualified pointer-to-member-function");
46 typedef std::result_of<pm(volatile X&)>::type result3;
47 static_assert(std::is_same<result3, volatile int&>::value,
48 "invoking pointer-to-member-object on volatile object");
50 typedef std::result_of<pmf2(volatile X&)>::type result4;
51 static_assert(std::is_void<result4>::value,
52 "invoking pointer-to-member-function on volatile object");