brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · ec023dc Raw
55 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// bitset<N> operator>>(size_t pos) const; // constexpr since C++2310 11#include <bitset>12#include <cassert>13#include <cstddef>14#include <vector>15 16#include "../bitset_test_cases.h"17#include "test_macros.h"18 19template <std::size_t N>20TEST_CONSTEXPR_CXX23 bool test_right_shift() {21    std::vector<std::bitset<N> > const cases = get_test_cases<N>();22    for (std::size_t c = 0; c != cases.size(); ++c) {23        for (std::size_t s = 0; s <= N+1; ++s) {24            std::bitset<N> v1 = cases[c];25            std::bitset<N> v2 = v1;26            assert((v1 >>= s) == (v2 >> s));27        }28    }29    return true;30}31 32int main(int, char**) {33  test_right_shift<0>();34  test_right_shift<1>();35  test_right_shift<31>();36  test_right_shift<32>();37  test_right_shift<33>();38  test_right_shift<63>();39  test_right_shift<64>();40  test_right_shift<65>();41  test_right_shift<1000>(); // not in constexpr because of constexpr evaluation step limits42#if TEST_STD_VER > 2043  static_assert(test_right_shift<0>());44  static_assert(test_right_shift<1>());45  static_assert(test_right_shift<31>());46  static_assert(test_right_shift<32>());47  static_assert(test_right_shift<33>());48  static_assert(test_right_shift<63>());49  static_assert(test_right_shift<64>());50  static_assert(test_right_shift<65>());51#endif52 53  return 0;54}55