C++ Logo

std-discussion

Advanced search

Partial specialization with only one template parameter in the primary template.

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Sat, 28 Sep 2019 16:29:48 +0300
In the Standard in teh section devoted partial specialization there is nothing said about cases when a primary template has only one template parameter. In this case sometimes it is impossible to declare a partial specialization and instead of a partial specialization we have an explicit specialization.

For example

#include <iostream>
namespace N
{
template <int>
struct A
{
A() { std::cout << "A<int>()\n" << '\n'; }
};
}
using N::A;
namespace N
{
template <>
struct A<10>
{
A() { std::cout << "A<10>()\n" << '\n'; }
};
}
int main()
{
A<1> a1;
A<10> a2;
}
How to define a partial specialization for template argument 10?

So I think the description of the section should point out such cases.

With best regards,
Vlad from Moscow


You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

Received on 2019-09-28 08:32:00