Boost logo

Boost Users :

Subject: Re: [Boost-users] asio/ip/udp.hpp causes MSVC to use std::bind
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2014-01-29 17:19:33


On 29/01/2014 07:09 p.m., Chris Stankevitz wrote:
> Can you tell me why the following code fails to compile? It smells as
> if udp.hpp is causing MSVC to "using namespace std".

MSVC is doing some kind of weird argument dependent lookup.

> PS: It doesn't happen if I remove the asio include.

That is because <functional> gets included by it. Include it directly
and you should get the same error.

> PPS: It doesn't happen if g() takes int vs std::string.

That is because `string` is in the `std` namespace. Change it to
anything else in the `std` namespace and you should get the same error.

> PPPS: It doesn't happen on GCC

This is because it's a MSVC bug. I cannot reproduce it in VS2013, so I
guess they fixed it.

> #include <boost/bind.hpp>
> #include <boost/asio/ip/udp.hpp>
> #include <string>
>
> using boost::bind;
>
> void g(const std::string&)
> {
> }
>
> int main()
> {
> bind(g, _1);
> return 0;
> }
>

Regards,

-- 
Agustín K-ballo Bergé.-
http://talesofcpp.fusionfenix.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net