]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/function_objects/constexpr.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / function_objects / constexpr.cc
CommitLineData
52066eae 1// { dg-do compile { target c++14 } }
8dff34fe 2
83ffe9cd 3// Copyright (C) 2014-2023 Free Software Foundation, Inc.
8dff34fe
VV
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
19
20// 20.9.5-20.9.9
21
22#include <functional>
23
24static_assert(std::plus<int>()(1,2)==3, "");
25static_assert(std::minus<int>()(3,2)==1, "");
26static_assert(std::multiplies<int>()(3,2)==6, "");
27static_assert(std::divides<int>()(6,2)==3, "");
28static_assert(std::modulus<int>()(7,2)==1, "");
29static_assert(std::negate<int>()(-5)==5, "");
30
31static_assert(std::plus<void>()(1,2)==3, "");
32static_assert(std::minus<void>()(3,2)==1, "");
33static_assert(std::multiplies<void>()(3,2)==6, "");
34static_assert(std::divides<void>()(6,2)==3, "");
35static_assert(std::modulus<void>()(7,2)==1, "");
36static_assert(std::negate<void>()(-5)==5, "");
37
38static_assert(std::equal_to<int>()(2,2), "");
39static_assert(std::not_equal_to<int>()(1,2), "");
40static_assert(std::greater<int>()(2,1), "");
41static_assert(std::less<int>()(1,2), "");
42static_assert(std::greater_equal<int>()(2,2), "");
43static_assert(std::less_equal<int>()(2,2), "");
44
45static_assert(std::equal_to<void>()(2,2), "");
46static_assert(std::not_equal_to<void>()(1,2), "");
47static_assert(std::greater<void>()(2,1), "");
48static_assert(std::less<void>()(1,2), "");
49static_assert(std::greater_equal<void>()(2,2), "");
50static_assert(std::less_equal<void>()(2,2), "");
51
52static_assert(std::logical_and<int>()(1,1), "");
53static_assert(std::logical_or<int>()(0,1), "");
54static_assert(std::logical_not<int>()(0), "");
55
56static_assert(std::logical_and<void>()(1,1), "");
57static_assert(std::logical_or<void>()(0,1), "");
58static_assert(std::logical_not<void>()(0), "");
59
60static_assert(std::bit_and<int>()(3,2)==2, "");
61static_assert(std::bit_or<int>()(1,2)==3, "");
62static_assert(std::bit_xor<int>()(1,1)==0, "");
63static_assert(std::bit_not<int>()(std::bit_not<int>()(0))==0, "");
64
65static_assert(std::bit_and<void>()(3,2)==2, "");
66static_assert(std::bit_or<void>()(1,2)==3, "");
67static_assert(std::bit_xor<void>()(1,1)==0, "");
68static_assert(std::bit_not<void>()(std::bit_not<void>()(0))==0, "");
69
de196e5d
JW
70static_assert(std::unary_negate< // { dg-warning "is deprecated" "" { target c++17 } }
71 std::logical_not<int>
72 >(std::logical_not<int>())(1), "");
73static_assert(std::not1(std::logical_not<int>())(1), ""); // { dg-warning "is deprecated" "" { target c++17 } }
8dff34fe 74
de196e5d
JW
75static_assert(std::binary_negate< // { dg-warning "is deprecated" "" { target c++17 } }
76 std::logical_and<int>
77 >(std::logical_and<int>())(0,0), "");
78static_assert(std::not2(std::logical_and<int>())(0,0), ""); // { dg-warning "is deprecated" "" { target c++17 } }