This is a simple question but I can't manage to find it on google:
Is there a special move constructor for integral type(including pointers)
For instance if I do:
int* a = new int(2);
int* b = std::move(a);
Is it guaranteed to point to NULL? How about if a and b were int?
is a guaranteed to point to NULL ?
No, it will be unchanged. Initialisation of built-in types will never modify the initialiser. Only initialisation of a class type with a move constructor (or an evil non-constant copy constructor, such as auto_ptr) could modify it.
For example, if you used std::unique_ptr rather than dumb pointers, then a would be empty after the initialisation of b.
How about if
aandbwere ints?
Still no.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With