C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Make class template parameters available externally
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-10-31 03:18:10


On 2019-10-31 10:48, Dmitry via Std-Proposals wrote:
> Thank you for the feedback.
>
> The main question to answer is why do we need to hide / restrict access
> to template parameters from outside at all?
> Here is a toy example <https://godbolt.org/z/tE3Hh_> of what I meant
> when I said that it had been possible for external code to deduce any
> template parameters (type as well as non-type ones) of any template
> instantiation.
>
> So, if you think, by trying to "hide" / make template arguments private
> / not-visible from outside, you are suggesting to break this (already
> existing) behaviour in C++.
>
> To put it another way, the proposal does not change anything
> fundamentally in this regard, instead, perhaps, it makes the trick from
> the toy example <https://godbolt.org/z/tE3Hh_> less obscure and verbose.

Decomposing the type to know the template parameters is not the same as
making these parameters part of the class' public interface. There are
cases when template parameters are used for auxiliary purposes, e.g. for
SFINAE or tagging and specialization. These parameters should not be
exposed.

I'm strongly opposed to making the proposed behavior the default. IMO,
if implemented, it must be opt-in.

Another thing to consider: unnamed template parameters.


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups