My code is as follow:
template <typename T>
void func(T&& param){
using boost::typeindex::type_id_with_cvr;
cout << "T = " << type_id_with_cvr<T>().pretty_name() << " , "
<< "param = " << type_id_with_cvr<decltype(param)>().pretty_name() << '\n';
}
int main(void){
const char name[] = "J. P. Briggs";
func(name);
func("Hello World");
func(24);
return 0;
}
its result:
T = char const (&) [13] , param = char const (&) [13]
T = char const (&) [13] , param = char const (&) [13]
T = int , param = int&&
Isn't the literal "Hello World" a rvalue? If so, why the result of the statement func("Hello World");
is T = char const (&) [13] , param = char const (&) [13]
rather than T = char const[13] , param = char const(&&) [13]
??
Is there something wrong ?
Aucun commentaire:
Enregistrer un commentaire