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

Support for pointers to incomplete types #34

Closed
mgieseki opened this issue Sep 23, 2017 · 6 comments
Closed

Support for pointers to incomplete types #34

mgieseki opened this issue Sep 23, 2017 · 6 comments

Comments

@mgieseki
Copy link

First of all, thank you for providing this implementation of std::variant. It's great to have a lightweight alternative to boost::variant available in C++11.
I just stumbled over an issue with recursive type definitions, and I'm not sure whether it's a limitation of C++11 or the variant implementation. The following struct definition compiles fine with GCC's and Clang's C++17 support:

struct S {
    std::variant<
        std::map<int, S>*
    > var;
};

When replacing std::variant with mpark::variant, I get an error message regarding the incomplete type S of std::pair<int, S>::second. Is it possible to enhance your implementation so that this kind of recursive type definition compiles with mpark::variant under C++11 as well?

@mpark
Copy link
Owner

mpark commented Sep 24, 2017

Thanks for the report! I just tried it out and confirmed the issue. It either looks like my fallback implementation of is_swappable is instantiating too eagerly, or I'm checking for is_swappable where I shouldn't be. I'm going to be attending CppCon this week, so I'll be sure to fix this after the conference!

@mgieseki
Copy link
Author

Awesome. Thanks for the confirmation and for having a look into the issue. Have a great time at CppCon.

@mpark
Copy link
Owner

mpark commented Nov 13, 2017

The following commits address this issue:

@mpark mpark closed this as completed Nov 13, 2017
@mgieseki
Copy link
Author

Great! Thanks for fixing this issue. It works flawlessly now.

@cor3ntin
Copy link

cor3ntin commented Oct 4, 2018

I'm experiencing something similar with gcc 7, seems to work with 8 https://godbolt.org/z/0fb-bV
(also works if I use standard variant)
Thanks!

@mpark mpark reopened this Oct 5, 2018
mpark added a commit that referenced this issue Jan 14, 2019
@mpark
Copy link
Owner

mpark commented Jan 15, 2019

The core of the issue here was that my implementation of invoke was instantiating too much. This is fixed by 5713032

@mpark mpark closed this as completed Jan 15, 2019
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

3 participants