0
我碰到一個問題讓我生氣。我已經使用跟隨着計時器進入結構實現定時器:編譯問題與VS2010和boost :: posix_time
typedef std::multimap<boost::posix_time::ptime, events::ITimeout*> TEntryMap;
TEntryMap entries_;
和我插入元素融入多重映射有:
boost::posix_time::ptime tTimeout = boost::posix_time::microsec_clock::local_time() + boost::posix_time::milliseconds(timeout);
entries_.insert(std::make_pair(tTimeout, ptr)); // ptr is the events::ITimeout object
,並在一個轉換單元(CPP文件),它完美的作品。不過,現在我需要這個功能移動到另一個CPP文件,現在我得到一個編譯錯誤:
1>Build started 2013-02-07 15:38:18.
1>ClCompile:
1> EventDispatcher.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(260): error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const boost::posix_time::ptime' (or there is no acceptable conversion)
1> ....\boost\boost\date_time\posix_time\ptime.hpp(57): could be 'boost::posix_time::ptime &boost::posix_time::ptime::operator =(const boost::posix_time::ptime &)'
1> while trying to match the argument list '(const boost::posix_time::ptime, const boost::posix_time::ptime)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(259) : while compiling class template member function 'std::pair<_Ty1,_Ty2> &std::pair<_Ty1,_Ty2>::operator =(std::pair<_Ty1,_Ty2> &&)'
1> with
1> [
1> _Ty1=const boost::posix_time::ptime,
1> _Ty2=events::ITimeout *
1> ]
1> ....\eventdispatcher.cpp(72) : see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
1> with
1> [
1> _Ty1=const boost::posix_time::ptime,
1> _Ty2=events::ITimeout *
1> ]
1>
我無能以及與此掙扎了2小時。我看到工作實施和非工作實施之間沒有區別。相同的構造,相同的多重地圖,相同的一切! ;(