Skip to content
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

PFR does not work with non-copyable aggregates on MSVC 17.10 #186

Open
Kaiyakha opened this issue Sep 26, 2024 · 1 comment
Open

PFR does not work with non-copyable aggregates on MSVC 17.10 #186

Kaiyakha opened this issue Sep 26, 2024 · 1 comment

Comments

@Kaiyakha
Copy link

Kaiyakha commented Sep 26, 2024

I was surprised to find out PFR fails to compile the following non-copyable aggregate Entity with MSVC 17.10:

struct Field final {
  Field() = default;
  Field(const Field&) = delete;
};

struct Entity final {
  Field x;
};

Entity e;

boost::pfr::get<0>(e);

The output says the tuple index is out of bounds. I also tried pfr::for_each_field which resulted in that scary If there is no other failed static asserts then something went wrong. My colleagues use Clang and they say the code above works just fine. The latest GCC also didn't show any issues.

@apolukhin
Copy link
Member

I'm afraid this is a MSVC issue. Looks like guaranteed copy elision is not supported by the compiler.

Anyway, I have no access to that compiler. If there's a known workaround, I'd appreciate a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants