我有这个全局函数在我的计划:为什么包含一个任意的STL头解决了这些编译错误?
static bool IsValidType(const CString& cType)
{
for (auto pType : {"bmp","jpg","jpeg","gif","tif","tiff","png"})
if (cType == CString(pType))
return true;
return false;
}
,它给我下面的编译错误:
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
我可以解决这个问题通过包含函数体前任意STL头,用于例如:
#include <string>
static bool IsValidType(const CString& cType)
{
...
}
但当然,我不认为这是做到这一点的正确方法。
你能向我解释为什么包括一个任意的STL头解决了这个问题,以及我应该如何解决它?
谢谢。
也许应该补充一点,我在这里(因此'CString')使用MFC ... – goodvibration
我猜你需要包括''其中被列入STL的头文件 –
kim366
哦,还是仅仅包括''。 –
kim366