Namespaces
Variants
Views
Actions

Talk:cpp/language/template parameters

From cppreference.com

Contents

[edit] DR 150

Clang appears to intend to apply it retroactively all the way back to C++98: "This is the resolution to a Defect Report, so will be applied to all language versions." T. Canens (talk) 13:52, 15 December 2016 (PST)

cool, maybe it shouldn't be revboxed at all then.. The DR table could use a bit of rewording too, to stress that fix applies to all previous standards. --Cubbi (talk) 14:23, 15 December 2016 (PST)

[edit] Default arguments and template members

The page says:

> Default parameters are not allowed in the out-of-class definition of a member template (they have to be provided in the declaration inside the class body)

This does not appear to be justified by the standard, which instead says (http://eel.is/c++draft/temp.param#12.sentence-4) only: "A default template-argument shall not be specified in the template-parameter-lists of the definition of a member of a class template that appears outside of the member's class."

In particular, member templates of non-template classes *are* permitted to have default template arguments added after their declaration in the class, per the standard's rule.

Clang implements the rule as written in the standard, GCC and ICC implement the rule as written here. How is such implementation divergence usually documented?

Good catch. Looks like [User:Jwakely] spotted it in gcc back here bug 53856, but it was then fixed only for member types, not member functions as I just tested. I'll update this page to say member of class template. As far as notable implementation divergences, we put them under Notes heading, or write a little (note: see gcc bug 12346) when unobtrusive. --Cubbi (talk) 13:19, 1 December 2017 (PST)

[edit] Different template parameter name in different declarations

Is it allowed to redeclare a template with its parameters differently named? For example:

template <typename A> class Foo;
//...
template <typename B> class Foo { Foo() = default; }

My opinion is that it should be allowed. Another person thinks it should not. (See our discussion [1]) I think we should explicitly mention this whether or not it is allowed, since it is confusing. -- LittleFlower (talk) 22:50, 1 August 2018 (PDT)

[edit] Constant destruction?

The page says:
A template parameter object shall have constant destruction.

Does it mean that it obeys the rules of constant initialization and therefore it must be destroyed correspondingly? First time I see the term "constant destruction"
ticotico (talk) 12:31, 25 May 2020 (PDT)

https://eel.is/c++draft/expr.const#def:destruction,constant seems to be relevant. — Radix (talk) 13:09, 25 May 2020 (PDT)
An anchor added for "constant destruction". --Fruderica (talk) 22:56, 25 May 2020 (PDT)