[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / libcxx / test / std / utilities / template.bitset / bitset.members / test.out_of_range.pass.cpp
blob37009c67ac3d2521ad73da602e1c03d99ab86016
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-exceptions
11 // constexpr bool test(size_t pos) const;
13 // Make sure we throw std::out_of_range when calling test() on an OOB index.
15 #include <bitset>
16 #include <cassert>
17 #include <stdexcept>
19 int main(int, char**) {
21 std::bitset<0> v;
22 try { (void) v.test(0); assert(false); }
23 catch (std::out_of_range const&) { }
26 std::bitset<1> v("0");
27 try { (void) v.test(2); assert(false); }
28 catch (std::out_of_range const&) { }
31 std::bitset<10> v("0000000000");
32 try { (void) v.test(10); assert(false); }
33 catch (std::out_of_range const&) { }
36 return 0;