Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-03-05 11:11:51

----- Original Message -----
From: "Ed Brey" <brey_at_[hidden]>
> > Won't work with VC6, even after you fix it up as follows:
> >
> > template<typename Y>
> > shared_array(const shared_array<Y>& r):
> > px(r.px) {
> > BOOST_STATIC_ASSERT((is_same<T,remove_cv<Y>::type>::value)); ++*(pn =
> >; }
> My intention was to point out a possible solution that avoids use of
> assertions when used on conforming compilers.

Why write the code twice?

> Using proper type_traits
> notaion, the shared_array member template would look like this:
> template<typename Y> // Note that Y is a dummy.
> shared_array(const shared_array<remove_cv<T>::type>& r):
> px(r.px) { ++*(pn =; }
> Assuming that this works

It doesn't. Don't you want to convert shared_ptr<volatile T> to
shared_ptr<const volatile T>?

>, then the question becomes "Is there any value in
> avoiding a static assertion?" It avoids the dependency on the static
> assertion library and just seems a little cleaner to only allow in what
> wants rather than allow too much and then check for correctness.

I don't buy it, sorry! You will already depend on type_traits, which is a
/far/ more complicated library. Also, assertions are good, and I don't want
to encourage people to shrink from using them.

> I realize that this method won't work for VC6, due to lack of partial
> specialization. For VC6, your proposed is_same workaround seems like the
> way to go. It's up to the library maintainer whether the preference is to
> use as common of code as possible, versus use ideal world code when
> replaced by workarounds as needed for broken compilers, so long as the
> result is the same. Here the result is very nearly the same, differing
> in a library dependency that would unnecessarily exist on a conforming
> platform if it shared code that required the dependency to work on a
> non-conforming platform.

But wouldn't it be better for people writing cross-platform code if the
result were /precisely/ the same?


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