Boost logo

Boost Users :

Subject: Re: [Boost-users] C++ gurus - really dumb question regarding partial speciallization.
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2012-12-19 14:31:16


On Wed, 19 Dec 2012, Robert Ramey wrote:

> I've got the following code which fails to compile. I'm really stumped by
> this.
> I've consulted the standard document on the subject and for the life of me
> I can't see anything wrong with it. It fails with the same message on vc
> 9.0
> as well as gcc 4.5.3. It's so simple it can't be a compiler issue.
>
> I appoligize in advance for spaming the list here - but I'm really, really
> stuck.
>
> Robert Ramey
>
> // primary template
> template<
> class T,
> int MIN,
> int MAX
>>
> struct safe_range1{};
>
> // instantiate primary as a test
> safe_range1<int, 0, 1> t1;
>
> // partial specialization # 1
> template<
> int MIN,
> int MAX
>>
> struct safe_range1<int, MIN, MAX>{};
>
> // instantiate partial specialization - what the ???
> // fails with "too few template parameters" !!!
> safe_range1<0, 1> t2;
>
> // partial specialization # 2
> template<class T>
> struct safe_range1<T, 0, 1> {};
>
> // also fails with "too few template parameters" !!!
> safe_range1<int> t3;

Your template, and all of the partial specializations, have three
parameters and no defaults. Partial specialization #1 just states that
when int is used as the first argument to safe_range1, it will use that
case, but that doesn't change the parameter type.

-- Jeremiah Willcock


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net