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 in front of the function body, for example:
#include <string>
static bool IsValidType(const CString& cType)
{
...
}
But of course, I don’t think this is the right way to do this.
Can you explain to me why the inclusion of an arbitrary STL header fixes this problem and how should I solve it correctly?
Thank.
source
share