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 // UNSUPPORTED: c++98, c++03, c++11
10 // <functional>
11 
12 // bit_not
13 
14 #include <functional>
15 #include <type_traits>
16 #include <cassert>
17 
18 int main(int, char**)
19 {
20     typedef std::bit_not<int> F;
21     const F f = F();
22     static_assert((std::is_same<F::argument_type, int>::value), "" );
23     static_assert((std::is_same<F::result_type, int>::value), "" );
24     assert((f(0xEA95) & 0xFFFF ) == 0x156A);
25     assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
26     assert((f(0)      & 0xFFFF ) == 0xFFFF);
27     assert((f(0xFFFF) & 0xFFFF ) == 0);
28 
29     typedef std::bit_not<> F2;
30     const F2 f2 = F2();
31     assert((f2(0xEA95)  & 0xFFFF ) == 0x156A);
32     assert((f2(0xEA95L) & 0xFFFF ) == 0x156A);
33     assert((f2(0x58D3)  & 0xFFFF ) == 0xA72C);
34     assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C);
35     assert((f2(0)       & 0xFFFF ) == 0xFFFF);
36     assert((f2(0L)      & 0xFFFF ) == 0xFFFF);
37     assert((f2(0xFFFF)  & 0xFFFF ) == 0);
38     assert((f2(0xFFFFL)  & 0xFFFF ) == 0);
39 
40     constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF;
41     static_assert ( foo == 0x156A, "" );
42 
43     constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF;
44     static_assert ( bar == 0x156A, "" );
45 
46   return 0;
47 }
48