我想知道 C++11 标准是否给出了关于type of the std::tuple
由返回std::tie
当一些论点是std::ignore
.
更具体地说,我可以假设:
-
decltype(std::tie(42, std::ignore))
不等于decltype(std::tie(std::ignore, 42))
-
decltype(std::tie(42, std::ignore))
不等于decltype(std::tie(42))
-
decltype(std::tie(std::ignore, 42))
不等于decltype(std::tie(42))
-
decltype(std::tie(std::ignore, std::ignore))
不等于decltype(std::tie(std::ignore))
换句话说,从类型的角度来看,生成的元组是否表现为具有类型的元组decltype(std::ignore)
对于所有匹配的模板参数std::ignore
按职位?
是的你可以,std::tie http://en.cppreference.com/w/cpp/utility/tuple/tie返回一个std::tuple<T&...>
where T...
是赋予它的类型。
std::ignore
有一个未指定的类型,但它仍然会出现在tuple
根据您指定的位置std::tie
.
如果让您感觉更好,您可以在代码中的某个位置包含:
int n;
auto i = std::tie(std::ignore, n);
auto j = std::tie(n, std::ignore);
auto k = std::tie(n);
static_assert(!std::is_same<decltype(i), decltype(j)>::value, "");
static_assert(!std::is_same<decltype(i), decltype(k)>::value, "");
static_assert(!std::is_same<decltype(j), decltype(k)>::value, "");
对于您明确使用的任何组合,依此类推。如果您的假设无效,这样编译就会失败。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)