Bonjour,
Could please tell me why the first 3 lines do not work while the last 3 ones work?
See : https://gcc.godbolt.org/z/qozEsc
#include <vector>
#include <string_view>
#include <iostream>
int main(){
const std::vector<std::string> W = {"aaa", "bbbb", "ccccc"};
std::vector<std::string_view> Wbak1;
for (std::string w : W) Wbak1.push_back(w.c_str());
for(auto w:Wbak1) std::cout << w << '\n';
std::vector<std::string_view> Wbak2;
for (auto i = 0U; i < W.size(); ++i) Wbak2.push_back(W[i].c_str());
for(auto w:Wbak2) std::cout << w << '\n';
}
Best regards, 40tude