C++ Logo

std-proposals

Advanced search

Re: [std-proposals] decltype can access private and protected

From: Dominic Fandrey <isocpp.id_at_[hidden]>
Date: Wed, 30 Mar 2022 08:51:48 +0200
On 25/03/2022 18:46, Frederick Virchanza Gotham via Std-Proposals wrote:
> ...
>
> This past week I was writing code for an Arduino microcontroller to save
> POD's to the onboard non-volatile Flash, and I had to edit a class to
> change a member from protected to public just so that I could use decltype
> on it. This shouldn't be necessary -- just allow decltype to get the type
> of anything irrespective of accessibility.

Why didn't you add a trait to the class:

using value_type = decltype(calibration);

Making a member public instead seems like a terrible alternative.

I'd argue giving decltype access to private members has the potential to
break a lot of SFINAE conditions.

Received on 2022-03-30 06:51:54