1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++98, c++03, c++11 11 // <functional> 12 13 // bit_not 14 15 #include <functional> 16 #include <type_traits> 17 #include <cassert> 18 main()19int main() 20 { 21 typedef std::bit_not<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(0xEA95) & 0xFFFF ) == 0x156A); 26 assert((f(0x58D3) & 0xFFFF ) == 0xA72C); 27 assert((f(0) & 0xFFFF ) == 0xFFFF); 28 assert((f(0xFFFF) & 0xFFFF ) == 0); 29 30 typedef std::bit_not<> F2; 31 const F2 f2 = F2(); 32 assert((f2(0xEA95) & 0xFFFF ) == 0x156A); 33 assert((f2(0xEA95L) & 0xFFFF ) == 0x156A); 34 assert((f2(0x58D3) & 0xFFFF ) == 0xA72C); 35 assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C); 36 assert((f2(0) & 0xFFFF ) == 0xFFFF); 37 assert((f2(0L) & 0xFFFF ) == 0xFFFF); 38 assert((f2(0xFFFF) & 0xFFFF ) == 0); 39 assert((f2(0xFFFFL) & 0xFFFF ) == 0); 40 41 constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF; 42 static_assert ( foo == 0x156A, "" ); 43 44 constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF; 45 static_assert ( bar == 0x156A, "" ); 46 } 47