获取boost的类型值:任何进行强制转换的对象

时间:2012-12-04 11:32:24

标签: c++ boost boost-python

有没有办法让我的boost :: any对象的typevalue用于any_cast?

    POSITION dictPos = CurrentSubMap->GetStartPosition();
    while(dictPos)
    {

        boost::any a = CurrentSubMap->GetValueAt(dictPos);
        if(a.type() == typeid(long))
            dictToAppend[CurrentSubMap->GetNextKey(dictPos)] = boost::any_cast<long>(a); 
        else
            dictToAppend[CurrentSubMap->GetNextKey(dictPos)] = boost::any_cast<CAtlString>(a);


    }

它有效但我需要一个动态解决方案,如:

dictToAppend[CurrentSubMap->GetNextKey(dictPos)] = boost::any_cast<HERE_THE_TYPE_OF_a>(a);

我用“a.type()”尝试了它,但它不起作用。

  

“'ValueType'的模板参数无效,预期类型为”

0 个答案:

没有答案
相关问题