Good idea in my opinion.

On Fri, Mar 25, 2022 at 7:47 PM Frederick Virchanza Gotham via Std-Proposals <> wrote:

Normally the behaviour is undefined when you dereference a nullptr, but it's allowed with decltype, for example the following is valid code:

    decltype( static_cast<std::string*>(nullptr)->compare("Hello") ) my_var;


I think decltype should be given another privilege: To get the type of protected/private members, for example:

class Dog {
        int calibration[3u][2u][7u];

int main(void)
    Dog doggy;

    decltype(doggy.calibration) my_array;

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.

Std-Proposals mailing list