-
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
flat_for_each_field not working on MSVC #38
Comments
@janwilmans, according to the documentation:
|
I'm not sure what that means? what are precise functions and get we work around them? |
There's a code example: #include <boost/pfr.hpp>
struct nested_t { char c; };
struct foo_t { int i; nested_t nested; };
static_assert(std::is_same<
boost::pfr::flat_tuple_element_t<1, foo_t>, // Flat reflection.
char // `char`, not `nested_t`!
>::value, "");
// Requires C++17 or Loophole enabled:
static_assert(std::is_same<
boost::pfr::tuple_element_t<1, foo_t>, // Precise reflection.
nested_t
>::value, ""); In other words, a flat reflection approach unwraps the nested structures, while the precise one accesses the fields as-is. In the example I've provided, the flattened structure will look like this: struct nested_t { char c; };
struct foo_t {
int i;
char c; // from nested_t
}; Exactly the same will happen to your code: struct foo {
int i;
int i_nested;
short data_0;
short data_1;
short data_2;
}; |
During the Boost Formal Review a bunch of changes were requested and applied., including the removal of I'll release a 2.0.0 version of the library soon. That version will be in Boost too. |
This example does not compile, even with /std:c++17 and without /permissive-.
Reproduce: just paste the code in a new console project, set it to c++17 and conformance mode to 'no'
This is the error message:
The text was updated successfully, but these errors were encountered: