Given the following code
std::string_view foo(){
std::string_view sv("ABC");
return sv;
}
int main(){
std::string_view svv = foo();
}
- Is it safe to say that since
"ABC"
is stored in the static area of the stack,svv
is valid since the internal char array is still alive outside the scope offoo
? - Is it true that it will be called the constructor (4) at https://en.cppreference.com/w/cpp/string/basic_string_view/basic_string_view?
- If it were = "ABC", does 1. still hold?