main()::__lambda1 不是 std::_Tuple_impl<1ul, main()::__lambda1> 的可访问基础

main()::__lambda1 is not an accessible base of std::_Tuple_impl<1ul, main()::__lambda1>

取以下内容:

#include <utility>
#include <functional>
#include <iostream>

struct FooType
{
    FooType(std::tuple<std::function<void()>, std::function<void()>> t)
    {
        std::get<0>(t)();
        std::get<1>(t)();
    }
};

int main()
{
    FooType foo(
        std::make_tuple(
            []() { std::cout << "a\n"; },
            []() { std::cout << "b\n"; }
        )
    );
}

它构建并运行良好with GCC 4.9 and higher, but with GCC 4.8(这是我的构建系统)以下编译器错误结果:

In file included from main.cpp:2:0:
/usr/include/c++/4.8/functional: In substitution of 'template<class _Res, class ... _ArgTypes> template<class _Functor> using _Invoke = decltype (std::__callable_functor(declval<_Functor&>())((declval<_ArgTypes>)()...)) [with _Functor = std::_Tuple_impl<1ul, main()::__lambda1>; _Res = void; _ArgTypes = {}]':
/usr/include/c++/4.8/functional:2257:9:   required from 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(std::_Tuple_impl<_Idx, _UHead, _UTails ...>&&) [with _UHead = main()::__lambda0; _UTails = {main()::__lambda1}; long unsigned int _Idx = 0ul; _Head = std::function<void()>; _Tail = {std::function<void()>}]'
/usr/include/c++/4.8/tuple:556:60:   required from 'constexpr std::tuple<_T1, _T2>::tuple(std::tuple<_U1, _U2>&&) [with _U1 = main()::__lambda0; _U2 = main()::__lambda1; <template-parameter-2-3> = void; _T1 = std::function<void()>; _T2 = std::function<void()>]'
main.cpp:21:5:   required from here
/usr/include/c++/4.8/functional:2181:71: error: 'main()::__lambda1' is not an accessible base of 'std::_Tuple_impl<1ul, main()::__lambda1>'
  using _Invoke = decltype(__callable_functor(std::declval<_Functor&>())
                                                                       ^

大概我在 GCC 4.8 的实验性 C++11 实现中遇到了 "bug",但我在网上找不到任何关于它的讨论。这个问题对任何人都很熟悉吗?有便宜的解决方法吗?

在元组中传递 std::function 是我刚刚创建的设计的核心——我很遗憾在 Coliru 中构建它而没有特别切换到 GCC 4.8 直到最后!

创建带有显式模板参数的元组 works as a workaround:

#include <utility>
#include <functional>
#include <iostream>

struct FooType
{
    FooType(std::tuple<std::function<void()>, std::function<void()>> t)
    {
        std::get<0>(t)();
        std::get<1>(t)();
    }
};

int main()
{
    FooType foo(
        std::make_tuple
        <
            std::function<void()>,
            std::function<void()>
        >(
            []() { std::cout << "a\n"; },
            []() { std::cout << "b\n"; }
        )
    );
}