If the reference binding
(initialization or pass into as function argument) is implicit type conversion
.
if not, why some casting expression
(static_cast, const_cast...) support to cast a non-reference entity
to reference
and I think it's reasonable to put everything unified. And further more, if reference is a part of type?
struct class A {};
int main() {
int a = 1;
static_cast<int &>(a);
static_cast<int &&>(1);
const_cast<A &&> (A()); // funny , const_cast<int &&> (1); doesn't work
const_cast<int &>(a);
const_cast<int && >(a);
static_cast<int &&>(1);
}
Aucun commentaire:
Enregistrer un commentaire