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;
++my_var;
I think decltype should be given another privilege: To get the type of protected/private members, for example:
class Dog {
private:
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
Std-Proposals@lists.isocpp.orghttps://lists.isocpp.org/mailman/listinfo.cgi/std-proposals