この投稿から、名前空間にヘルパー関数を作成する方法を学びました。 C++の「ヘルパー」関数
//stringhelper.hpp
namespace utility{
static std::string intToString(int integer)
{
std::stringstream sstream;
sstream << integer;
return sstream.str();
}
static void toLowerCase(std::string& y)
{
std::transform(y.begin(), y.end(), y.begin(), (int(*)(int))tolower);
}
}
このヘッダーを含めましたが、次の警告が表示されました
'void utility::toLowerCase(std::string&)' defined but not used
はい。intToString(int integer)を使用しましたが、toLowerCase(std :: string&)は使用しませんでした。これらの警告を見たり、ヘッダーごとに1つのヘルパー関数を分割したりしたくありません。
誰かが良い解決策を提案できますか?警告を無効にするだけでいいですか?ありがとうございました