Boost logo

Boost :

From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2004-02-26 10:20:46


Jody Hagins <jody-boost-011304 <at> atdesk.com> writes:

>
> > Obviously, Kelvin does not want to make the ctor explicit, and even if
> he did, the change would most likely break existing code. However, some
> users may desire the pedantic behavior of an explicit constructor. What
> would be wrong with changing the ctor to be something like this...
>
> template<typename ValueType>
> #if defined(BOOST_ANY_HAS_EXPLICIT_CTOR)
> explicit
> #endif
> any(const ValueType & value)
> : content(new holder<ValueType>(value))
> {
> }
>
> then users can get the functionality if they want it, but, by default,
> you get the same behavior. Since the implementation is an inline member
> template, there should be no linking issues.
>
>

I'd say (I could be wrong, though) that this would
cause much trouble. You have two options for using your
proposed solution:

1. Define BOOST_ANY_HAS_EXPLICIT_CTOR globally in your
project, thus possibly breaking existing code (which might
lie deep inside Boost itself.)
2. Define the macro locally, thus possibly violating ODR.

In practise, chances are no problem arises since as
you point out the ctor is an inliner, but ODR is not
that permissive.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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