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

boost::fusion::map or boost::fusion::map surprising behavior #203

Open
arximboldi opened this issue Oct 23, 2018 · 2 comments
Open

boost::fusion::map or boost::fusion::map surprising behavior #203

arximboldi opened this issue Oct 23, 2018 · 2 comments

Comments

@arximboldi
Copy link

arximboldi commented Oct 23, 2018

Hi!

I found surprising behavior with boost::fusion::map.
Given the following set of types:

struct Foo {};
struct Bar {};
using Child = boost::fusion::map<boost::fusion::pair<Foo, int>>;
using Parent = boost::fusion::map<boost::fusion::pair<Bar, Child>>;

The following example fails to compile:

auto example()
{
    return Parent{
        boost::fusion::make_pair<Bar>(
                boost::fusion::make_pair<Foo>(42))};
}

This can be fixed by doing:

auto example()
{
    return Parent{
        boost::fusion::pair<Bar, Child>(
                boost::fusion::make_pair<Foo>(42))};
}

While I do understand while the former fails and the latter doesn't. I do find this suprising behavior. Specially, considering the errors produced by the failing example.

@arximboldi
Copy link
Author

There are even more confusing examples I believe (trying to disentangle my metaprograming to produce a minimal example...)

@arximboldi
Copy link
Author

arximboldi commented Oct 23, 2018

Ahaaa! Found it, the problem arises when the nested map is not the first element of the outer map. The problem seems to be related to how map_impl works via recursive inheritance in combination with some broken SFINAE. Here is a failing example that should clearly not fail...

struct Foo {};
struct Bar {};
using Child = boost::fusion::map<boost::fusion::pair<Foo, int>>;
using Parent = boost::fusion::map<
    boost::fusion::pair<Foo, float>,
    boost::fusion::pair<Bar, Child>>;

auto example()
{
    return Parent{
        boost::fusion::pair<Foo, float>{42.0f},
        boost::fusion::pair<Bar, Child>{Child{
                boost::fusion::pair<Foo, int>{42}}}};
}

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

1 participant