Feature #7943
openstd::string_view support
0%
Description
Namaskara,
There are many functions in wt (4.0) which take std::string as function argument.
In many cases we create an immutable (const) string what we pass function argument (s).
In cases where feasible, can we have a std::string_view overloaded functions, so that we create a const string_view object that we provide these functions as input argument.
Regards
Rathnadhar K V
Updated by Samir Shaker almost 4 years ago
I would also like to see support for std::string_view. In addition to what Rathnadhar mentioned, WLogger fails to output an std::string_view. For example, the code below gives an error:
std::string_view my_string("a string literal");
log("info") << my_string;
The error in my case was:
/usr/local/include/Wt/WLogger.h:370:23: error: no matching function for call to 'to_string'
impl_->line_ << to_string(t);
Samir.
Updated by Rathnadhar K V over 3 years ago
Namaskara Samir,
I believe that time has come for Wt to support std::string_view for space and temporal optimizations.
There are many situations where the string is not modified at all or rarely modified. In my program the date format and time format is never modified. But the WtDate and WtTime toString takes const WString as the parameter. The format string is ASCII. Further the format string is rarely changed (for maintaining the uniformity...).
So under such circumstance, its useful if we have an overloaded function (method) that takes const std::string_view& as parameter.
Regards
Rathnadhar K V