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 // The CI "Apple back-deployment with assertions enabled" needs a higher value 10 // ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=12712420 11 12 // bitset<N> operator<<(size_t pos) const; // constexpr since C++23 13 14 #include <bitset> 15 #include <cassert> 16 #include <cstddef> 17 #include <vector> 18 19 #include "../bitset_test_cases.h" 20 #include "test_macros.h" 21 22 template <std::size_t N> test_left_shift()23TEST_CONSTEXPR_CXX23 void test_left_shift() { 24 std::vector<std::bitset<N> > const cases = get_test_cases<N>(); 25 for (std::size_t c = 0; c != cases.size(); ++c) { 26 for (std::size_t s = 0; s <= N+1; ++s) { 27 std::bitset<N> v1 = cases[c]; 28 std::bitset<N> v2 = v1; 29 assert((v1 <<= s) == (v2 << s)); 30 } 31 } 32 } 33 test()34TEST_CONSTEXPR_CXX23 bool test() { 35 test_left_shift<0>(); 36 test_left_shift<1>(); 37 test_left_shift<31>(); 38 test_left_shift<32>(); 39 test_left_shift<33>(); 40 test_left_shift<63>(); 41 test_left_shift<64>(); 42 test_left_shift<65>(); 43 44 return true; 45 } 46 main(int,char **)47int main(int, char**) { 48 test(); 49 test_left_shift<1000>(); // not in constexpr because of constexpr evaluation step limits 50 #if TEST_STD_VER > 20 51 static_assert(test()); 52 #endif 53 54 return 0; 55 } 56