When I use Visual Studio 2019, it gives me the green squiggles with this:
#include <iostream>
#include <locale>
int main() {
// Green squiggles given for this entire line:
std::cout.imbue(std::locale("en_US.utf8"));
// Visual Studio says, "C26444: Avoid unnamed objects with custom construction and destruction (es.84)"
// Using cout.imbue to provide nice formatting for numbers:
std::cout << "Example locale formatting: " << 100'000.00 << '\n';
}
I've tried some variations like this:
std::locale my_locale("en_US.utf8");
// Now the green squiggles just appear from cout.imbue onward:
std::cout.imbue(my_locale);
I believe the es.84 is from the C++ Core Guidelines: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-noname
However, I'm not sure how to fix this. I looked at cppreference.com and cplusplus.com for examples, but I'm doing what they show.
What does Visual Studio not like and how can I fix it?