Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-07-08 16:59:35


"David B. Held" <dheld_at_[hidden]> wrote in message
news:cckeh3$fd0$1_at_sea.gmane.org...
> Jonathan Turkanis wrote:
> > [...]
> > Could you pull the definition of nested outside of sp
> >
> > template<typename P1, typename P2, typename T>
> > struct sp_nested { };
> >
> > then use a metafunction within sp:
> >
> > template<typename P1, typename P2>
> > struct sp {
> > template<typename T>
> > struct nested {
> > typedef sp_nested<P1, P2, T> type;
> > };
> > };
> > [...]
>
> For syntax reasons, this is an undesirable solution.

I 'm not sure I see the syntax problem; if you mean that it's more
cumbersome to use a metafunction, I agree.

> Although,
> you could get pretty close by modifying it a little:
>
> template<typename P1, typename P2>
> struct sp {
> template<typename T>
> struct nested : sp_nested<P1, P2, T>
> { };
> };

Then specializing less< ... > for sp_nested wouldn't affect the
implementation of less<nested>.

<snip>

> The problem is that sp_nested<> would be an implementation detail
> that I would not want to expose to the user. So I would not want
> the user to have to mention it in order to instantiate less<>.

I don't see the distinction between

   template <class P1, class P2, typename T>
   struct less<sp<P1, P2>::nested<T> >
        : binary_function<...>
   {
     bool operator()(...);
   };

and

   template <class P1, class P2, typename T>
   struct less<sp_nested<P1, P2, T> >
        : binary_function<...>
   {
     bool operator()(...);
   };

with respect to exposing implementation details.

Jonathan


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