I have this global function in my program:
static bool IsValidType(const CString& cType)
{
for (auto pType : {"bmp","jpg","jpeg","gif","tif","tiff","png"})
if (cType == CString(pType))
return true;
return false;
}
And it gives me the following compilation errors:
error C3312: no callable 'begin' function found for type 'initializer-list'
error C3312: no callable 'end' function found for type 'initializer-list'
error C2065: 'pType' : undeclared identifier
I can resolve it by including an arbitrary STL header before the function body, for example:
#include <string>
static bool IsValidType(const CString& cType)
{
...
}
But of course, I don't think that this is the correct way to do it.
Can you please explain to me why including an arbitrary STL header resolves this problem, and how I should go about resolving it correctly?
Thank you.