我收到編譯錯誤使用g ++ 4.6,並使用boost::make_shared<T>(...)
時提高1.42,而shared_ptr<T>(new T(...))
剛剛編譯精細。不幸的是,我無法隔離一個最小的例子(我嘗試過的任何編譯都很好),但也許有人可以向我解釋其中的差異。的boost :: make_shared <T>(...)無法編譯,shared_ptr的<T>(新T(...))不
我instatiating的shared_ptr<ResidualsFunctor> f
,其中ResidualsFunctor
具有以下構造函數實例:
ResidualsFunctor(int,int,StaticEquilibriumSolver*)
這
f=shared_ptr<ResidualsFunctor>(new ResidualsFunctor(0,0,this)); // this is a StaticEquilibriumSolver*
編譯就好了,而
f=make_shared<ResidualsFunctor>(0,0,this);
告訴我:
/usr/include/boost/smart_ptr/make_shared.hpp: In function 'boost::shared_ptr<T> boost::make_shared(Args&& ...) [with T = StaticEquilibriumSolver::ResidualsFunctor, Args = int, int, StaticEquilibriumSolver* const]':
pkg/sparc/SparcField.cpp:472:49: instantiated from here
/usr/include/boost/smart_ptr/make_shared.hpp:148:5: error: no matching function for call to 'forward(int&)'
/usr/include/boost/smart_ptr/make_shared.hpp:148:5: note: candidate is:
/usr/include/boost/smart_ptr/make_shared.hpp:90:40: note: template<class T> T&& boost::detail::forward(T&&)
這是一個提升錯誤嗎?在gcc中?我看不到我的錯?
這看起來像Boost等效的'std :: forward'和你的編譯器之間的奇怪的相互作用。你使用的是什麼編譯器版本,以及你使用的是什麼版本的Boost? –
它是在問題g ++ 4.6和boost 1.42中指定的。 – eudoxos