Jump to content

Talk:Partial template specialization

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Partial template specialization is a method of optimizing generic code at compile time. 

Total bullshit, its not for optimizing for for taking care of special abilities, e.g. that its a pointer, or that for type X some access to whatever is done otherwise. what about informing before writing,

Yes, this article contains mostly incorrect information on a very narrow subject. I rewrote the first paragraph for a better definition of partial specialization. The "Templates and specialization" section should also be expanded to cover more uses of partial specialization. Containers are just an example. There are lots more uses, see for example Template metaprogramming. Ufretin (talk) 11:06, 12 January 2008 (UTC)[reply]

as opposed to explicit specialization, where all the template arguments are provided

In the first paragraph, maybe you intended to say "full specialization" instead of "explicit specialization" —Preceding unsigned comment added by 77.234.79.113 (talk) 13:01, 13 February 2008 (UTC)[reply]

Well, the terms are used somewhat interchangeably, but the standard uses "explicit specialization", so I made an informed decision to use that term. There could still be good reasons for using "full specialization" instead, though. I am aware that Vandevoorde and Josuttis avoids the term "explicit specialization" in their C++ Templates:The complete guide, for instance. decltype (talk) 06:44, 22 February 2008 (UTC)[reply]
I think there should be an example. That's what people would be looking for. Ben T/C 11:40, 11 May 2009 (UTC)[reply]
Definitely. I'll fix it when time permits. decltype (talk) 13:07, 11 May 2009 (UTC)[reply]

Overloading function by return type

[edit]

I don't think this line is correct :

// legal: base function template overloading the return type
template <typename ArgumentType>
void Foo(ArgumentType arg);

Return type is not used for the function signature in C++.

109.89.54.237 (talk) 16:18, 3 May 2015 (UTC)[reply]

@109.89.54.237: Agreed. By using int and char, which are type-convertible, it did not make the concept clear enough. I have fixed it by using string and char. Further, I made a distinction of which ones are overloads, as you rightly point out. Thanks for the careful review! ← scribbleink ᗧHᗣT 18:13, 3 May 2015 (UTC)[reply]

Valid Overload

[edit]

The following is a valid overload since arg has a type char.

// legal: base function name reused. Not considered an overload. ill-formed: non-overloadable declaration (see below)
template <typename ReturnType>
ReturnType Foo(char arg) { return "Return2"; }