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
1 answer
Partial template specialization for variadic template where [Args...] is empty
I have a class, Delegate, declared like this:
template class Delegate;
template
class Delegate
{ /*...*/ };
It can be instantiated for a function returning a ReturnType and taking no arguments…

Conduit
- 2,675
- 1
- 26
- 39
4
votes
3 answers
Can I use partial template specialization for a (non-member) function?
I'm trying to use partial template specialization on a (non-member) function, and I'm tripping up on the syntax. I've searched StackOverflow for other partial template specialization questions, but those deal with partial specialization of a class…

Adrian McCarthy
- 45,555
- 16
- 123
- 175
4
votes
2 answers
Template partial specialization problems
I am trying to write a size and type generic vector class for math programming. I am having problems with partial specialization.
The problem occurs when I try to specialize a member method of my vector class for given size.
I can provide a simple…

F.L.
- 559
- 4
- 11
4
votes
3 answers
Template Partial Specialization - any real-world example?
I am pondering about partial specialization. While I understand the idea, I haven't seen any real-world usage of this technique. Full specialization is used in many places in STL so I don't have a problem with that. Could you educate me about a…

Khaled Alshaya
- 94,250
- 39
- 176
- 234
4
votes
3 answers
Function template specialization with a template class
Possible Duplicate:
partial specialization of function template
I can't find anywhere a solution for my problem, because if I search with the keywords I come up with would give me solutions suited for different problems. I understand that this…

Tim
- 5,521
- 8
- 36
- 69
4
votes
2 answers
can template alias be used for partial specialization?
Given a template alias
template
using uint_ = integral_constant;
The partial specialization of
template
struct size{};
as
template
struct size>{};
generates a warning…

abir
- 1,797
- 14
- 26
3
votes
2 answers
Is there a way a partial specialization is always preferred over the primary template?
I'm asking myself
Can you write a class template and a corresponding partial specialization such that for any set of template arguments for the parameters, the partial specialization is taken by the compiler?
For example
template

Johannes Schaub - litb
- 496,577
- 130
- 894
- 1,212
3
votes
1 answer
Template specialization for the base template type for future derived types
I have a class that works as wrapper for some primitives or custom types. I want to write explicit specialization for custom template type.
My code that reproduces the problem:
template < class T >
struct A {
void func() { std::cout <<…

Dmitry Golubev
- 33
- 3
3
votes
1 answer
Avoiding duplication of function definitions in partial template specializations when using traits
How does one share common_fn() among all specializations (for Widget > and Widget >, no matter what T is) in the code below?
#include
struct Afoo {};
struct Bfoo {};
template struct A { typedef Afoo Foo;…

Calaf
- 10,113
- 15
- 57
- 120
3
votes
4 answers
Why does C++ forbid this partial specialization?
Why does C++ forbid this partial specialization?
What kind of philosophy is behind this forbiddance, so I can accept it?
Programming would be much easier without this forbiddance.
Templates shall prevent redundances.
Now I have to produce redundance…

MBastieK
- 31
- 3
3
votes
2 answers
Partial template specialisation of a functor that's calling a member method of objects passed to it
I have the following functor and its partial specialisation
template
struct Caller
{
typedef _Return(_T::*Method)(_Arg);
Caller(Method pm, _Arg a)
: _pMethod(pm),
…

zyndor
- 1,418
- 3
- 20
- 36
3
votes
3 answers
Problem with C++ Partial Template Specialization
I have a situation similar to this:
template
class MyClass
{
...
static A RARELY_USED_A;
}
// Seems to work but does not cover all possible cases, since
// there may be instances of A that have no numeric…

b.buchhold
- 3,837
- 2
- 24
- 33
3
votes
1 answer
Too few template-parameter-lists problem
Can anybody please tell me how to make the following pseudo-code compatible with GCC4? I wonder how it works under MSVC...
typedef int TypeA;
typedef float TypeB;
class MyClass
{
// No base template function, only partially specialized…

Ryan
- 1,451
- 2
- 27
- 36
3
votes
2 answers
C++ partial template template specialization
I want to pass a partial template specialization to template template parameter but I'm getting an error. Im not sure why excatly this doesent work.
template class V, typename T, int N, int... Indexes>
class Swizzle
{
//…

sorte33
- 35
- 1
- 4
3
votes
2 answers
How to perform partial specialisation when two template parameters are of the same type?
How to partial specialization that two template parameter are same type.
How to make this code using second function .
#include
#include
template
void Translate(A&& a,B* b){
// make some translate…

Zhigang Zhang
- 195
- 1
- 7