41template <
class Allocator>
42class VectorBoolWorkaround :
public std::vector<std::byte, Allocator>
46 using StdVectorType = std::vector<std::byte, Allocator>;
48 static bool& toBool (std::byte& element) {
return *
reinterpret_cast<bool*
> (&element); }
49 static const bool& toBool (
const std::byte& element) {
return *
reinterpret_cast<const bool*
> (&element); }
50 static bool* toBool (std::byte* ptr) {
return reinterpret_cast<bool*
> (ptr); }
51 static const bool* toBool (
const std::byte* ptr) {
return reinterpret_cast<const bool*
> (ptr); }
54 constexpr VectorBoolWorkaround (std::initializer_list<bool> il)
56 StdVectorType::reserve (il.size());
62 constexpr bool& operator[] (
size_t i) {
return toBool (StdVectorType::operator[] (i)); }
63 constexpr const bool& operator[] (
size_t i)
const {
return toBool (StdVectorType::operator[] (i)); }
64 constexpr bool& at (
size_t i) {
return toBool (StdVectorType::at (i)); }
65 constexpr const bool& at (
size_t i)
const {
return toBool (StdVectorType::at (i)); }
66 constexpr bool& front() {
return toBool (StdVectorType::front()); }
67 constexpr const bool& front()
const {
return toBool (StdVectorType::front()); }
68 constexpr bool& back() {
return toBool (StdVectorType::back()); }
69 constexpr const bool& back()
const {
return toBool (StdVectorType::back()); }
70 constexpr void push_back (
bool v) { StdVectorType::push_back (std::byte (v)); }
72 bool* data() {
return toBool (StdVectorType::data()); }
73 const bool* data()
const {
return toBool (StdVectorType::data()); }
74 bool* begin() {
return data(); }
75 const bool* begin()
const {
return data(); }
76 bool* end() {
return data() + StdVectorType::size(); }
77 const bool* end()
const {
return data() + StdVectorType::size(); }