Skip to content

Commit 59b31d0

Browse files
committed
Build the header name string rather than casting to one
@marcalff on #4346: a cast to a class type reads as a conversion where the intent is a temporary. `nostd::string_view` carries an explicit `operator std::string`, which direct initialisation reaches just as the cast did, so the two forms compile to the same thing and this one says what it is. Compiles clean in both configurations of the type: the fallback `nostd::string_view` class, and `WITH_STL=CXX17` where it is `std::string_view` and the standard library's own string_view constructor takes over. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent beb0913 commit 59b31d0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎examples/http/client.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void sendRequest(const std::string &url)
7171
span->SetAttribute(semconv::http::kHttpResponseStatusCode, status_code);
7272
result.GetResponse().ForEachHeader(
7373
[&span](nostd::string_view header_name, nostd::string_view header_value) {
74-
span->SetAttribute("http.header." + static_cast<std::string>(header_name), header_value);
74+
span->SetAttribute("http.header." + std::string(header_name), header_value);
7575
return true;
7676
});
7777

0 commit comments

Comments
 (0)