Questions tagged [partial-specialization]

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.

316 questions
0
votes
1 answer

Partial specialization of nested template template class

I am currently struggeling with partial template specialization of a template template (template ) class. I know we can realize the following problem with inheritance but the goal is to use only templates and template specialization. Let's consider…
0
votes
2 answers

C++ Partial Template Specialization:Undeclared identifier error

The goal of writing this code was to get a better understanding of partial template specialization. I'm trying to partial specialize the class Vector with three different bools. I have an enum(for my bool) defined as: enum MY_BOOL { YES, NO, …
0
votes
1 answer

c++ pimpl idiom : Implementation depending on a template parameter

In this question I unsuccessfully asked how to use different pimpl implementation depending on a template argument. Maybe this example ilustrates better what I am trying to do : #include template< int N, typename T > struct B { B() :…
BЈовић
  • 62,405
  • 41
  • 173
  • 273
0
votes
0 answers

Why a fully specialized class template can't be defined in a non-fully specialized one?

Why a fully specialized class template can't be defined in a non-fully specialized one? template struct Wrapper { template struct Fun_ { constexpr static int vlaue = 0; }; template<> // error …
0
votes
1 answer

Split variadic parameter pack using template specialization

I'm trying to define a sort of template 'map' primitive (as in map-reduce). The idea is that I want to apply a function to every item of a template parameter pack. The function can be any callable object. It can return any type (though the return…
0
votes
1 answer

Partial specialization and the need for std::void_t<>

One for the language lawyers.... I'm playing around with SFINAE and TMP, trying to get a deeper understanding. Consider the following code, a naive implementation of std::is_default_constructible #include template
Greg
  • 393
  • 3
  • 7
0
votes
1 answer

Role of default template arguments in the context of partial specialization

I am not clear about the interaction of default template arguments in the context of partial specialization, for choosing which is the better matching template. This questions stems from code posted in this answer by max66. Given the definitions of…
Fabio
  • 2,105
  • 16
  • 26
0
votes
3 answers

C++ - Overload templated class method with a partial specilization of that method

There are a few questions already similar to this already on stack overflow, but nothing that seemd to directly answer the question I have. I do apologise if I am reposting. I'd like to overload a few methods of a templated class (with 2 template…
JBeFat
  • 907
  • 10
  • 20
0
votes
1 answer

How to correctly define a partial specialization for a member struct of a templated class?

I am getting an error when trying to add std::iterator_traits for a templated member struct - i.e. I have an iterator class which is a member of a templated outer class: namespace Toolbox { template class…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
0
votes
1 answer

Function template overloading - partial specialization

I have 2 classes that follow a similar pattern: Foo.h // header guard here class Foo { public: Foo() = delete; static foo1& getFoo1( Param a, Param b, Param c ) { // code... } static foo2& getFoo2( Param a, Param b, Param…
0
votes
1 answer

Specializing and or Overloading member function templates with variadic parameters

Trying to resolve overload resolution for class member: static function template overload - partial specialization. I currently have a class declared / defined as such: Note: my use of Param a, Param b, Param c etc. are not related to the actual…
0
votes
1 answer

Class member function template partial specialization with variadic parameters

I'm using Visual Studio 2017 CE version 15.6.2 with compiler language options set to: ISO C++ Latest Draft Standard (/std:c++latest) I'm working with a majority of the functions from and I have 2 classes that are non template classes,…
0
votes
2 answers

Partial template specialization type collapsing rules

Sorry for the lack of a better title. While trying to implement my own version of std::move and understanding how easy it was, I'm still confused by how C++ treats partial template specializations. I know how they work, but there's a sort of rule…
João Pires
  • 927
  • 1
  • 5
  • 16
0
votes
2 answers

How can this condition be put in template partial specialization?

template struct best_type { }; template struct best_type 8>> { // error: template argument 2 is invalid typedef byte type; }; The error is because of the…
0
votes
1 answer

Build error with template template parameter only after both members are parametrized

I am trying to pass a template template parameter whom its parameter is a non-type value of type equal to a subtype of a previous template parameter (whew! that was as hard to say as it is to read!), and i'm having some build errors after trying to…
lurscher
  • 25,930
  • 29
  • 122
  • 185