Project

General

Profile

Feature #7943

std::string_view support

Added by Rathnadhar K V 9 months ago. Updated 13 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
12/23/2020
Due date:
% Done:

0%

Estimated time:

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

#1

Updated by Samir Shaker 7 months 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.

#2

Updated by Rathnadhar K V 13 days 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

Also available in: Atom PDF