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
0
votes
0 answers
Using a custom allocator for a given templatized type by default in stl containers
My particular use case is to try and cut back on the boiler-plate code required to use stl containers with Eigen for some of the newer developers I work with, but this question could be applied more generally. Idiomatic C++11 is preferred.
Given…

Walrus
- 405
- 4
- 10
0
votes
1 answer
c++11 partial class specialization using already implemented methods
assuimng this example code
#include
#include
#include
#include
template< typename T, typename S >
class MyClass
{
public:
MyClass () : v(10) {}
bool ok () { return true; }
T run (S s, int i) {…

petrbel
- 2,428
- 5
- 29
- 49
0
votes
1 answer
partial specified template class with nontype parameter in C++
In following code, I got an compiling error
#include
using namespace std;
template
class MyClass {
public:
void func1(){
cout<<"default: func1"<

Yan Zhu
- 4,036
- 3
- 21
- 37
0
votes
2 answers
Static Assert if template parameter is of a certain template class
How can I throw a static_assert if template of class A is of a certain templated class NOTALLOWED?
template
struct NOTALLOWED{
};
template
struct A{
// static_assert if T == NOTALLOWED<...> ??
}
// USING A<…

Gabriel
- 8,990
- 6
- 57
- 101
0
votes
1 answer
string to type function, template specialization to make call uniform
Is there a unique way to achieve a uniform call syntax for a convert function like the following for any kind of type? The function takes a string and converts it into the given TYPE (here int and MyMatrix::Vector3 , call by reference of…

Gabriel
- 8,990
- 6
- 57
- 101
0
votes
1 answer
Template partial specialisation and dependent names
Consider following
#include
template
struct C {
using value_type = T;
value_type f(value_type v);
};
template
auto C::f(value_type v) -> value_type {
return v;
}
int main(int argc,…

tomas789
- 1,280
- 1
- 9
- 21
0
votes
2 answers
Can i partially specizlize template for not all non-type parameters
template
struct T;
template<>
struct T, ?> {};
i want this to work
typedef T<1, 0> t;
and this to cause compile time error
typedef T<1, 2> t;
EDIT, i mean i want second parameter to be 0. and i can't use C++11 features.

Yola
- 18,496
- 11
- 65
- 106
0
votes
3 answers
C++ template specialization with not picking up an int
I have the following code:
template LuaCall& operator>>(T) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
template <> LuaCall& operator>>(int& val) { mResults.push_back(std::make_pair(LUA_RESULT_INTEGER, (void *)&val)); return *this;…

Andreas Bonini
- 44,018
- 30
- 122
- 156
0
votes
3 answers
Templated parameter for a template specialisation?
Hi I've got a static member of a templated class that I want defined for a sub group of classes that are templated ie:
template
class FooT
{
private:
static int ms_id;
};
template
class Foo {};
template<>…

user176168
- 1,294
- 1
- 20
- 30
0
votes
1 answer
Undefined reference to partial specialized template class function during link time
So I had an problem with partial specialization of function templates. I choose the solution described here: Question
Now I have this:
#include
#include
template struct helper {
static void print(T value) {…

Tim
- 5,521
- 8
- 36
- 69
0
votes
3 answers
A workaround for partial specialization of function template?
Consider the following metafunction for an integral pow (it is just an example) :
class Meta
{
template static constexpr T ipow(T x)
{
return (N > 0) ? (x*ipow(x))
: ((N < 0) ?…

Vincent
- 57,703
- 61
- 205
- 388
0
votes
2 answers
Partial specialisation of a method if pointer to a member function is NULL
I have got a template class with 2 parameters and a fancy push_back method:
template
class StorableVector {
public:
...
void push_back(Handle< Element > e) {
…

Yulia V
- 3,507
- 10
- 31
- 64
0
votes
1 answer
template partial specialization prevents initialization from derived class
I inherit from a template with partial specialization, and I can't call the template ctor from the derived ctor.
When the partial specialization in the code below is commented out, it compiles without any errors or warnings.
#include…

Mark
- 1,035
- 2
- 11
- 24
-1
votes
2 answers
C++ partial specialization of template without code duplication
I have a class definition with 3 template parameters. I would like to create specializations of this class with specific combinations of 2 of the parameters, leaving the third free. How can I do that without duplicating code?
template < typename A,…

bekoch
- 1
- 1
-1
votes
1 answer
How to define out of class functions for a class specialized using std::enable_if
I have a specialization of a class called graph which is enabled only if the input is a particular type. I am not able to define out of class definitions for the functions inside that class. This question os different from some other questions on…

yasht
- 195
- 1
- 15