I have to handle the [[nodiscard]] warning from std::remove
;
static_cast<void>(std::remove(stringVar.begin(), stringVar.end(), ' '));
I want the correct way to do it. The warning can be stopped by below code:
auto temp = std::remove(stringVar.begin(), stringVar.end(), ' ');
I dont want to use the return value of std::remove
.
void main()
{
std::string stringVar { "Operation : In , Value : 3884 ," };
size_t from = 0, to = 0, pos = 0;
std::string delFrom{ ":" }, delTo{ "," };
static_cast<void>(std::remove(stringVar.begin(), stringVar.end(), ' '));
from = stringVar.find(delFrom, pos);
to = stringVar.find(delTo, pos);
std::cout<< stringVar.substr(from + 1, to - from - 1);
}
Output:
In
This is a specific question do not interested in already searched question on SO.
Update: Data consistent and readable format.