cpp模板参数数量错误

时间:2019-05-06 23:31:49

标签: c++11

我弄错了该函数,在该函数的下面遍历一个映射,该映射的主键是一对,辅助对是字符串。目标是获取其值与给定值匹配的所有主键和辅助键对。我想将结果存储在成对的向量中,如下所示:

vector<pair<string, pair<int, int> > > get_splits_direction_with(map<pair<int, int>, map<string, double>> nodes_expanded_direction, double minimum)
    {
        vector<string> directions = {"forward", "backward"}; 
        vector<pair<string, pair<int, int>>> result;
        for (auto it = nodes_expanded_direction.begin(); it != nodes_expanded_direction.end(); ++it)
        {
            for (string direction : directions)
            {
                if (it->second[direction] == minimum)
                {
                    pair<string, pair<int, int>> p(direction, it->first);
                    result.push_back(p);
                }
            }

        }
        return result;
    }

当我使用以下命令调用函数时:

vector<pair<string direction, pair<int, int> > > min_splits_direction = get_splits_direction_with(nodes_expanded_direction, min_split_nodes_expanded_direction);

产生以下错误输出:

  

vector>> min_splits_direction   = get_splits_direction_with(nodes_expanded_direction,min_split_nodes_expanded_direction);

     

root @ DESKTOP-1066SO9:/ mnt / c / projects / a-star#make   get_optimal_split_direction> direction.output在包含的文件中   get_optimal_split_direction.cpp:16:0:lib / my_lib / vector_ops.hpp:在   函数‘std :: vector> get_min_splits(bool,DB,   std :: __ cxx11 :: string,std :: __ cxx11 :: string,int,int,   std :: __ cxx11 :: string,std :: __ cxx11 :: string,std :: __ cxx11 :: string)’:   lib / my_lib / vector_ops.hpp:348:48:错误:模板编号错误   参数(1,应为2)        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                   ^〜在/usr/include/c++/7/bits/stl_algobase.h:64:0中包含的文件中,                    从/usr/include/c++/7/bits/char_traits.h:39,                    从/ usr / include / c ++ / 7 / ios:40,                    来自/ usr / include / c ++ / 7 / ostream:38,                    从/ usr / include / c ++ / 7 / iostream:39,                    从get_optimal_split_direction.cpp:4:/usr/include/c++/7/bits/stl_pair.h:198:12:注意:为   “模板struct std :: pair”        结构对               ^ ~~~在get_optimal_split_direction.cpp:16:0中包含的文件中:   lib / my_lib / vector_ops.hpp:348:50:错误:模板参数1为   无效        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                     ^ lib / my_lib / vector_ops.hpp:348:50:错误:模板参数2为   无效的lib / my_lib / vector_ops.hpp:348:161:错误:无法转换   ‘std :: vector,   在初始化时将std :: pair>>设置为“ int”        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                                                                                                                                    ^ make: * [get_optimal_split_direction]错误1   root @ DESKTOP-1066SO9:/ mnt / c / projects / a-star#make   get_optimal_split_direction> direction.output   root @ DESKTOP-1066SO9:/ mnt / c / projects / a-star#make   get_optimal_split_direction> direction.output   root @ DESKTOP-1066SO9:/ mnt / c / projects / a-star#make   get_optimal_split_direction> direction.output在包含的文件中   get_optimal_split_direction.cpp:16:0:lib / my_lib / vector_ops.hpp:在   函数‘std :: vector> get_min_splits(bool,DB,   std :: __ cxx11 :: string,std :: __ cxx11 :: string,int,int,   std :: __ cxx11 :: string,std :: __ cxx11 :: string,std :: __ cxx11 :: string)’:   lib / my_lib / vector_ops.hpp:348:48:错误:模板编号错误   参数(1,应为2)        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                   ^〜在/usr/include/c++/7/bits/stl_algobase.h:64:0中包含的文件中,                    从/usr/include/c++/7/bits/char_traits.h:39,                    从/ usr / include / c ++ / 7 / ios:40,                    来自/ usr / include / c ++ / 7 / ostream:38,                    从/ usr / include / c ++ / 7 / iostream:39,                    从get_optimal_split_direction.cpp:4:/usr/include/c++/7/bits/stl_pair.h:198:12:注意:为   “模板struct std :: pair”        结构对               ^ ~~~在get_optimal_split_direction.cpp:16:0中包含的文件中:   lib / my_lib / vector_ops.hpp:348:50:错误:模板参数1为   无效        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                     ^ lib / my_lib / vector_ops.hpp:348:50:错误:模板参数2为   无效的lib / my_lib / vector_ops.hpp:348:161:错误:无法转换   ‘std :: vector,   在初始化时将std :: pair>>设置为“ int”        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                                                                                                                                    ^ make:* [get_optimal_split_direction]错误1   root @ DESKTOP-1066SO9:/ mnt / c / projects / a-star#make   get_optimal_split_direction> direction.output在包含的文件中   get_optimal_split_direction.cpp:16:0:lib / my_lib / vector_ops.hpp:在   函数‘std :: vector> get_min_splits(bool,DB,   std :: __ cxx11 :: string,std :: __ cxx11 :: string,int,int,   std :: __ cxx11 :: string,std :: __ cxx11 :: string,std :: __ cxx11 :: string)’:   lib / my_lib / vector_ops.hpp:348:50:错误:模板编号错误   参数(1,应为2)        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                     ^在/usr/include/c++/7/bits/stl_algobase.h:64:0中包含的文件中,                    从/usr/include/c++/7/bits/char_traits.h:39,                    从/ usr / include / c ++ / 7 / ios:40,                    来自/ usr / include / c ++ / 7 / ostream:38,                    从/ usr / include / c ++ / 7 / iostream:39,                    从get_optimal_split_direction.cpp:4:/usr/include/c++/7/bits/stl_pair.h:198:12:注意:为   “模板struct std :: pair”        结构对               ^ ~~~在get_optimal_split_direction.cpp:16:0中包含的文件中:   lib / my_lib / vector_ops.hpp:348:52:错误:模板参数1为   无效        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                       ^ lib / my_lib / vector_ops.hpp:348:52:错误:模板参数2为   无效的lib / my_lib / vector_ops.hpp:348:163:错误:无法转换   ‘std :: vector,   在初始化时将std :: pair>>设置为“ int”        向量>> min_splits_direction =   get_splits_direction_with(nodes_expanded_direction,   min_split_nodes_expanded_direction);                                                                                                                                                                      ^ make:*** [get_optimal_split_direction]错误1

请协助。

0 个答案:

没有答案