From: Ed Brey (brey_at_[hidden])
Date: 2001-03-07 11:15:00
1. Even though MSVC's member template support is non-conformant, it is
possible to use what does work to allow construction and assignment to a
shared pointer from a different but compatible type. This is achieved
by using a base class, which prevents MSVC from thinking that a member
template has already been defined.
2. Using member templates in VC has been reported to cause problems with
regard to exporting from a DLL. The exact nature of the problem, if
any, has not been identified. New info (non-summary): I tried using a
smart_ptr from the existing (no member templates) code in an exported
class, and VC gave me a warning straight away that there would be
problems, so it appears that DLL exporting is a separate significant
3. Shared_array currently does not support construction or assignment
from compatible types. In this context, compatible means types with
less restrictive cv qualifiers. The can be remedied through various
methods, of which using static assertions and the is_same type trait is
the most portable to nonconformant compilers.
Attached is an updated version of smart_ptr.hpp and, for convenience, a
diff versus the existing version. A couple notes on the updated
a. I have only lightly tested it with VC and gcc. It should be reviewed
and regression tested across supported platforms.
b. The workaround mentioned in item 1 above is guarded in conditional
compilation so that it only gets applied to MSVC. The reflects my
opinion that minimizing the complexity of code that is compiled on a
conforming platform is worth a small amount of code duplication.
However, others may weight avoidance of code duplication more heavily,
which is also fine.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk