Boost logo

Boost :

From: Michael Marcin (mmarcin_at_[hidden])
Date: 2007-04-12 15:11:21


Jody Hagins wrote:
> On Thu, 12 Apr 2007 11:46:03 -0500
> "Michael Marcin" <mmarcin_at_[hidden]> wrote:
>
>>
>> template <typename T, std::size_t N>
>> struct tag_of<boost::array<T, N> > {};
>
> Now you have defined the template. All non specialized stucts tag_of
> will be defined as an empty class. By simply declaring it, the onus
> is
> now on another piece of code to properly define the template. Someone
> can still provide a "general" definition, but it's very possible that
> specializations are the true desire.
>
> If you want an empty stuct to be the default template, then you can
> use
> the above. If, however, you want to force the template definitions
> then simply provide the forward declaration.
>
> With the forward declaration, if a user tries to use the struct in a
> non-specialized way, a compiler error will result, which is good. You
> don't want the user to get default "nothing" behavior from a typo.
>
>
> Does that make any sense at all?

Maybe.

IIUC what that forward declared partial specialization is doing is akin to
saying:
- I know the default implementation of tag_of can't be correct for
boost::array<T,N>
- There should be an implementation of tag_of that will make it work for
boost::array<T,N>
- I don't know what that implementation is, you or someone else better
provide it

Is it then true that when proper definition of the partial specialization is
provided this partial specialization of the declaration has no effect
whatsoever?

If that is true and this is a compiler bug then perpahs we can use a
configuration macro like BOOST_NO_DECLARTION_PARTIAL_SPECIALIZATION to
simply omit these these forward declarations on compilers that choke on them
(like CW 9.4 apparerently does).

Thanks,

Michael Marcin


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