Home > Archive > VC STL > February 2005 > Compiling Error C2784, C2676 using STL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Compiling Error C2784, C2676 using STL
|
|
| maersa 2005-02-14, 9:11 pm |
| hi all,
i'm getting an error when trying to insert items into a map.
// define types....
typedef std::basic_string< TCHAR > tstring;
typedef std::map< tstring, tstring> STRINGMAP;
typedef std::pair< tstring, tstring > StringPair;
class A
{
.....
STRINGMAP m_properties;
.....
}
in my code i do the following....
m_properties.insert( StringPair( _T("key"), _T("value") ) );
and get the following errrors.
-----------------------------------------------------------------------------------------------------------------
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\functional(139): error C2784: 'bool std::operator <(const
std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce
template argument for 'const std::_Tree<_Traits> &' from 'const tstring'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\functional(139): error C2784: 'bool std::operator <(const
std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce
template argument for 'const std::list<_Ty,_Ax> &' from 'const tstring'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\functional(139): error C2784: 'bool std::operator <(const
std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' :
could not deduce template argument for 'const std::reverse_iterator<_RanIt>
&' from 'const tstring'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\functional(139): error C2784: 'bool std::operator <(const
std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce
template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const tstring'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\functional(139): error C2676: binary '<' : 'const tstring'
does not define this operator or a conversion to a type acceptable to the
predefined operator
-----------------------------------------------------------------------------------------------------------------
thanks in advance.
| |
| Arnaud Debaene 2005-02-14, 9:11 pm |
| maersa wrote:
> hi all,
>
> i'm getting an error when trying to insert items into a map.
>
> // define types....
> typedef std::basic_string< TCHAR > tstring;
> typedef std::map< tstring, tstring> STRINGMAP;
> typedef std::pair< tstring, tstring > StringPair;
The pair type associated with a map is std::pair<const Key, Value>. Your
definition is throwing away the const on the key. You should better define :
typedef STRINGMAP::value_type StringPair;
Arnaud
MVP - VC
| |
| maersa 2005-02-14, 9:11 pm |
| hi Arnaud,
i tried what you've suggested, but i get the same error.
hmmmm....
"Arnaud Debaene" <adebaene@club-internet.fr> wrote in message
news:u6y28KRAFHA.3376@TK2MSFTNGP12.phx.gbl...
> maersa wrote:
>
> The pair type associated with a map is std::pair<const Key, Value>. Your
> definition is throwing away the const on the key. You should better define
> :
> typedef STRINGMAP::value_type StringPair;
>
> Arnaud
> MVP - VC
>
>
| |
| Ulrich Eckhardt 2005-02-14, 9:11 pm |
| maersa wrote:
> i tried what you've suggested, but i get the same error.
If you had taken the time to properly quote, people would now know which of
his suggestions you tried. Anyhow, since you still get the same error, the
error is not in the code you have shown.
read http://got.to/quote
Uli
| |
| Tom Widmer 2005-02-14, 9:11 pm |
| maersa wrote:
> hi Arnaud,
>
> i tried what you've suggested, but i get the same error.
> hmmmm....
You have #included <string>, right?
Tom
| |
| maersa 2005-02-14, 9:11 pm |
| thanks tom, that was the problem.
"Tom Widmer" <tom_usenet@hotmail.com> wrote in message
news:u96PEXgAFHA.3860@TK2MSFTNGP11.phx.gbl...
> maersa wrote:
>
> You have #included <string>, right?
>
> Tom
|
|
|
|
|