
16 Jul
2005
16 Jul
'05
4:43 p.m.
"David Abrahams" writes
Whoa; smart pointers and boost::optional are not very closely related beasts.
I mean, a weak_ptr and optional both have 0 or 1 pointees, so there is at least a passing resemblance.
Merely a syntactic one. optional is not a smart pointer; it just uses * and -> to provide access to its contained object.
But also semantically. A smart pointer with a "copy on assignment" policy would behave in almost exactly the same way.
In the absence of Boost, I would probably use a std::auto_ptr to store an optional field, which is, um, a smart pointer. I realize that Optional is implemented slightly differently.
I wouldn't characterize it as a "slight" difference.
Okay, "completely". Just an expression... :-) Calum