
On Mon, Aug 07, 2006 at 10:20:37AM -0400, David Abrahams wrote:
Sascha Krissler <boost-dev@k.datenfreihafen.de> writes:
Another solution would be to make a detail::generic_optional with all the operator foo and let optional inherit from it. That would be infinitesimal backward-incompatible ;)
I would use a simple metafunction to transform a type T into a type with a null value:
template <class T> struct nullable { typedef boost::optional<T> type; };
template <class T> struct nullable<T*> { typedef T* type; };
// other specializations for types with built-in NULL values
This way you're really not incurring any overhead for types that are already nullable. Use free functions to smooth out any messy interface differences due to the optional<T> wrapper on some types.
That's what i am doing right now. The messy interface differences could be smoothed out by optional<>. If i had to implement all the interface of OptionalPointee again that would be a lot of duplication whether changing optional would be a couple of mpl::if_. Well i will not wait for a new release of boost to solve my poblem anyway it is a suggestion to improve the genericity of the lib.