1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <functional>
10 
11 // negate
12 
13 #include <functional>
14 #include <type_traits>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 
main(int,char **)19 int main(int, char**)
20 {
21     typedef std::negate<int> F;
22     const F f = F();
23     static_assert((std::is_same<F::argument_type, int>::value), "" );
24     static_assert((std::is_same<F::result_type, int>::value), "" );
25     assert(f(36) == -36);
26 #if TEST_STD_VER > 11
27     typedef std::negate<> F2;
28     const F2 f2 = F2();
29     assert(f2(36) == -36);
30     assert(f2(36L) == -36);
31     assert(f2(36.0) == -36);
32 
33     constexpr int foo = std::negate<int> () (3);
34     static_assert ( foo == -3, "" );
35 
36     constexpr double bar = std::negate<> () (3.0);
37     static_assert ( bar == -3.0, "" );
38 #endif
39 
40   return 0;
41 }
42