首页 > TAG信息列表 > stdtuple

c-为什么不能从元组分配对,但是可以从对分配元组?

我不清楚为什么分配元组< X,Y> = pair< X,Y> 但是分配对X,Y =元组X,Y是不合法的. std::pair<int, double> x { 1 , 5.5}; std::tuple<int, double> y { 1 , 5.5}; int a; double b; std::tie(a,b) = x; std::tie(a,b) = y; x = y; // THIS LIN

通过函数中的编译时变量访问C 11中的元组元素

以下最小示例使用g -std = c 11 -Wall tuple.cpp -o tuple进行编译: #include <tuple> #include <iostream> template<int i> char get_elem_i(std::tuple<char, char> t) { return std::get<i>(t); } int main() { std::tuple<char, char>

创建一个C std :: tuple投影函数

我正在寻找std :: tuple的投影函数.即,该函数接收整数列表作为模板参数,并返回仅具有这些索引处的值的元组. 例如,考虑我有一个元组元组< int,String,char,float> t,然后调用项目< 1,3>(t)将导致元组类型元组< String,float>的元组. 当然,关键似乎是递归模板.但是,我无法让它工作.

c – 为什么std :: get没有一个接受转发引用的签名

为什么std :: get for std :: tuple有这么多的重载(http://en.cppreference.com/w/cpp/utility/tuple/get)?一个对应于const和amp;的每种可能组合.和&&amp ;?对于每个组合,返回值上的const ref限定符是相同的.为什么不通过转发引用只有一个单一的重载接受元组类型,然后根据输入的签

c – 使用单参数模板化构造函数构造引用元组的值元组

我有一个const引用的元组std :: tuple< const Matrix&,...>我从中构造了一个值元组std :: tuple< Matrix,...>.对于大于1的任何大小的元组,这都可以正常工作:(在线示例:https://godbolt.org/g/24E8tU) #include <tuple> struct Matrix { Matrix() = default; Matrix(Matri

C将同类包装类型的元组转换为原始类型的元组

我想将std :: apply()调用到函数中;但是,我无法,因为我使用的std :: tuple目前已被包装.例如: #include <tuple> template <class T> struct wrapped { wrapped(T t) : t(t) {} T t; }; template <class T, class ... Args> struct delay_call { T(*callback)(Args.