By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,156 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,156 IT Pros & Developers. It's quick & easy.

Compiler bug w/ partial function template specialization w/ multiple parameters

P: n/a
Here is a very simple piece of code to repro this bug.

template<typename T, int N> inline bool foo( void )
{
return true;
}

template<typename T> inline bool foo<T, 1>( void )
{
return false;
}

the partial specialization of foo fails to compile w/:
error C2768: 'foo' : illegal use of explicit template
arguments
I believe the above should compile fine. At the very
least it is inconsistent because doing the same thing
using either
A) classes
or
B) a template function w/ just one parameter
or
C) specializing both parameters
compiles. i.e., all of the below compile fine
1)
template<typename T, int N> class C
{
public:
inline static bool foo( void )
{
return true;
}
};

template<typename T> class C<T, 1>
{
public:
inline static bool foo( void )
{
return false;
}
};

2)
template<> inline bool foo<float, 1>( void )
{
return false;
}

3)
template<int N> inline bool foo( void )
{
return true;
}

template<> inline bool foo<1>( void )
{
return false;
}

What is the best way to submit this bug to the compiler
group at MS? BTW, I'm running MS VC++ 7.1.3088

Thanks,
Michael Stembera
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Mon, 24 Nov 2003 10:29:34 -0800, "Michael Stembera"
<m_********@yahoo.com> wrote:
Here is a very simple piece of code to repro this bug.

template<typename T, int N> inline bool foo( void )
{
return true;
}

template<typename T> inline bool foo<T, 1>( void )
{
return false;
}

the partial specialization of foo fails to compile w/:
error C2768: 'foo' : illegal use of explicit template
arguments
Right, there is no such thing as partial function specialization
(overloading provides similar facilities).
I believe the above should compile fine. At the very
least it is inconsistent because doing the same thing
using either
A) classes
Yup, partial template specialization is a class thing.
or
B) a template function w/ just one parameter
Complete specialization is fine.
or
C) specializing both parameters
compiles. i.e., all of the below compile fine
Again, that's complete specialization.

What is the best way to submit this bug to the compiler
group at MS? BTW, I'm running MS VC++ 7.1.3088


You could submit a feature request at comp.std.c++. It's not a bug,
but simply a feature that the standard C++ language lacks.

Tom
Nov 16 '05 #2

P: n/a
tom_usenet wrote:
On Mon, 24 Nov 2003 10:29:34 -0800, "Michael Stembera"
<m_********@yahoo.com> wrote:

What is the best way to submit this bug to the compiler
group at MS? BTW, I'm running MS VC++ 7.1.3088


You could submit a feature request at comp.std.c++. It's not a bug,
but simply a feature that the standard C++ language lacks.


Partial specialization of function templates is a feature likely to be
included in the next revision of the C++ standard, expected in 5 years (!)
or so. Until then, the OP will have to find another way, or pressure
vendors (such as MS) to implement a non-conforming extension to support PTS
for function templates.

-cd
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.