2017-03-27 95 views
1

下面是我設計的結構和類,最終目標是使用boost序列化將值寫入xml 當我編譯代碼下面我得到一個編譯時錯誤(錯誤是巨大的,我只是貼吧的最後一行這或許對這個問題的會談)Boost錯誤「Structure has no members named'serialize'」「雖然結構已經序列化

/boost_1_49_0/include/boost/serialization/access.hpp:118: error: 'class std::map, std::allocator >, std::map, std::allocator >, std::map, std::allocator >, IdInfo, std::less, std::allocator > >, std::allocator, std::allocator >, IdInfo> > >, std::less, std::allocator > >, std::allocator, std::allocator >, std::map, std::allocator >, IdInfo, std::less, std::allocator > >, std::allocator, std::allocator >, IdInfo> > > > > >, std::less, std::allocator > >, std::allocator, std::allocator >, std::map, std::allocator >, std::map, std::allocator >, IdInfo, std::less, std::allocator > >, std::allocator, std::allocator >, IdInfo> > >, std::less, std::allocator > >, std::allocator, std::allocator >, std::map, std::allocator >, IdInfo, std::less, std::allocator > >, std::allocator, std::allocator >, IdInfo> > > > > > > > >' has no member named 'serialize' make: *** [READER.exe] Error 1

的AssetReaderInfo clkass下面竟然有一個成員序列化,但錯誤違背它。

我已經在所有的類中定義的序列化,但它未能編譯 另外,我還沒有specfied主要cpp的代碼,因爲我認爲這增加了混亂

請你提出了什麼問題?

struct IdInfo 
{ 
    std::string m_milePost; 
    std::string m_cellModemAlertExclusionList; 

    public: 
    IdInfo():m_milePost("milepost"),m_cellModemAlertExclusionList("dummyval"){}; 

    template<class archive> 
    void serialize(archive& ar, const unsigned int version) 
    { 
     using boost::serialization::make_nvp; 
     ar & make_nvp("values", m_milePost); 
     ar & make_nvp("values", m_cellModemAlertExclusionList); 
    } 
}; 

class myReader { 
public: 

    friend class boost::serialization::access; 
    // Asset ID list 
    typedef std::map< std::string,IdInfo > myMap; 
    typedef std::map<std::string> mySet; 
    struct ReaderInfo 
    { 
     mySet m_aSList; 
     myMap m_pList; 
     myMap m_eList; 
     // WIU/BS type 
     std::string m_Type; 
     std::string m_topic; 
     std::string m_lastSavedMsg; 
     template <class archive> 
     void serialize(archive& ar, const unsigned int version) 
     { 
      using boost::serialization::make_nvp; 
      ar & make_nvp("values", m_topic); 
      ar & make_nvp("values", m_Type); 
      ar & make_nvp("values", m_eList); 
      ar & make_nvp("values", m_pList); 
     } 

    }; 
    typedef std::map< std::string, ReaderInfo > GroupDataMap; 
    GroupDataMap m_GroupDataMap; 

    template<class archive> 
    void serialize(archive& ar, const unsigned int version) 
    { 
     using boost::serialization::make_nvp; 
     ar & make_nvp("Group", m_GroupDataMap); 
    } 
} 

int main() 
{ 
    myReader Reader; 
    boost::archive::xml_oarchive xml(ofs); 
    xml << boost::serialization::make_nvp("Connections", Reader); 
} 

解決方案:

It turns out that i should include /boost/serialization/map.hpp as iam using a std::map

感謝您的幫助

+0

刪除或自我回答。這樣很明顯,問題不再需要關注 – sehe

回答

0

事實證明,我應該使用一個std包括/boost/serialization/map.hpp爲IAM ::地圖

#include /boost/serialization/map.hpp

相關問題