Actually, My intention is to pass a shared_ptr, as against a raw ptr. The purpose is that after execting the callback, the shared_ptr can go out of scope, and ensure object deletion on its own, without having to call an explicit delete.
So, I really wanted to pass a shared_ptr to the callback fn, as a void*.
The reason behind this is...
- i have a 3rd party timer engine, which accepts a callback function and callback args.
- On timer expiry, it calls my regd callback implmentation, along with the args passed in its start_timer function.
- Earlier, I was passing an object* to the callback args of the timer.
- If the timer event fires, my callback impl gets called, and I get a chance to do a "delete", which is fine.
- In some cases, I have to cancel / stop the timer. And then since, my callback doesn't fire, I have no way to delete the obj*, and results in a memory leak.
So, I wanted to pass a shared_ptr itself as the callback argument for my 3rd party timer. So that, even if timer doesn't fire, my object won't leak.
regards,
RV
________________________________
From: "boost-users-request@lists.boost.org"
To: boost-users@lists.boost.org
Sent: Tuesday, 10 May 2011 4:15 PM
Subject: Boost-users Digest, Vol 2718, Issue 1
Send Boost-users mailing list submissions to
boost-users@lists.boost.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.boost.org/mailman/listinfo.cgi/boost-users
or, via email, send a message with subject or body 'help' to
boost-users-request@lists.boost.org
You can reach the person managing the list at
boost-users-owner@lists.boost.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Boost-users digest..."
Today's Topics:
1. Re: Error: guid_defined is not
templateBOOST_CLASS_EXPORT_GUID (Robert Ramey)
2. Re: [Boost][program-options] Original position of an argument
in command-line. (Vladimir Prus)
3. How to cast a boost::shared_ptr to void* (Mupparthy Ravindranath)
4. Re: How to cast a boost::shared_ptr to void* (Robert Jones)
5. Re: How to cast a boost::shared_ptr to void* (michi7x7)
6. Re: How to cast a boost::shared_ptr to void*
(Mupparthy Ravindranath)
7. Re: How to cast a boost::shared_ptr to void* (Robert Jones)
8. Re: [Boost][program-options] Original position of an argument
in command-line. (Germ?n Diago)
----------------------------------------------------------------------
Message: 1
Date: Mon, 9 May 2011 21:57:06 -0800
From: "Robert Ramey"
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] Error: guid_defined is not
templateBOOST_CLASS_EXPORT_GUID
Message-ID:
Jari wrote:
Hi
I am using boost serialization and it was working fine (save load
works) but then I tried using BOOST_CLASS_EXPORT_GUID and get weird
error.
The line that gives the error is this:
BOOST_CLASS_EXPORT_GUID( Bakery, "Bakery")
(I put the code in Cpp to avoid any problems with headers.)
And this is the full Visual studio express 2010 error:
2>E:\boost_1_46_1\boost/archive/detail/check.hpp(162): error C2338:
typex::value
...
what does the code look like at line 162 of check.hpp ?
Robert Ramey
------------------------------
Message: 2
Date: Tue, 10 May 2011 10:45:04 +0400
From: Vladimir Prus
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [Boost][program-options] Original position
of an argument in command-line.
Message-ID:
Content-Type: text/plain; charset="UTF-8"
Germ?n Diago wrote:
Hi all. I have a question regarding boost.program_options.
I want to parse a command-line but I want to know the order in which
each option appeared in the
command line. Is this possible? Thanks in advance.
parse_command_line returns vector< basic_option<charT> >, which
are in the order of occurence. This is a point where you can do
logic based on the order. variables_map does not store order
information.
HTH,
--
Vladimir Prus
Mentor Graphics
+7 (812) 677-68-40
------------------------------
Message: 3
Date: Tue, 10 May 2011 13:26:09 +0530 (IST)
From: Mupparthy Ravindranath
To: "boost-users@lists.boost.org"
Subject: [Boost-users] How to cast a boost::shared_ptr to void*
Message-ID: <257490.53596.qm@web94803.mail.in2.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi all,
My requirement is to cast an object of type shared_ptr as void*, so that I can send it to a callback function that accepts a void*.? I cannot change callback the function signature because it is part of an existing legacy code.
In the existing code, I am sending a raw object pointer (instead of shared_ptr).? Now, if I want to pass a shared_ptr, it won't compile because I cannot cast the shared ptr to void*.?
Can anyone suggest some workaround for this.? I tried searching the mailing lists and internet, but not much luck.
regards,
RV