Click here to Skip to main content
15,892,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionContext menu in TreeView control ?? Pin
Anonymous23-Sep-05 1:04
Anonymous23-Sep-05 1:04 
AnswerRe: Context menu in TreeView control ?? Pin
khan++23-Sep-05 1:27
khan++23-Sep-05 1:27 
GeneralRe: Context menu in TreeView control ?? Pin
Anonymous23-Sep-05 23:09
Anonymous23-Sep-05 23:09 
QuestionMDI without initial window Pin
tooho23-Sep-05 1:01
tooho23-Sep-05 1:01 
AnswerRe: MDI without initial window Pin
prasad_som23-Sep-05 1:56
prasad_som23-Sep-05 1:56 
AnswerRe: MDI without initial window Pin
vikas amin23-Sep-05 1:57
vikas amin23-Sep-05 1:57 
GeneralRe: MDI without initial window Pin
tooho23-Sep-05 3:26
tooho23-Sep-05 3:26 
Questionstd::multimap & std::find() Pin
Themis23-Sep-05 0:06
Themis23-Sep-05 0:06 
Hello, lets take a look at the STL.

We have
<br />
std::multimap<sth*, sth*> pairs;<br />
<br />
void remove(sth* s1, sth* s2)<br />
{<br />
  std::multimap<sth*, sth*>::iterator i;<br />
  if ((i = std::find(pairs.lower_bound(s1), pairs.upper_bound(s1), std::make_pair(s1, s2))) != pairs.end())<br />
    pairs.erase(i);<br />
}<br />


Well that doesn't work. I get MANY template compile errors (really hard to read, and rearly make any sense). I'll give you a small sample:

<br />
f:\Microsoft Visual Studio .NET 2003\Vc7\include\algorithm(31): error C2784: 'bool std::operator ==(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'std::allocator<_Ty>::value_type'<br />
        with<br />
        [<br />
            _Ty=std::pair<sth *const ,sth *><br />
        ]<br />
<br />
f:\Microsoft Visual Studio .NET 2003\Vc7\include\algorithm(31): error C2784: 'bool std::operator ==(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'std::allocator<_Ty>::value_type'<br />
        with<br />
        [<br />
            _Ty=std::pair<sth *const ,sth *><br />
        ]<br />
<br />
f:\Microsoft Visual Studio .NET 2003\Vc7\include\algorithm(31): 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 'std::allocator<_Ty>::value_type'<br />
        with<br />
        [<br />
            _Ty=std::pair<sth *const ,sth *><br />
        ]<br />


I think you get the idea. All the compile errors point inside std::find() where the arrow points:
<br />
template<class _InIt,<br />
	class _Ty> inline<br />
	_InIt find(_InIt _First, _InIt _Last, const _Ty& _Val)<br />
	{	// find first matching _Val<br />
	for (; _First != _Last; ++_First)<br />
---->		if (*_First == _Val)<br />
			break;<br />
	return (_First);<br />
	}<br />



I just can't understand where the problem is. Everythink looks fine to me, but obviously it isn't.

Anyother idea how am I supposed to erase a single pair from a std::multimap()? I can only find functions that erase all <key_value, mapped_value=""> pairs for a specified key but I just need to erase one of those pairs given a specified mapped_value.

That all,
Themis

PS - std::remove() also doesn't work as it relies on std::find() (at least in VS .NET 2003 implementation)

-- modified at 6:08 Friday 23rd September, 2005

PS2 - I don't know if you are already aware of that but the code tags of the forum are not rendered properly with the Firefox Browser.
AnswerOfftopic Pin
Jörgen Sigvardsson23-Sep-05 0:30
Jörgen Sigvardsson23-Sep-05 0:30 
GeneralRe: Offtopic Pin
Themis23-Sep-05 2:47
Themis23-Sep-05 2:47 
QuestionLinker Error Pin
rajeevktripathi22-Sep-05 23:43
rajeevktripathi22-Sep-05 23:43 
AnswerRe: Linker Error Pin
ThatsAlok23-Sep-05 0:05
ThatsAlok23-Sep-05 0:05 
AnswerRe: Linker Error Pin
MailtoGops23-Sep-05 0:11
MailtoGops23-Sep-05 0:11 
QuestionProgram Deployment Pin
mikobi22-Sep-05 23:19
mikobi22-Sep-05 23:19 
AnswerRe: Program Deployment Pin
Mircea Puiu23-Sep-05 2:52
Mircea Puiu23-Sep-05 2:52 
Questioninitialize stl map in static scope Pin
yccheok22-Sep-05 23:10
yccheok22-Sep-05 23:10 
AnswerRe: initialize stl map in static scope Pin
toxcct22-Sep-05 23:22
toxcct22-Sep-05 23:22 
GeneralRe: initialize stl map in static scope Pin
Cedric Moonen22-Sep-05 23:46
Cedric Moonen22-Sep-05 23:46 
GeneralRe: initialize stl map in static scope Pin
toxcct22-Sep-05 23:52
toxcct22-Sep-05 23:52 
GeneralRe: initialize stl map in static scope Pin
yccheok23-Sep-05 1:28
yccheok23-Sep-05 1:28 
GeneralRe: initialize stl map in static scope Pin
Laffis23-Sep-05 1:06
Laffis23-Sep-05 1:06 
GeneralRe: initialize stl map in static scope Pin
yccheok23-Sep-05 1:19
yccheok23-Sep-05 1:19 
AnswerRe: initialize stl map in static scope Pin
Tim Smith23-Sep-05 3:58
Tim Smith23-Sep-05 3:58 
AnswerRe: pointer to char array Pin
Eytukan22-Sep-05 23:02
Eytukan22-Sep-05 23:02 
GeneralRe: pointer to char array Pin
sunit523-Sep-05 2:56
sunit523-Sep-05 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.