edouarda/brigand

transform bug with msvc and nested alias declarations

Sahnvour opened this issue · 3 comments

The following code compiles fine with clang, but not with msvc from VS2015 Update 3 :

template<typename T>
    struct Foo
    {
        using Bar = T;
    };

    using FooBool = Foo<bool>;
    using list = brigand::list<FooBool>;

    template<typename Foo_>
    using GetBar = typename Foo_::Bar;

    using ToBar = brigand::bind<GetBar, brigand::_1>;

    using res = brigand::transform<list, ToBar>;

    static_assert(std::is_same<brigand::list<bool>, res>::value, "error");

The error is :

1>brigand\algorithms\transform.hpp(89): error C2938: 'GetBar<unknown-type>' : Failed to specialize alias template
1>  example.h(25): note: see reference to class template instantiation 'brigand::detail::transform<0,list,ToBar>' being compiled
1>brigand\algorithms\transform.hpp(89): error C3546: '...': there are no parameter packs available to expand

Please let me know if there are workarounds.
Regards.

The typical workaround is to use a struct instead of an using for GetBar.

Thanks, I worked around it with this

template<typename Foo_>
struct GetBar
{
    using type = typename Foo_::Bar;
};

using ToBar = brigand::apply<brigand::bind<GetBar, brigand::_1>, brigand::_1>;

Finding work arounds for Visual Studio is always a bit soul crushing.