brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 37009c6 Raw
38 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// UNSUPPORTED: no-exceptions10 11// constexpr bool test(size_t pos) const;12 13// Make sure we throw std::out_of_range when calling test() on an OOB index.14 15#include <bitset>16#include <cassert>17#include <stdexcept>18 19int main(int, char**) {20    {21        std::bitset<0> v;22        try { (void) v.test(0); assert(false); }23        catch (std::out_of_range const&) { }24    }25    {26        std::bitset<1> v("0");27        try { (void) v.test(2); assert(false); }28        catch (std::out_of_range const&) { }29    }30    {31        std::bitset<10> v("0000000000");32        try { (void) v.test(10); assert(false); }33        catch (std::out_of_range const&) { }34    }35 36    return 0;37}38