Bonjour a tous,

j'ai quelque problème avec la fonctions replace de la STL (algorithm.h).


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
map<string,TrVariable>::iterator pos;
for(pos=mMapOfVariable.begin();pos!=mMapOfVariable.end();++pos)
{
	string key=pos->first;
	TrVariable var=pos->second;
	string varContent=var.valueToString();
	replace (formula.begin(), formula.end(), key,varContent);
}
Donc ici, je parcour une std::map et je cherche a remplacer des occurrences dans une std::string formula.

Comme vous pouvez le voir key et varContent sont tout deux des string.
Malheureusement, lors de la compilation j'obtiens des erreurs de ce type:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
c:\Program Files\Visual Basic Express\VC\include\algorithm(898) : error C2784: 'bool std::operator ==(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'char'
        c:\Program Files\Visual Basic Express\VC\include\xtree(1453) : see declaration of 'std::operator =='
        c:\Program Files\Visual Basic Express\VC\include\algorithm(907) : see reference to function template instantiation 'void std::_Replace<char*,_Ty>(_FwdIt,_FwdIt,const _Ty &,const _Ty &)' being compiled
        with
        [
            _Ty=std::string,
            _FwdIt=char *
        ]
        .\TrJsParser.cpp(34) : see reference to function template instantiation 'void std::replace<std::_String_iterator<_Elem,_Traits,_Alloc>,std::string>(_FwdIt,_FwdIt,const _Ty &,const _Ty &)' being compiled
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Alloc=std::allocator<char>,
            _FwdIt=std::_String_iterator<char,std::char_traits<char>,std::allocator<char>>,
            _Ty=std::string
        ]
Il me dit qu'il n'arrive pas a déterminé le template.....
Donc avez vous une idée de la source du problème ?

Je vous remercie d'avance pour vos lumières