C++ Logo

std-proposals

Advanced search

Re: Make class template parameters available externally

From: Dmitry <dimanne_at_[hidden]>
Date: Fri, 1 Nov 2019 21:16:37 +0000
So, I have incorporated (all) your feedback in the proposal:

   - now the feature is opt-in
   - private/protected/public keywords are used: template<public typename A,
   protected int B>
   - New compiler errors are discussed: when there is a propagated template
   parameter and user-defined one with the same name.

Here is a link
<https://docs.google.com/document/d/1dx9zuklyI1l4wU2buGaDuZGik1nAdd1YAJZ4mjwS9FU/edit#heading=h.uuouxp4cefr2>
to
the proposal (leading directly to the new opt-in approach).

And also there are my thoughts on the question about the upcoming class
types in non-type template parameters
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0732r0.pdf>:
"Namely, do we want to have references (static constexpr int &B = _B; in
the example above), or values (static constexpr int B = _B;)?
No matter how smart structures it will be possible to use as template
arguments, (after instantiation) they are just smartly-mangled
(16IntegralConstantIPFiRiEXadL_Z3fooIiEiRT_EEE) old plain C structs, and
they are entirely handled in compile-time. From this point of view, there
is little point in using references. Perhaps, a safer approach would be to
understand how compile-time calculations implemented in the modern
compilers, in particular whether "compile-time reference" makes sense or
not."

-- 
Dmitry
*Sent from gmail*

Received on 2019-11-01 16:19:21