I have problem with this piece of code:
#include <string>
#include <iostream>
struct A{
template<class UT>
A(UT &&s) : internal(std::forward<std::string>(s)){
}
std::string internal;
};
int main(){
const std::string &s = "hello";
A a1{ s };
std::cout << "s = " << s << std::endl;
}
This current example does not compiles and if I change s
to be non const, it moves the string.
I have similar codes that works OK, but in this case there is something wrong I can not see.
Aucun commentaire:
Enregistrer un commentaire