opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
bool_like.h
Go to the documentation of this file.
1#pragma once
2
3namespace osc
4{
5 // A type that directly wraps a `bool` (as in, it has the same object
6 // representation as a `bool`).
7 //
8 // The main reason this exists is to provide a separate type from `bool`
9 // for template overloading (i.e. you might need this whenever `std::vector<bool>`
10 // is being a PITA).
12 public:
13 BoolLike() = default;
14 BoolLike(bool value_) : value{value_} {}
15
16 operator bool& () { return value; }
17 operator const bool& () const { return value; }
18
19 private:
20 bool value;
21 };
22
24 {
25 return reinterpret_cast<bool*>(bool_like);
26 }
27
28 inline const bool* cast_to_bool_ptr(const BoolLike* bool_like)
29 {
30 return reinterpret_cast<const bool*>(bool_like);
31 }
32}
Definition bool_like.h:11
BoolLike(bool value_)
Definition bool_like.h:14
BoolLike()=default
Definition custom_decoration_generator.h:5
bool * cast_to_bool_ptr(BoolLike *bool_like)
Definition bool_like.h:23
constexpr U to(T &&value)
Definition conversion.h:56