Files
clang-p2996/libcxx/test/std/utilities/template.bitset/bitset.members/test.out_of_range.pass.cpp
Nikolas Klauser f02120fba2 [libc++] Implement P2417R2 (A more constexpr bitset)
Reviewed By: ldionne, #libc

Spies: jloser, arichardson, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D131218
2022-08-14 10:34:01 +02:00

38 lines
1.0 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: no-exceptions
// constexpr bool test(size_t pos) const;
// Make sure we throw std::out_of_range when calling test() on an OOB index.
#include <bitset>
#include <cassert>
#include <stdexcept>
int main(int, char**) {
{
std::bitset<0> v;
try { (void) v.test(0); assert(false); }
catch (std::out_of_range const&) { }
}
{
std::bitset<1> v("0");
try { (void) v.test(2); assert(false); }
catch (std::out_of_range const&) { }
}
{
std::bitset<10> v("0000000000");
try { (void) v.test(10); assert(false); }
catch (std::out_of_range const&) { }
}
return 0;
}