Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2005

Tip: Looking for answers? Try searching our database.

VC++ Delegate Options

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob Schieber - 21 Oct 2005 18:05 GMT
Hey,

I need to utilize function pointers in my MFC application.  I was
wondering what the best approach is.  Im a C# developer, so I'm farily
comofortable using delegates.

So far I've found a library called boost.function
http://www.boost.org/doc/html/function.html which looks easy to use
simillar to delegates.  Just wondering if there's anything better out there.

Signature

Rob Schieber

Carl Daniel [VC++ MVP] - 21 Oct 2005 19:50 GMT
> Hey,
>
[quoted text clipped - 6 lines]
> simillar to delegates.  Just wondering if there's anything better out
> there.

If you want something like delegates, boost::function is a good way to go.

-cd
Tamas Demjen - 21 Oct 2005 22:01 GMT
> So far I've found a library called boost.function
> http://www.boost.org/doc/html/function.html which looks easy to use
> simillar to delegates.  Just wondering if there's anything better out
> there.

If you're interested about the internals of implementing delegates in
native C++, you may want to take a look at my article at
http://tweakbits.com/articles/events/index.html

No, I'm not saying it's better than boost::function. However, my article
provides an in-depth explanation of how these delegate (closure)
templates work internally. In fact, I provided two independent solutions
for the same problem. When I started implementing it, boost::function
did not exist, or at least was not publically available yet. The best
thing about my implementation is that it is very small. It only uses 2
pointers, and therefore sizeof(event) = 2 * sizeof(void*), which is the
theoretical minimum (an event must store the address of both the member
function and the object as well). I don't know how it compares to
boost::function's memory requirements, but these days it's not that
important anymore.

Boost has a very nice, generally accepted, multi-platform
implementation, with a wide user-base. I encourage you to use that. My
opinion is that if something is implemented in STL or boost, and it
works for me, I could hardly find a reason not to use it.

Tom
Rob Schieber - 22 Oct 2005 00:55 GMT
>> So far I've found a library called boost.function
>> http://www.boost.org/doc/html/function.html which looks easy to use
[quoted text clipped - 4 lines]
> native C++, you may want to take a look at my article at
> http://tweakbits.com/articles/events/index.html

I'll check out that article, as well as boost then thanks for the input
guys.

--
Rob Schieber

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.