相关疑难解决方法(0)

模板参数包访问第N个类型和第N个元素

以下文章是我为模板参数包找到的第一个提案.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1603.pdf

在第16页,它讨论了引入两个新的运算符[]和<>来访问参数包元素和参数包类型.

The suggested syntax for such an operator involves two new operators: .[] to access values and .<> to access types. For instance:

template<int N, typename Tuple> struct tuple_element;
template<int N, ... Elements>
struct tuple_element<tuple<Elements...> >
{
    typedef Elements.<N> type;
};

template<int N, ... Elements>
Elements.<N>& get(tuple<Elements...>& t)
{ return t.[N]; }

template<int N, ... Elements>
const Elements.<N>& get(const tuple<Elements...>& t)
{ return t.[N]; }
Run Code Online (Sandbox Code Playgroud)

那么这些运营商在哪里?如果没有,他们的替代品是什么?

c++ variadic-templates c++11

37
推荐指数
4
解决办法
2万
查看次数

标签 统计

c++ ×1

c++11 ×1

variadic-templates ×1