Why can const char* const & = “hello” compile?

It’s essentially adhering to this formula

T const & a = something_convertible_to_T;

Where T is const char*. In the first case, a temporary pointer can be materialized, assigned the address of the literal, and then have itself bound to the reference. In the second case, since the lvalue reference isn’t const, it can’t happen. Another example of more of the same

const char* && a = "hello"; // rvalue ref makes a no into a yes.

Now the temporary pointer is bound to an rvalue reference.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)