Thanks. I changed the map to:
typedef map
::_K fn,struct std::less<class session_id>,class std::allocator
' being compiled c:\src\inc\Z.h(240) : see reference to class template instantiation 'std::map ,struct std::less<class session_id>,class std::allocator > >' being compiled c:\boost\function.hpp(452) : warning C4097: typedef-name 'base_type' used as synonym for class-name 'function ::fun ction2 ' c:\program files\microsoft visual studio\vc98\include\utility(26) : see reference to class template instantiation 'boost::function ' being compiled c:\program files\microsoft visual studio\vc98\include\xtree(28) : see reference to class template instantiation 'std::pair >' being compiled c:\program files\microsoft visual studio\vc98\include\map(46) : see reference to class template instantiation 'std::_Tree >,struct std::map ,struct std::less<class session_id>,class std::allocator ::_K fn,struct std::less<class session_id>,class std::allocator ' being compiled c:\src\inc\Z.h(240) : see reference to class template instantiation 'std::map ,struct std::less<class session_id>,class std::allocator > >' being compiled c:\boost\function.hpp(453) : warning C4097: typedef-name 'base_type' used as synonym for class-name 'function ::fun ction2 ' c:\program files\microsoft visual studio\vc98\include\utility(26) : see reference to class template instantiation 'boost::function ' being compiled c:\program files\microsoft visual studio\vc98\include\xtree(28) : see reference to class template instantiation 'std::pair >' being compiled c:\program files\microsoft visual studio\vc98\include\map(46) : see reference to class template instantiation 'std::_Tree >,struct std::map ,struct std::less<class session_id>,class std::allocator ::_K fn,struct std::less<class session_id>,class std::allocator ' being compiled c:\src\inc\Z.h(240) : see reference to class template instantiation 'std::map ,struct std::less<class session_id>,class std::allocator > >' being compiled
Z.obj - 0 error(s), 6 warning(s)
</warnings>
Tom Matelich
-----Original Message----- From: dick.bridges@tais.com [mailto:dick.bridges@tais.com] Sent: Thursday, September 26, 2002 7:57 AM To: Boost-Users@yahoogroups.com Subject: RE: [Boost-Users] bind: I just keep trying...
I'm trying to store member function pointers. For purposes of this discussion, the key is an int.
<context> X is the virtual base class for polymorphic message classes. all messages have a session-d attribute
Ys are instances of classes derived from a virtual message hanler base class. foo() is the message handler function.
Z is the 'message pump' that dispatches messages to Ys based upon the session-id.
Y instances insert make_pair(session-id, message_handler) pairs into the map. (I think _1 is 'this' during the insert.)
Z calls the Y instance message-handler using the session-id key to the map. </context>
Mark Storer
.com> cc:
Subject: RE: [Boost-Users] bind: I just keep trying...
09/25/2002 04:47
PM
Please respond
to Boost-Users
I'm a little confused as to what you're aiming for here... a map of ints to function pointers (that can point to Y::foo)?
This should do the trick, provided I'm recalling my function pointer declarations correctly std::map
Further boost::bind creates an INSTANCE of a functor. Giving the compiler an instance when it wants a type is not a good way to keep it happy.
Now if what you're actually after is calling Y::foo on a colleciton of Y's, then you don't need a collection of function pointers for each instance in the first place, which is where bind comes in. According to my flimsy understanding of bind (I haven't used it yet), this should do the trick:
X someX; std::vector<Y> &wise = BuildYs(); // wise == plural of Y
std::for_each( wise.begin(), wise.end(), boost::bind<short>(&Y::foo, &someX) );
If you want the X parameter to vary from one call of foo to the next, I suggest rolling your own loop... or incorporating the X* into Y, at which point you can get rid of the X* parameter, and use boost::bind(&Y::foo), or std::mem_fun(&Y::foo).
--Mark Storer Software Engineer Cardiff Software
#include <disclaimer> typedef std::disclaimer<Cardiff> Discard;
-----Original Message----- From: dick.bridges@tais.com [mailto:dick.bridges@tais.com] Sent: Wednesday, September 25, 2002 4:08 PM To: boost-users@yahoogroups.com Subject: [Boost-Users] bind: I just keep trying...
Everytime I think I have a clue, I'm reminded how little I REALLY understand.
<error compiler='VC6SP4'> 'map' : invalid template argument for '_Ty', type expected </error>
<snippet> struct X { }
struct Y { short foo(X*); }
struct Z { map
myMap; } </snippet> I thought I saw how to do this somewhere on the website but I sure can't find it now. Any help GREATFULLY appreciated.
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
------------------------ Yahoo! Groups Sponsor ---------------------~--> Home Selling? Try Us! http://us.click.yahoo.com/QrPZMC/iTmEAA/MVfIAA/EbFolB/TM -------------------------------------------------------------- -------~->
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
----------------------------------------------------------------------- DISCLAIMER: Information contained in this message and/or attachment(s) may contain confidential information of Zetec, Inc. If you have received this transmission in error, please notify the sender by return email. ----------------------------------------------------------------------- Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/