Re: partial template specialization

From: skscpp (sksjava_at_hotmail.com)
Date: 10/01/03


Date: Wed, 1 Oct 2003 16:31:22 -0500


"Mike Wahler" <mkwahler@mkwahler.net> wrote in message
news:7qHeb.11595$NX3.3708@newsread3.news.pas.earthlink.net...
>
> "skscpp" <sksjava@hotmail.com> wrote in message
> news:blfemf$ml3$1@news.lsil.com...
> > Here is the code that I currently have:
> >
> > template <typename type, typename ret>
> > struct XdrFunctionType
> > {
> > typedef type Type;
> > typedef ret (*Policy)(XDR*, Type*);
> > };
> >
> > template <typename type, typename ret, typename XdrFunctionType<type,
> > ret>::Policy>
> > struct XdrPolicy
> > {
> > typedef type Type;
> > typedef XdrFunctionType<type, ret>::Policy Policy;
> > };
> >
> > =====================
> >
> > I want to specialize XdrPolicy template for ret type of bool and ret
type
> of
> > bool_t.
> > In other words, I don't want the clients of XdrPolicy to have to enter 3
> > template parameters but rather only two: the "type" and the "Policy"
> > function. I want the "ret" type to be implicitly known somehow - is
that
> > possible with what I have or with slight variation from it.
>
> Perhaps I'm misunderstanding, but note that template
> arguments can be defaulted. If you want to default
> only one of three, it needs to be last.
>
> template<typename A, typename B, typename C = T>
>
> -Mike

You are correct. However, my third parameter depends on my 2nd paramater.
I guess there isn't a way to overcome this. Well, I don't necessarily have
to use "default argument" scheme.

Thanks.