现代C+中是否允许双/嵌套变量模板扩展+;? 我一直尝试使用C++元编程来构造诸如的构造。 f(g<0>(args...), g<1>(args...), ... g<n-1>(args...))

现代C+中是否允许双/嵌套变量模板扩展+;? 我一直尝试使用C++元编程来构造诸如的构造。 f(g<0>(args...), g<1>(args...), ... g<n-1>(args...)),c++,c++11,variadic-templates,template-meta-programming,C++,C++11,Variadic Templates,Template Meta Programming,其中map\u call的一个(尝试失败)实现如下所示: // what I tried: template<class Mapped, class Indicies> struct map_call_help; template<class Mapped, int... indices> struct map_call_help<Mapped, std::integer_sequence<int, indices...>> { templ

其中
map\u call
的一个(尝试失败)实现如下所示:

// what I tried:
template<class Mapped, class Indicies> struct map_call_help;
template<class Mapped, int... indices>
struct map_call_help<Mapped, std::integer_sequence<int, indices...>>
{
    template<class Callable, class... Args>
    static inline void f(Callable && call, Args && ... args)
    {
        call( Mapped::f<indices>(std::forward<Args>(args)...) ...);
        //                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^      1
        //    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2
        // nested expansion fails with parse error / expected ')'
        // inner expansion is: std::forward<Args>(args)...
        // outer expansion is: Mapped::f<indices>(_forwarded_args_)...
    }
};
template<int n, class Mapped, class Callable, class... Args>
inline void map_call(Callable && call, Args && ... args)
{
    map_call_help<Mapped, std::make_integer_sequence<int, n>>::f(
          std::forward<Callable>(call), std::forward<Args>(args)... );
}
//我尝试的是:
模板结构图\u调用\u帮助;
模板
结构映射\u调用\u帮助
{
模板
静态内联void f(可调用和调用、参数和…参数)
{
调用(映射::f(std::转发,如果感兴趣。

更改

Mapped::f<indices>
映射::f

Mapped::模板f

还有许多其他类似的错误,但那是那一行的错误。

上面的代码在完全不同的位置生成错误,即使在我修复了
模板之后。
打字错误。请在减少错误并确认仍然生成错误后,发布生成错误的实际代码。@Yakk:谢谢你的评论。正如我所说的,
integer\u sequence
相关代码不包括在内,以避免冗长的帖子。如果你想,我可以减少它,并将它包括在这里,以获得完整的代码。问题是,当我浏览了你的代码,删除了简单的语法错误,并将
std::integer\u sequence
替换为
std::index\u seq你拼错了
模板
,你错过了一个
模板
,你对
make_int_seq
的使用有点古怪,你不能将模板函数作为单个对象传递,yada yada--所有这些都很容易由你的“简化”造成没有复制。发布一个。例如,
do_stuff
不是一个对象,它是一个模板函数。你不能将它作为参数传递给函数。谢谢,我修复了我的代码(为了保持小,它现在需要C++14),但仍然有同样的问题,所以我对你的无事可做非常感兴趣;)你是对的:我被编译错误消息弄糊涂了,看错了方向。问题的答案是:嵌套变量扩展是可能的(我不确定),但我发布的代码中还有另一个问题;)非常感谢,我猜我误解了这里的编译器错误。事实上,这也是我正在处理的实际代码中的问题。
Mapped::f<indices>
Mapped::template f<indices>