C++ 错误:来自‘;的用户定义转换无效;char’;至‘;标准::向量<;标准::基本字符串<;char>;

C++ 错误:来自‘;的用户定义转换无效;char’;至‘;标准::向量<;标准::基本字符串<;char>;,c++,string,c++11,vector,C++,String,C++11,Vector,我在stl_algo.h中得到了上面的错误,但无法确定问题所在,因为涉及到太多向量 for (unsigned i=0;i < subsets.size(); i++) { do { permutations.push_back(subsets[i]);} while (next_permutation(begin(subsets[i]), end(subsets[i]))); } for (unsigned i

我在stl_algo.h中得到了上面的错误,但无法确定问题所在,因为涉及到太多向量

    for (unsigned i=0;i < subsets.size(); i++) {
        do {
        permutations.push_back(subsets[i]);}
        while (next_permutation(begin(subsets[i]), end(subsets[i])));
    }


    for (unsigned i = 0; i < permutations.size(); i++) {
            if (find(wordlist.begin(), wordlist.end(), permutations[i]) != wordlist.end())
                first_words.push_back(permutations[i]);

    }

  ...

    for (const auto& str: subsets)
        set_difference(str.begin(), str.end(), letters.begin(), letters.end(), back_inserter(complement_sets));
for(无符号i=0;i
您需要学习如何读取编译器的输出,通常它不仅会告诉您问题发生的位置,还会告诉您问题发生的位置,尤其是在使用模板(或宏)时

例如,MSVC给了我以下输出:

c:\program files (x86)\microsoft visual studio 12.0\vc\include\algorithm(3710): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'char' (or there is no acceptable conversion)
          c:\program files (x86)\microsoft visual studio 12.0\vc\include\iterator(59): could be 'std::back_insert_iterator<std::vector<std::string,std::allocator<_Ty>>> &std::back_insert_iterator<std::vector<_Ty,std::allocator<_Ty>>>::operator =(const std::back_insert_iterator<std::vector<_Ty,std::allocator<_Ty>>> &)'
          with
          [
              _Ty=std::string
          ]
          c:\program files (x86)\microsoft visual studio 12.0\vc\include\iterator(36): or       'std::back_insert_iterator<std::vector<std::string,std::allocator<_Ty>>> &std::back_insert_iterator<std::vector<_Ty,std::allocator<_Ty>>>::operator =(std::basic_string<char,std::char_traits<char>,std::allocator<char>> &&)'
          with
          [
              _Ty=std::string
          ]
          c:\program files (x86)\microsoft visual studio 12.0\vc\include\iterator(30): or       'std::back_insert_iterator<std::vector<std::string,std::allocator<_Ty>>> &std::back_insert_iterator<std::vector<_Ty,std::allocator<_Ty>>>::operator =(const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)'
          with
          [
              _Ty=std::string
          ]
          while trying to match the argument list '(std::back_insert_iterator<std::vector<std::string,std::allocator<_Ty>>>, char)'
          with
          [
              _Ty=std::string
          ]
          c:\program files (x86)\microsoft visual studio 12.0\vc\include\algorithm(3748) : see reference to function template instantiation '_OutIt std::_Set_difference<_InIt1,_InIt2,_OutIt,_Pr>(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt,_Pr)' being compiled
          with
          [
              _OutIt=std::back_insert_iterator<std::vector<std::string,std::allocator<std::string>>>
  ,            _InIt1=char *
  ,            _InIt2=char *
  ,            _Pr=std::less<void>
          ]
          c:\program files (x86)\microsoft visual studio 12.0\vc\include\algorithm(3778) : see reference to function template instantiation '_OutIt std::_Set_difference2<char*,char*,_OutIt,_Pr>(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt,_Pr,std::true_type)' being compiled
          with
          [
              _OutIt=std::back_insert_iterator<std::vector<std::string,std::allocator<std::string>>>
  ,            _Pr=std::less<void>
  ,            _InIt1=char *
  ,            _InIt2=char *
          ]
          c:\program files (x86)\microsoft visual studio 12.0\vc\include\algorithm(3808) : see reference to function template instantiation '_OutIt std::set_difference<_InIt1,_InIt2,_OutIt,std::less<void>>(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt,_Pr)' being compiled
          with
          [
              _OutIt=std::back_insert_iterator<std::vector<std::string,std::allocator<std::string>>>
  ,            _InIt1=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>
  ,            _InIt2=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>
  ,            _Pr=std::less<void>
          ]
          c:\users\marvin\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(43) : see reference to function template instantiation '_OutIt std::set_difference<std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,std::back_insert_iterator<std::vector<std::string,std::allocator<_Ty>>>>(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' being compiled
          with
          [
              _OutIt=std::back_insert_iterator<std::vector<std::string,std::allocator<std::string>>>
  ,            _Ty=std::string
  ,            _InIt1=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>
  ,            _InIt2=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>
          ]
这里的问题是您正在比较两组字符,但试图将其插入字符串列表中。
您需要将字符串传递到后端插入器,而不是字符串向量。

在哪一行出现此错误?
auto
默认按值获取内容。因此,您只需要对字符串的副本进行排序,等等。
auto&
是您想要的,它将使用对原始对象的引用。它位于主调试器之外,在stl_algo.h第6000行中,在构建语言(如u glibcxx_function_所需)的行之间(_OutputIteratorConcept@aj1204您希望通过引用访问元素的任何地方。
const auto&
如果您不打算修改它们。@aj1204编译器通常会打印导致错误的语法分析的整个“堆栈”。其中应该有一些代码。
          c:\users\marvin\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(43) : see reference to function template instantiation '_OutIt std::set_difference<std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,std::back_insert_iterator<std::vector<std::string,std::allocator<_Ty>>>>(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' being compiled
          with
          [
              _OutIt=std::back_insert_iterator<std::vector<std::string,std::allocator<std::string>>>
  ,            _Ty=std::string
  ,            _InIt1=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>
  ,            _InIt2=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>
          ]