]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/function/43397.cc
b8a268081a61d1173c5d16ae35b0cc679246f848
1 // { dg-do run { target c++11 } }
2 // Copyright (C) 2010-2016 Free Software Foundation, Inc.
4 // This file is part of the GNU ISO C++ Library. This library is free
5 // software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the
7 // Free Software Foundation; either version 3, or (at your option)
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this library; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
19 // 20.8.15 polymorphic function object wrapper
22 #include <testsuite_hooks.h>
27 short operator() ( int && ) { return 1; }
28 short operator() ( int && ) const { return 2; }
29 short operator() ( int && ) volatile { return 3; }
30 short operator() ( int && ) const volatile { return 4; }
31 short func( int && ) { return 5; }
32 short func_c( int && ) const { return 6; }
33 short func_v( int && ) volatile { return 7; }
34 short func_cv( int && ) const volatile { return 8; }
39 bool test
__attribute__((unused
)) = true;
47 Foo
const volatile foo_cv
;
49 std::function
< int ( int && ) > f1( ref(foo
) );
52 std::function
< int ( int && ) > f2( ref(foo_c
) );
55 std::function
< int ( int && ) > f3( ref(foo_v
) );
58 std::function
< int ( int && ) > f4( ref(foo_cv
) );
61 std::function
< int ( Foo
&, int && ) > f5( &Foo::func
) ;
62 VERIFY( f5(foo
, 0) == 5 );
64 std::function
< int ( Foo
const &, int && ) > f6( &Foo::func_c
) ;
65 VERIFY( f6(foo_c
, 0) == 6 );
67 std::function
< int ( Foo
volatile &, int && ) > f7( &Foo::func_v
) ;
68 VERIFY( f7(foo_v
, 0) == 7 );
70 std::function
< int ( Foo
const volatile &, int && ) > f8( &Foo::func_cv
) ;
71 VERIFY( f8(foo_cv
, 0) == 8 );