Boost logo

Boost :

From: Phil Bouchard (philippe_at_[hidden])
Date: 2008-04-17 05:11:00


"Steven Watanabe" <watanabesj_at_[hidden]> wrote in message
news:48063795.5050100_at_providere-consulting.com...

[...]

>> Sorry for the quick email... I have to go but it clears everything up the
>> heap, there is no possible cyclicism.
>>
>
> really?
>
> #include <boost/shifted_ptr.hpp>
>
> #include <vector>
> #include <iostream>
>
> static int count;
>
> struct X {
> X() {
> ++count;
> }
> ~X() {
> --count;
> }
> X(const X& other) : vec(other.vec) {
> ++count;
> }
> std::vector<boost::shifted_ptr<X> > vec;
> };
>
> int main() {
> {
> boost::shifted_ptr<X> x = boost::new_sh<X>();
> x->vec.push_back(x);
> }
> std::cout << count << std::endl;
> }

Ok that's a good point. My routines delimits the heap segment using an
overriden owned<>::operator new. If this operator new isn't used then
shifted_ptr will think the object resides on the stack or data frames;
vector<> uses the global operator new. I'll figure out something else.

I have discovered also another bug related to the set counter. Now Vault
contains the corrected version.

Regards,
-Phil


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk