1 /*
2  *
3  * Copyright (c) 2020
4  * John Maddock
5  *
6  * Use, modification and distribution are subject to the
7  * Boost Software License, Version 1.0. (See accompanying file
8  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9  *
10  */
11 
12  /*
13   *   LOCATION:    see http://www.boost.org for most recent version.
14   *   FILE         basic_regex_parser.cpp
15   *   VERSION      see <boost/version.hpp>
16   *   DESCRIPTION: Declares template class basic_regex_parser.
17   */
18 
19 #include <boost/regex/config.hpp>
20 #include <set>
21 
22 #ifndef BOOST_REGEX_V4_INDEXED_BIT_FLAG_HPP
23 #define BOOST_REGEX_V4_INDEXED_BIT_FLAG_HPP
24 
25 namespace boost{
26 namespace BOOST_REGEX_DETAIL_NS{
27 
28 class indexed_bit_flag
29 {
30    boost::uint64_t low_mask;
31    std::set<std::size_t> mask_set;
32 public:
indexed_bit_flag()33    indexed_bit_flag() : low_mask(0) {}
set(std::size_t i)34    void set(std::size_t i)
35    {
36       if (i < std::numeric_limits<boost::uint64_t>::digits - 1)
37          low_mask |= static_cast<boost::uint64_t>(1u) << i;
38       else
39          mask_set.insert(i);
40    }
test(std::size_t i)41    bool test(std::size_t i)
42    {
43       if (i < std::numeric_limits<boost::uint64_t>::digits - 1)
44          return low_mask & static_cast<boost::uint64_t>(1u) << i ? true : false;
45       else
46          return mask_set.find(i) != mask_set.end();
47    }
48 };
49 
50 } // namespace BOOST_REGEX_DETAIL_NS
51 } // namespace boost
52 
53 
54 #endif
55