Questions tagged [template-specialization]

Template specialization refers to programmer-generated explicit specialization of templates for specific types.

Templates refer to the ability to write code that works for any type satisfying the operations used within the class and/or function on that type. Template specialization refers to the ability for the programmer to explicitly change the code for a given type, either by a partial specializion of the template (in which a subset of parameters are specialized over), or a full specialization of the template (where all parameters are specialized).

1616 questions
8
votes
2 answers

C++: partial specialization of template template classes

The following code: using namespace std; template class Goo {}; template class Hoo {}; template class B = Goo > struct Foo { B data; void foo1(); void foo2(); }; template…
user231536
  • 2,661
  • 4
  • 33
  • 45
8
votes
1 answer

Template specialization and references

In Functional programming in C++, chapter 11 deals with some basic template meta programming. In this context, the author shows this implementation of remove_reference/remove_reference_t, which are essentially the same as those described on…
Enlico
  • 23,259
  • 6
  • 48
  • 102
8
votes
1 answer

Specialization based on array size validity

Trying to specialize based on validity of array size: // base template template struct absolute { operator int () const { return 0; } }; // positive case template template struct absolute
Amir Kirsh
  • 12,564
  • 41
  • 74
8
votes
3 answers

Template partial specialization for __stdcall function pointer

typedef bool (*my_function_f)(int, double); typedef bool (__stdcall *my_function_f2)(int, double); // ^^^^^^^^^ template class TFunction; template class TFunction { typedef R…
pure cuteness
  • 1,635
  • 11
  • 26
8
votes
2 answers

Why is a partial class template specialization on a matching template class ambiguous with another partial specialization without the template match?

The question may be too hard to describe in on sentence in the title, but here is a minimal example: #include #include template struct my_trait : std::false_type {}; template
Ad N
  • 7,930
  • 6
  • 36
  • 80
8
votes
2 answers

Type_traits *_v variable template utility order fails to compile

Having seen this answer, I tried to come up with a variable template utility to the code from it: template class Template> struct is_specialization : std::false_type {}; template