InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.41k stars 663 forks source link

STYLE: Replace `(const std::string)` casts with C++17 `std::string_view` #4587

Closed N-Dekker closed 5 months ago

N-Dekker commented 5 months ago

Prevented potential static analysis warnings, like Clang-Tidy:

C-style casts are discouraged; use static_cast [google-readability-casting]

And JetBrains ReSharper:

C-style cast is used instead of a C++ cast

Note that std::string_view is more lightweight than std::string.

N-Dekker commented 5 months ago

By the way, I noticed that GoogleTest has a few macro's specifically for string comparison, avoiding the need to manually convert the arguments to std::string or std::string_view. Might be worth considering 😃

dzenanz commented 5 months ago

GoogleTest has a few macro's specifically for string comparison

Make a competing PR using those? 😄

N-Dekker commented 5 months ago

/azp run ITK.macOS

N-Dekker commented 5 months ago

Note that std::string_view only provides read-only to the data, so in that sense, it's similar to const std::string &.