Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 包含可变模板的元组_C++_Templates_C++11_Tuples - Fatal编程技术网

C++ 包含可变模板的元组

C++ 包含可变模板的元组,c++,templates,c++11,tuples,C++,Templates,C++11,Tuples,我有以下代码: template<typename... A> void queueQuery(std::string query, std::function<void(A...)> callback = nullptr); template<typename... A> std::tuple<std::string, std::function<void(A...)> queryCallback; std::queue<quer

我有以下代码:

template<typename... A>
void queueQuery(std::string query, std::function<void(A...)> callback = nullptr);

template<typename... A>
std::tuple<std::string, std::function<void(A...)> queryCallback;

std::queue<queryCallback> queryQueue;

您正在定义
queryCallback

template<typename... A> 
std::tuple<std::string, std::function<void(A...)> queryCallback;
模板

tuplePlease扩展到一个——或者在您的例子中,扩展到一个最小的代码块,该代码块将生成所讨论的错误。您知道一个类型的两个不同的
模板
实例是不相关的类型,对吗?在C++11中不可能吗?我是说。。。模板类型数量不确定的元组,或者模板类型数量不确定的元组?不,在标准C++11中不能这样做,只能对函数或类进行模板化。确定。所以对于我的问题,没有任何选择。我得另找一条路。谢谢。你可以把它包装成一个
struct
,看看我更新的代码
template<typename... A> 
std::tuple<std::string, std::function<void(A...)> queryCallback;
template<typename... A> 
struct Foo{
    std::tuple<std::string, std::function<void (A...)> > queryCallback;
};