Boost logo

Boost :

From: Giora Unger (Giora_at_[hidden])
Date: 1999-12-28 12:55:01

Thanks for all the answers I received. I have some
new issues to raise:

1. Creation on stack
It is clearly stated, and is reasonable, that Smart Pointers are good
only for dynamically allocated objects. Alas, a major problem can be
caused, if creation on stack is possible. Consider this:

void f()
        MyClass mc;
        boost::shared_ptr<MyClass> pmc(&mc);

void g(boost::shared_ptr<MyClass> p_pMy)

The above code will result in a loud crash, of course.
I guess you already encountered the problem, and I'd like to know what's
your recommendation regarding the desired solution:
a. Shall I prevent stack creation ?! I don't think it's elegant. Am I wrong
b. Should conventions given to my programmers suffice ?

Any ideas are most welcomed.

2. Multi-threading
I see that the reason for non-thread-safe implementation is the platform
independence issue. OK.
So, I have a concrete question regarding my application, that uses the boost
smart pointers. I'm developing on WindowsNT, with MSVC++6.0.
I plan to use Win32 API critical sections, for making the shared_ptr
(as Dave wrote, it seems like the line discussed above is the only needed
Is there any flaw in this ?
Andy - you said most compilers won't have a problem with the code I pointed
at. Do you know, by any chance, if MSVC++6.0 handles it correctly ?

3. User-defined conversions
Greg - I might have missed some previous discussions about this issue, but
I'd like to mention Scott Meyers excellent "More Effective C++",
item 5 (pages 24-31). He fiercely advocates for NOT using user-defined
conversions. I was convinced...

Dave suggested using
    #if defined(BOOST_NO_MEMBER_TEMPLATES) \

but no comments were given.
Actually, I commented out line 168 in config.h -
and didn't notice any change in my test program (which includes the
basic boost test, and adds many more tests).

Do you think I shall use the above idea ?
What's the point in this variable anyway ?

Thank you all again,

Giora Unger
Radcom Ltd.
Tel.: 972-3-6455186
Fax: 972-3-6474681

Boost list run by bdawes at, gregod at, cpdaniel at, john at