2012-01-18 9 views
3
>c:\program files\microsoft visual studio 10.0\vc\include\algorithm(4494): error C2678:  
binary '=' : no operator found which takes a left-hand operand of type 'const 
std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion) 
      with 
      [ 
       _Elem=char, 
       _Traits=std::char_traits<char>, 
      _Ax=std::allocator<char> 
      ] 
     c:\program files\microsoft visual studio 10.0\vc\include\xstring(707): could be 
'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator = 
(std::basic_string<_Elem,_Traits,_Ax> &&)' 
    with 
     [ 
      _Elem=char, 
      _Traits=std::char_traits<char>, 
      _Ax=std::allocator<char> 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\xstring(762): or  'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const std::basic_string<_Elem,_Traits,_Ax> &)' 
     with 
     [ 
      _Elem=char, 
      _Traits=std::char_traits<char>, 
      _Ax=std::allocator<char> 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\xstring(767): or  
'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator = 
(const _Elem *)' 
    with 
     [ 
      _Elem=char, 
      _Traits=std::char_traits<char>, 
      _Ax=std::allocator<char> 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\xstring(772): or   
'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator = 
(_Elem)' 
    with 
    [ 
      _Elem=char, 
      _Traits=std::char_traits<char>, 
      _Ax=std::allocator<char> 
     ] 
     while trying to match the argument list '(const 
std::basic_string<_Elem,_Traits,_Ax>, const std::basic_string<_Elem,_Traits,_Ax>)' 
     with 
     [ 
      _Elem=char, 
      _Traits=std::char_traits<char>, 
      _Ax=std::allocator<char> 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\algorithm(4522) : see 
reference to function template instantiation '_OutIt 
std::_Set_intersection<_InIt1,_InIt2,_OutIt>(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' being 
compiled 
     with 
     [ 


_OutIt=std::_Tree_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std::less<std ::string>,std::allocator<std::string>,false>>>, 


_InIt1=std::_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std::less<std::string>,std::allocator<std::string>,false>>>, 


_InIt2=std::_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std ::less<std::string>,std::allocator<std::string>,false>>> 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\algorithm(4549) : see 
reference to function template instantiation '_OutIt 
std::_Set_intersection1<std::_Tree_unchecked_const_iterator<_Mytree>,std::_Tree_unchecked_ 
const_iterator<_Mytree>,_OutIt> 
(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt,std::tr1::true_type)' being compiled 
     with 
     [ 



_OutIt=std::_Tree_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std::less<std  ::string>,std::allocator<std::string>,false>>>, 


_Mytree=std::_Tree_val<std::_Tset_traits<std::string,std::less<std::string>,std::allocator< 
std::string>,false>>, 


_InIt1=std::_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std 
::less<std::string>,std::allocator<std::string>,false>>>, 

_InIt2=std::_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std  ::less<std::string>,std::allocator<std::string>,false>>> 
     ] 
    c:\qc\qc_daq_development\qc\qc_daq\src\hfgui3\expscan.cpp(458) : see reference to 
function template instantiation '_OutIt 

std::set_intersection<std::_Tree_const_iterator<_Mytree>,std::_Tree_const_iterator<_Mytree>  ,std::_Tree_const_iterator<_Mytree>>(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' being 
compiled 
     with 
     [ 


_OutIt=std::_Tree_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std::less<std 
::string>,std::allocator<std::string>,false>>>, 


_Mytree=std::_Tree_val<std::_Tset_traits<std::string,std::less<std::string>,std::allocator< 
std::string>,false>>, 


_InIt1=std::_Tree_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std::less<std 
::string>,std::allocator<std::string>,false>>>, 


_InIt2=std::_Tree_const_iterator<std::_Tree_val<std::_Tset_traits<std::string,std::less<std 
::string>,std::allocator<std::string>,false>>> 

は、Visual Studio 2010でプログラムをコンパイルしながら、それは、Visual Studio 2003でうまく機能として、スローされたエラーメッセージですので、私は把握する本当にできないのです問題!!!どんな助けや提案も深く感謝されます!前もって感謝します。:2678は、2010対のコンパイル・エラー、上述

私は上記のエラーメッセージを投げている行を貼り付けています。 あなたが私にそれを解決するためにあなたの貴重な時間を費やす場合、誰かがより多くの情報を私に教えてください、私はあなたに感謝します。それはで、その要素の「配置」を変更しますので

typedef std::set<string>     SET_STR; 
typedef std::map<string, SET_STR >   MAP_STR_SETSTR; 
typedef std::map<char, SET_STR >   MAP_CHAR_SETSTR; 
typedef std::map<string,SfvarInfo>   MAP_STR_FVARINFO; 


CritSec     m_csVarAccess;     
MAP_STR_VAL    m_mapVar; 
MAP_STR_VAL    m_mapFvarOverrides; 
MAP_STR_VAL    m_mapFvarOrig; 
MAP_STR_FVARINFO  m_mapFvarInfo; 
MAP_STR_SETSTR   m_mapCategoryFvar;    
MAP_CHAR_SETSTR   m_mapTypeFvar;     
MAP_STR_VAL    m_mapLoadedFvar; 

UserParam<string>  m_sScanFvar; 
UserParam<string>  m_sFvarFilterType; 
UserParam<string>  m_sFvarFilterCategory; 

SET_STR setType(m_mapTypeFvar[m_sFvarFilterType.c_str()[0]]); 
SET_STR setCategory(m_mapCategoryFvar[m_sFvarFilterCategory]); 
+0

SET_STR、setType、setCategory、setFilterの定義を含めてください。 –

+0

ありがとうpragnar私は何かが恋しいのか教えてください! – user1107855

答えて

3

あなたが要素に割り当てることができませんstd::setにイテレータによって指さ:

SET_STR::iterator itOut = 
std::set_intersection(setType.begin(),setType.end(),setCategory.begin(),setCategory.end(),s 
etFilter.begin()); 
setFilter.erase(itOut,setFilter.end()); //erase the rest of the set 

Definationsは事前に 感謝セット(一般的な場合)。したがって、をイテレータを使用して割り当てるため、set_intersection()コールの出力イテレータとしてsetFilter.begin()を使用することはできません。

基本的にVS2003ではVS2003がインストールされていないため、テストできませんが、それは当てはまりませんでしたので、コンパイルされました。

使用のstd :: insert_iterator <>の代わりに:set_intersection()は今のコードset<>::iterator .Fromの代わりにinsert_iterator<>を返しますので、

std::set_intersection(setType.begin(), setType.end(), 
         setCategory.begin(), setCategory.end(), 
         inserter(setFilter, setFilter.begin())); 

これは、あなたがset_intersection()コールの後にやっているerase()が複雑になりますsetFilterの最後の内容に交差点の要素のみを含めるようにしたいので、set_intersection()が呼び出されたときにsetFilterが空であることを確認してください。erase()の操作は必要ありません。

スコット・マイヤーズは、「効果的なSTL」、でこの種のものを語る「項目22:setmultisetにインプレースキーの変更を避け、」いくつかのコンパイラはstd::setためconst_iteratorスタイルのイテレータを使用する方法を含め、。

+0

マイケルに感謝しますが、私はあなたの有益な提案に従うことができません。私はvC++を初めて使っているので、可能な構文で私を助けてください。 – user1107855

+1

試してみるとどのようなエラーが表示されますか? std :: inserter(...)を使って行を追加する#include

+0

pragnarが言ったように、さらに 'SET_STR :: iterator itOut'と' erase() '呼び出しの割り当てを削除する必要があります。 –

関連する問題