• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // test 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 
main(int,char **)19 int main(int, char**) {
20     {
21         std::bitset<0> v;
22         try { v.test(0); assert(false); } catch (std::out_of_range const&) { }
23     }
24     {
25         std::bitset<1> v("0");
26         try { v.test(2); assert(false); } catch (std::out_of_range const&) { }
27     }
28     {
29         std::bitset<10> v("0000000000");
30         try { v.test(10); assert(false); } catch (std::out_of_range const&) { }
31     }
32 
33     return 0;
34 }
35