Opened 3 years ago

Last modified 3 years ago

#12115 new Bugs

Boost.Asio compile error on Visual Studio 2015 Update 2

Reported by: Sergey Svistunov <zenden2k@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.60.0 Severity: Problem
Keywords: Cc:

Description

I just upgraded to VS 2015 Update 2 and boost/asio/basic_io_object.hpp fails to compile on it. Downgrading to VS 2015 Update 1 fixed this issue for me.

1>include\boost/asio/basic_io_object.hpp(45): error C2064: term does not evaluate to a function taking 2 arguments
1>  include\boost/asio/ip/basic_resolver.hpp(45): note: see reference to class template instantiation 'boost::asio::detail::service_has_move<IoObjectService>' being compiled
1>          with
1>          [
1>              IoObjectService=boost::asio::ip::resolver_service<boost::asio::ip::tcp>
1>          ]
1>  C:\work\uninav\src\private\nav_mail\MailClient.cpp(175): note: see reference to class template instantiation 'boost::asio::ip::basic_resolver<boost::asio::ip::tcp,boost::asio::ip::resolver_service<InternetProtocol>>' being compiled
1>          with
1>          [
1>              InternetProtocol=boost::asio::ip::tcp
1>          ]

Compile error in basic_io_object.hpp:45 at "service_has_move::eval("

#if defined(BOOST_ASIO_HAS_MOVE)
namespace detail
{
  // Type trait used to determine whether a service supports move.
  template <typename IoObjectService>
  class service_has_move
  {
  private:
    typedef IoObjectService service_type;
    typedef typename service_type::implementation_type implementation_type;

    template <typename T, typename U>
    static auto eval(T* t, U* u) -> decltype(t->move_construct(*u, *u), char());
    static char (&eval(...))[2];

  public:
    static const bool value =
      sizeof(service_has_move::eval(
        static_cast<service_type*>(0),
        static_cast<implementation_type*>(0))) == 1;
  };
}
#endif // defined(BOOST_ASIO_HAS_MOVE)

Change History (6)

comment:1 Changed 3 years ago by Sergey Svistunov <zenden2k@…>

Both in Update 1 and Update 2 this macro "BOOST_ASIO_HAS_MOVE" seems to be defined by boost.config.

comment:2 Changed 3 years ago by anonymous

I am encountering the same issue, also on VS2015 Update 2. This is preventing us from using Boost.Asio.

comment:3 Changed 3 years ago by anonymous

Also meet this error

comment:4 Changed 3 years ago by article@…

I just encountering the same issue, and found a resolution:

typedef asio::ip::tcp::resolver::iterator tcp_iterator;

and use tcp_iterator, instead of use asio::ip::tcp::resolver::iterator direct in the constructors, and compile fine

comment:5 Changed 3 years ago by anonymous

the solution I found was to just change this boost code (mentioned in the original report)

   static const bool value =
      sizeof(service_has_move::eval(
        static_cast<service_type*>(0),
        static_cast<implementation_type*>(0))) == 1;

to this

  static const bool value =
      sizeof(   eval(
        static_cast<service_type*>(0),
        static_cast<implementation_type*>(0))) == 1;

(i.e. remove the service_has_move:: )

and it compiled fine. If you rename that actual method to something like eval2, you'll get a compile error, which confirms it's still resolving to the correct method.

comment:6 Changed 3 years ago by anonymous

Removing service_has_move worked for me! Thank you sir.

Note: See TracTickets for help on using tickets.