I wanted to have a fold-expressioned function that concatenates string_views. But the code I tried didn’t work. What am I makging wrong ?
template<typename Allocator, typename Char, typename Traits>
auto sv_concat( std::basic_string_view<Char, Traits> svs ... )
{
basic_string<Char, Traits, Allocator> str;
str.reserve( (svs.length() + ...) );
((str += svs), ...);
return str;
}
This are the clang++ 18 errors:
test.cpp:14:31: error: pack expansion does not contain any unexpanded parameter packs
14 | str.reserve( (svs.length() + ...) );
| ~~~~~~~~~~~~ ^
test.cpp:15:17: error: pack expansion does not contain any unexpanded parameter packs
15 | ((str += svs), ...);
| ~~~~~~~~~~~~ ^