2

libtorrent我发现以下代码,它不能用 Visual Studio 2015 RC 编译:

boost::bind( &address::is_v4,
             boost::bind( &tcp::endpoint::address,
                          _1
             )
)
== m_bind_addr.is_v4()

虽然我们可能会争论使用 bind 使用运算符重载的问题,但我实际上想知道为什么它不能编译。错误信息是:

C:\Projects\boost\boost/bind/bind.hpp(2003): error C2027: use of undefined type 'boost::_bi::add_cref<Pm,0>'
          with
          [
              Pm=bool (__thiscall boost::asio::ip::address::* )(void) const
          ]
  C:\Projects\boost\boost/bind/bind.hpp(2011): note: see reference to class template instantiation 'boost::_bi::dm_result<M (__thiscall boost::asio::ip::address::* ),A1>' being compiled
          with
          [
              M=bool (void) const,
              A1=boost::_bi::bind_t<boost::asio::ip::address,boost::_mfi::cmf0<boost::asio::ip::address,boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>>,boost::_bi::list1<boost::arg<1>>>
          ]
4

1 回答 1

0

我遇到了这个,但仅用于 32 位编译。64位就好了。用 mem_fn(来自 boost/mem_fn.hpp)包围函数就可以了:

boost::bind( &address::is_v4,
         boost::bind( boost::mem_fn( &tcp::endpoint::address),
                      _1
         )
) == m_bind_addr.is_v4()
于 2015-11-27T03:58:06.653 回答