35 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// bitset<N>& reset(size_t pos); // constexpr since C++2312 13// Make sure we throw std::out_of_range when calling reset() 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 { v.reset(0); assert(false); } catch (std::out_of_range const&) { }23 }24 {25 std::bitset<1> v("0");26 try { v.reset(2); assert(false); } catch (std::out_of_range const&) { }27 }28 {29 std::bitset<10> v("0000000000");30 try { v.reset(10); assert(false); } catch (std::out_of_range const&) { }31 }32 33 return 0;34}35