私はこの小さなmweにboost::python
ライブラリを使用しています。次のコードは `C++ 03`でコンパイルされますが、` C++ 11`ではコンパイルされません
#include <deque>
#include <boost/python.hpp>
typedef std::deque<long unsigned int> DequeUInt64;
BOOST_PYTHON_MODULE_INIT(tmp) {
boost::python::class_<DequeUInt64>("DequeUInt64")
.def("push_back" ,&DequeUInt64::push_back)
.def("push_front" ,&DequeUInt64::push_front);
}
Iは、上記のコードはstd=c++03
とgnu++03
でなくc++11
又はc++0x
でコンパイルすることを観察しました。エラーは次のとおりです。
tmp.cpp: In function 'void init_module_tmp()':
tmp.cpp:8:47: error: no matching function for call to 'boost::python::class_<std::deque<long unsigned int> >::def(const char [10], <unresolved overloaded function type>)'
.def("push_back" ,&DequeUInt64::push_back)
^
In file included [from /opt/local/include/boost/python.hpp:18:0], [from tmp.cpp:2]:
/opt/local/include/boost/python/class.hpp:223:11:
note: candidate:
template<class Derived> boost::python::class_<T, X1, X2, X3>::self&
boost::python::class_<T, X1, X2, X3>::def(const boost::python::def_visitor<Derived>&)
[with Derived = Derived;
W = std::deque<long unsigned int>;
X1 = boost::python::detail::not_specified;
X2 = boost::python::detail::not_specified;
X3 = boost::python::detail::not_specified]
self& def(def_visitor<Derived> const& visitor)
^
note: template argument deduction/substitution failed:
tmp.cpp:8:47:
note: mismatched types 'const boost::python::def_visitor<U>' and 'const char [10]'
.def("push_back" ,&DequeUInt64::push_back)
^
In file included [from /opt/local/include/boost/python.hpp:18:0], [from tmp.cpp:2]:
/opt/local/include/boost/python/class.hpp:233:11:
note: candidate:
template<class F> boost::python::class_<T, X1, X2, X3>::self&
boost::python::class_<T, X1, X2, X3>::def(const char*, F)
[with F = F;
W = std::deque<long unsigned int>;
X1 = boost::python::detail::not_specified;
X2 = boost::python::detail::not_specified;
X3 = boost::python::detail::not_specified]
self& def(char const* name, F f)
^
note: template argument deduction/substitution failed:
tmp.cpp:8:47:
note: couldn't deduce template parameter 'F'
.def("push_back" ,&DequeUInt64::push_back)
私のブーストはboost: stable 1.60.0
で、私のG ++はg++-mp-5 (MacPorts gcc5 5.4.0_0) 5.4.0
です。どういうわけか、新しい標準が型/テンプレートの推論に問題を引き起こしていますが、正直なところ私はなぜそれほど理解できないのでしょうか? Boostは単にC++ 11でテストされていないため問題ですか?とにかく上記のエラーメッセージはどういう意味ですか?
ただ、好奇心出し、クランは動作しますか? – refi64
私は質問が2票しかないのに驚いています。タイトルの曖昧さを除けば、実際のMCVE、完全なコンパイラエラー、コンテキスト(Boostとコンパイラのバージョン)など、私が望むことができるすべてのものがあります。 – chris