| 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 |
// UNSUPPORTED: no-exceptions |
| 10 |
|
| 11 |
// bitset<N>& set(size_t pos, bool val = true); // constexpr since C++23 |
| 12 |
|
| 13 |
// Make sure we throw std::out_of_range when calling set() on an OOB index. |
| 14 |
|
| 15 |
#include <bitset> |
| 16 |
#include <cassert> |
| 17 |
#include <stdexcept> |
| 18 |
|
| 19 |
int main(int, char**) { |
| 20 |
{ |
| 21 |
std::bitset<0> v; |
| 22 |
try { v.set(0); assert(false); } catch (std::out_of_range const&) { } |
| 23 |
} |
| 24 |
{ |
| 25 |
std::bitset<1> v("0"); |
| 26 |
try { v.set(2); assert(false); } catch (std::out_of_range const&) { } |
| 27 |
} |
| 28 |
{ |
| 29 |
std::bitset<10> v("0000000000"); |
| 30 |
try { v.set(10); assert(false); } catch (std::out_of_range const&) { } |
| 31 |
} |
| 32 |
|
| 33 |
return 0; |
| 34 |
} |