]>
Commit | Line | Data |
---|---|---|
d081231a JW |
1 | // { dg-options " -std=gnu++1y " } |
2 | // { dg-do compile } | |
3 | ||
4 | // Copyright (C) 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. | |
11 | ||
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. | |
16 | ||
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/>. | |
20 | ||
21 | // 20.3.3 Comparisons | |
22 | ||
23 | #include <functional> | |
24 | ||
25 | struct R { }; | |
26 | ||
27 | struct L | |
28 | { | |
29 | L operator+(const R&) const { return *this; } | |
30 | L operator-(const R&) const { return *this; } | |
31 | L operator*(const R&) const { return *this; } | |
32 | L operator/(const R&) const { return *this; } | |
33 | L operator%(const R&) const { return *this; } | |
34 | L operator-() const { return *this; } | |
35 | ||
36 | bool operator==(const R&) const { return true; } | |
37 | bool operator!=(const R&) const { return false; } | |
38 | bool operator<(const R&) const { return false; } | |
39 | bool operator<=(const R&) const { return true; } | |
40 | bool operator>(const R&) const { return false; } | |
41 | bool operator>=(const R&) const { return true; } | |
42 | ||
43 | bool operator&&(const R&) const { return true; } | |
44 | bool operator||(const R&) const { return true; } | |
45 | bool operator!() const { return false; } | |
46 | ||
47 | int operator&(const R&) const { return 1; } | |
48 | int operator|(const R&) const { return 1; } | |
49 | int operator^(const R&) const { return 0; } | |
50 | int operator~() const { return 0; } | |
51 | }; | |
52 | ||
53 | L l; | |
54 | R r; | |
55 | ||
56 | // test unary function objects | |
57 | template<typename F, typename Check = typename F::is_transparent> | |
58 | bool | |
59 | test1(F f) | |
60 | { | |
61 | f(l); | |
62 | return true; | |
63 | } | |
64 | ||
65 | // test binary function objects | |
66 | template<typename F, typename Check = typename F::is_transparent> | |
67 | bool | |
68 | test2(F f) | |
69 | { | |
70 | f(l, r); | |
71 | return true; | |
72 | } | |
73 | ||
74 | auto plus = test2( std::plus<>() ); | |
75 | auto minus = test2( std::minus<>() ); | |
76 | auto multiplies = test2( std::multiplies<>() ); | |
77 | auto divides = test2( std::divides<>() ); | |
78 | auto modulus = test2( std::modulus<>() ); | |
79 | auto negate = test1( std::negate<>() ); | |
80 | ||
81 | auto equal_to = test2( std::equal_to<>() ); | |
82 | auto not_equal_to = test2( std::not_equal_to<>() ); | |
83 | auto greater = test2( std::greater<>() ); | |
84 | auto less = test2( std::less<>() ); | |
85 | auto greater_equal = test2( std::greater_equal<>() ); | |
86 | auto less_equal = test2( std::less_equal<>() ); | |
87 | ||
88 | auto logical_and = test2( std::logical_and<>() ); | |
89 | auto logical_or = test2( std::logical_or<>() ); | |
90 | auto logical_not = test1( std::logical_not<>() ); | |
91 | ||
92 | auto bit_and = test2( std::bit_and<>() ); | |
93 | auto bit_or = test2( std::bit_or<>() ); | |
94 | auto bit_xor = test2( std::bit_xor<>() ); | |
95 | auto bit_not = test1( std::bit_not<>() ); |