Partial template specialization is a particular form of class template specialization. Usually used in reference to the C++ programming language, it allows the programmer to specialize only some arguments of a class template, as opposed to explicit specialization, where all the template arguments are provided.
Questions tagged [partial-specialization]
316 questions
4
votes
2 answers
partial template template vector specialization
I have a general function that handles different containers.
template class C, class T, class A>
void handle(C const& c)
{
cout << "General handling\n";
}
Now I would like it to react differently if I pass it a…

turoni
- 1,345
- 1
- 18
- 37
4
votes
1 answer
Undefined reference to specialized template member
I have a class parameterized by a template template class with a static member function:
template class F>
struct A {
static int foo();
};
This class has no default definition for foo, and must be specialized for different…

Taylor
- 139
- 4
4
votes
2 answers
Template specialisation with default argument
I have a program that is as follows. There is a base template struct X and a partial specialisation with SFINAE.
template
struct X{
X() {
std::cout << "in 1" << std::endl;
};
};
template
struct…

Raees Rajwani
- 487
- 5
- 18
4
votes
1 answer
Partial specialization of nested class on enum defined inside a template class
Please see the following code:
template
struct X {
enum class E { e0 };
template
struct Y {};
template
struct Y {
static int f() { return 0; }
};
};
int main() {
X::Y

Junekey Jeon
- 1,496
- 1
- 11
- 18
4
votes
1 answer
decltype((void)T{}) in template Partial Specialization not deduce?
template
struct Test
{
static const int value = 0;
};
template
struct Test
{
static const int value = 2;
};
template
struct Test
{
…

fe263
- 121
- 1
- 7
4
votes
1 answer
Why can I partially specialize but can't fully specialize member templates in C++?
IMO, C++ template rules seem too restrictive and compiler implementation defined. But here I have a specific behavior I've had a hard time wrapping my head around.
In the following problem, I consciously try to avoid explicitly specializing the…

A__A
- 73
- 1
- 8
4
votes
2 answers
Partial specialization for pointers, c++
How to make partial specialization of the class GList so that it is possible to store pointers of I (i.e I*) ?
template
struct TIList
{
typedef std::vector Type;
};
template
class GList
{
private:
…

Woody
- 69
- 2
- 6
4
votes
3 answers
Partial member function template specialisation and data member access
I have a question regarding partial specialisation of templated member functions.
Background: The goal is to compute descriptive statistics of large datasets which are too large to be hold in memory at once. Therefore I have accumulator classes for…

Stefan
- 776
- 1
- 8
- 17
4
votes
1 answer
Ambiguous class template instantiation with nontype parameter packs
I was trying to specialize Expr:
#include
#include
#include
template
struct Expr {
Expr(){std::cout << "0"<< std::endl;};
};
//specialization #1
template
struct…

StefanKssmr
- 1,196
- 9
- 16
4
votes
1 answer
Condition in Template Definition
I want to change the return type of a template function depending on a property of the given type. Is there a possibility to do something like this, maybe with partial specialization (one for the cool T and one for not cool ones)?
template

PaulProgrammerNoob
- 624
- 6
- 19
4
votes
1 answer
boost::hana tag_of implementation
I wonder how the when specialization work when there's no case base for the boost::hana::when case.
boost::hana::tag_of implementation:
template
struct when; // forward declaration only
template

ABu
- 10,423
- 6
- 52
- 103
4
votes
2 answers
Why is in-class partial specialization well-formed?
According to [temp.class.spec] 5/ (emphasis mine)
A class template partial specialization may be declared or redeclared
in any namespace scope in which the corresponding primary template may
be defined
This would suggest that partial…

W.F.
- 13,888
- 2
- 34
- 81
4
votes
2 answers
Partial specialising function template with templated argument
I've got a template function (for the sake of simplification, let's call it "add")
template
inline T add(const T a, const T b)
{
return a+b;
}
I can specialise it for certain types, but what I'd like to do is specialise it for a…

Hugh
- 726
- 1
- 6
- 25
4
votes
1 answer
Template method specialization for template type
Having template classes like this (it's simplified to get my point):
template class Wrapper
{
TYPE m_tValue;
void DoSomething();
};
template class Array
{
TYPE * m_pArray;
…

GPUquant
- 245
- 2
- 7
4
votes
1 answer
partial template specialization for template pointer to function
Consider the following abstract Subscription class:
template
class Subscription {
public:
virtual ~Subscription() {}
virtual bool handle(const TMessage &) = 0;
};
In some cases, it could be convenient if one class alone…

ArnonZ
- 3,822
- 4
- 32
- 42