M
Michael Tsang
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
1. Is the following possible:
int a = 3;
int && b = a;
2. I want to write the signatures of extractors in this way:
#include <iosfwd>
class foo_t;
template<class charT, class Traits>
std::basic_istream<charT, Traits> &operator>>(std::basic_istream<charT,
Traits> &&in /* note the r-value reference */, foo_t &object);
Is this a good idea?
3. For the swap function:
template<class T>
swap(T &a, T &b) {
T c = (T &&)a; // a is now destroyed
a = (T &&)b; // b is now destroyed
b = (T &&)c; // c is now destroyed
}
Is this OK. What is the difference between std::move and a cast to r-value
reference? What C++ casting operator is the most suitable for replacing the
C-style casts?
4. Is it useful to have const class r-values? Do we need to write
constructors from a const r-values (const foo_t &&) of the same type?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkuE5ysACgkQm4klUUKw07D3GwCdGWBovX+hcCDvqo1v+SHdgC6V
LDYAn3wKmAFYHxNjQDVmQQZ2XEKugF52
=anc2
-----END PGP SIGNATURE-----
Hash: SHA1
1. Is the following possible:
int a = 3;
int && b = a;
2. I want to write the signatures of extractors in this way:
#include <iosfwd>
class foo_t;
template<class charT, class Traits>
std::basic_istream<charT, Traits> &operator>>(std::basic_istream<charT,
Traits> &&in /* note the r-value reference */, foo_t &object);
Is this a good idea?
3. For the swap function:
template<class T>
swap(T &a, T &b) {
T c = (T &&)a; // a is now destroyed
a = (T &&)b; // b is now destroyed
b = (T &&)c; // c is now destroyed
}
Is this OK. What is the difference between std::move and a cast to r-value
reference? What C++ casting operator is the most suitable for replacing the
C-style casts?
4. Is it useful to have const class r-values? Do we need to write
constructors from a const r-values (const foo_t &&) of the same type?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkuE5ysACgkQm4klUUKw07D3GwCdGWBovX+hcCDvqo1v+SHdgC6V
LDYAn3wKmAFYHxNjQDVmQQZ2XEKugF52
=anc2
-----END PGP SIGNATURE-----