-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for bit-fields #80
Comments
C++14 loophole and classic methods don't work constexpr time. So I'm focusing on the C++17 solution. I created a branch, and some changes. First, I modified the structure binding functions to return not the tuples of references, but getter and setter lambdas. I tried to manage the Has/Is bitfield membera a Missing parts:
Bitfield offset and sizeA bitfield size can be calculated with this trick (except for For the bitfield offset I can not come up with an idea with standard C++17, constexpr time. C++20 has more opportunity to "guess" the type layout with the layout compatible type trait, and the bit cast. These help for the bitfield offset, but not all the cases; only for the standard_layout types. |
Probably can be managed to create not only "read-only" mode, but "proxy" mode too. So If integral types return with a proxy type like: template<class Getter, class Setter>
struct Proxy {
using type = std::invoke_result_t<Getter, /*no reference*/>;
operator type() const {
return getter(/* no reference */);
}
operator type&() const {
return getter(/*reference*/);
}
template<class Any>
Proxy& operator=(Any&& val) {
setter(val);
return *this;
}
private:
Getter getter;
Setter setter;
}; This can be used for bitfield structs too. |
C++20 is helping. With So the Remaining limitation:
|
Lets implement support for bit-fields for read-only mode.
The text was updated successfully, but these errors were encountered: