Click here to Skip to main content
15,867,594 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionHow to make tool bar for outlook express Pin
curious_keen7-Aug-04 1:10
curious_keen7-Aug-04 1:10 
QuestionHow to make tool bar for outlook express Pin
curious_keen7-Aug-04 1:09
curious_keen7-Aug-04 1:09 
GeneralAlex Kolesnichenko's "Building Rich COMponents with Attributed ATL" Pin
Rob Severin6-Aug-04 15:13
Rob Severin6-Aug-04 15:13 
GeneralPre-Allocating stl maps / multimaps Pin
Jabin Reinhold4-Aug-04 4:35
Jabin Reinhold4-Aug-04 4:35 
GeneralRe: Pre-Allocating stl maps / multimaps Pin
gokings9-Aug-04 2:17
gokings9-Aug-04 2:17 
GeneralRe: Pre-Allocating stl maps / multimaps Pin
gokings9-Aug-04 8:03
gokings9-Aug-04 8:03 
GeneralRe: Pre-Allocating stl maps / multimaps Pin
Jörgen Sigvardsson20-Aug-04 9:32
Jörgen Sigvardsson20-Aug-04 9:32 
QuestionVC6 compiler limits with STL's mem_fun? Pin
T.T.H.28-Jul-04 23:03
T.T.H.28-Jul-04 23:03 
Hi
I need a little (or big...) help with my Visual C++ 6.0 compiler because I guess I found a C++ programm using some STL functions which my compiler does not understand. Basically it's about the functions from STL called "mem_fun_ref" and "mem_fun".

In short, I do not get the following little program to get compiled:

/* The following code example is taken from the book
* "The C++ Standard Library - A Tutorial and Reference"
* by Nicolai M. Josuttis, Addison-Wesley, 1999
*
* (C) Copyright Nicolai M. Josuttis 1999.
* Permission to copy, use, modify, sell and distribute this software
* is granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied
* warranty, and with no claim as to its suitability for any purpose.
*/
//#define mem_fun1 mem_fun
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>


class Person {
private:
std::string name;
public:
//...
void print () const {
std::cout << name << std::endl;
}
void printWithPrefix (std::string prefix) const {
std::cout << prefix << name << std::endl;
}
};

void foo (const std::vector<Person>& coll)
{
using std::for_each;
using std::bind2nd;
using std::mem_fun_ref;

// call member function print() for each element
for_each (coll.begin(), coll.end(),
mem_fun_ref(&Person::print));

// call member function printWithPrefix() for each element
// - "person: " is passed as an argument to the member function
for_each (coll.begin(), coll.end(),
bind2nd(mem_fun_ref(&Person::printWithPrefix),
"person: "));
}


void ptrfoo (const std::vector<Person*>& coll)
// ^^^ pointer !
{
using std::for_each;
using std::bind2nd;
using std::mem_fun;

// call member function print() for each referred object
for_each (coll.begin(), coll.end(),
mem_fun(&Person::print));

// call member function printWithPrefix() for each referred object
// - "person: " is passed as an argument to the member function
for_each (coll.begin(), coll.end(),
bind2nd(mem_fun(&Person::printWithPrefix),
"person: "));
}


int main()
{
std::vector<Person> coll(5);
foo(coll);

std::vector<Person*> coll2;
coll2.push_back(new Person);
ptrfoo(coll2);
}

Hint: the first compiler error could be ""solved"" by removing the "const" from "void print () const {".

Nevertheless I get the following errors:

E:\myProjects\memfun1\memfun1.cpp(45) : error C2784: 'class std::mem_fun_ref_t<_R,_Ty> __cdecl std::mem_fun_ref(_R (__thiscall _Ty::*)(void))' : could not deduce template argument for '<Unknown>' from 'void (__thiscall Person::*)(class std::basic_st
ring<char,struct std::char_traits<char>,class std::allocator<char> >) const'
E:\myProjects\memfun1\memfun1.cpp(64) : error C2784: 'class std::mem_fun_t<_R,_Ty> __cdecl std::mem_fun(_R (__thiscall _Ty::*)(void))' : could not deduce template argument for '<Unknown>' from 'void (__thiscall Person::*)(class std::basic_string<cha
r,struct std::char_traits<char>,class std::allocator<char> >) const'

The g++ compiler under Linux simply compiles it without problems...

Any help very welcome!

Bye,
T.T.H.

---------------------------------------------

UPDATE:

I hate it when that happens: I search the net for one hour then post the question here and 5 seconds afterwards I find the answer myself...

http://www.gamedev.net/community/forums/topic.asp?topic_id=187903&forum_id=21

So basically it's a problem with the STL implementation of VC6.0.

T.T.H.
AnswerRe: VC6 compiler limits with STL's mem_fun? Pin
Kevin McFarlane7-Aug-04 8:16
Kevin McFarlane7-Aug-04 8:16 
GeneralATL Composite Control print - HOW TO Pin
VKatti27-Jul-04 5:56
VKatti27-Jul-04 5:56 
Generalconflict between ATL and MFC Pin
Anonymous25-Jul-04 20:57
Anonymous25-Jul-04 20:57 
GeneralRe: conflict between ATL and MFC Pin
Kevin McFarlane7-Aug-04 3:14
Kevin McFarlane7-Aug-04 3:14 
GeneralRe: conflict between ATL and MFC Pin
Jörgen Sigvardsson7-Aug-04 7:57
Jörgen Sigvardsson7-Aug-04 7:57 
GeneralRe: conflict between ATL and MFC Pin
gokings9-Aug-04 2:22
gokings9-Aug-04 2:22 
GeneralRe: conflict between ATL and MFC Pin
Kevin McFarlane28-Aug-04 0:18
Kevin McFarlane28-Aug-04 0:18 
QuestionHow to map WM_CHAR messages for a modeless dialog Pin
asimeqi23-Jul-04 11:16
asimeqi23-Jul-04 11:16 
GeneralOLEDB question... Pin
CherezZaboro23-Jul-04 5:34
CherezZaboro23-Jul-04 5:34 
GeneralRe: OLEDB question... Pin
palbano23-Jul-04 8:13
palbano23-Jul-04 8:13 
GeneralATL Container HOW TO Pin
vishalmore22-Jul-04 21:51
vishalmore22-Jul-04 21:51 
GeneralRe: ATL Container HOW TO Pin
Anonymous23-Jul-04 8:34
Anonymous23-Jul-04 8:34 
GeneralComposite Control and Slider EDGE Pin
Balkrishna Talele22-Jul-04 19:32
Balkrishna Talele22-Jul-04 19:32 
GeneralWTL Pin
asv21-Jul-04 4:54
asv21-Jul-04 4:54 
GeneralWTL Drag And Drop Pin
18-Jul-04 19:28
suss18-Jul-04 19:28 
Questionhow to create multipane status bar in Dialog window ? Pin
Mandalay18-Jul-04 4:51
Mandalay18-Jul-04 4:51 
QuestionHow to change/set text color in RichEditCtrl/CRichEditCtrlView ??? Pin
M Bandu17-Jul-04 7:08
M Bandu17-Jul-04 7:08 

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.