C & C++

C & C++

Made by DeepSource

Initializing std:string or std::string_view is redundant CXX-C2023

Style
Minor
Autofix

Initializing std::string or std::string_view with an empty string is unnecessary and can be considered redundant.

This is redundant because both types already have a default constructor that performs necessary initialization. Also, by removing the redundant initialization, the code becomes cleaner and more concise.

To fix this issue, simply remove the explicit initialization of the std::string or std::string_view with an empty string.

Bad practice

std::string str = "";
std::string_view str_view = "";

Recommended

std::string str;
std::string_view str_view;