Boost logo

Boost Users :

Subject: [Boost-users] asio/ip/udp.hpp causes MSVC to use std::bind
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2014-01-29 17:09:38


boost 1.55
VS2012 Update 4

===

Can you tell me why the following code fails to compile? It smells as
if udp.hpp is causing MSVC to "using namespace std".

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

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

PPPS: It doesn't happen on GCC

Thank you,

Chris

===

#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;
}

===

1>------ Build started: Project: OverlayServer, Configuration: Debug
Win32 ------
1> main.cpp
1>main.cpp(13): error C2668: 'std::bind' : ambiguous call to overloaded function
1> c:\program files (x86)\microsoft visual studio
11.0\vc\include\functional(1387): could be
'std::_Bind<_Forced,_Ret,_Fun,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>>
std::bind<void,const std::string&,boost::arg<I>&>(_Rx (__cdecl
*)(const std::basic_string<_Elem,_Traits,_Alloc>),_Vx0_t)' [found
using argument-dependent lookup]
1> with
1> [
1> _Forced=true,
1> _Ret=void,
1> _Fun=void (__cdecl *const )(const std::string &),
1> _V0_t=boost::arg<1> &,
1> _V1_t=std::_Nil,
1> _V2_t=std::_Nil,
1> _V3_t=std::_Nil,
1> _V4_t=std::_Nil,
1> _V5_t=std::_Nil,
1> <unnamed-symbol>=std::_Nil,
1> I=1,
1> _Rx=void,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>,
1> _Vx0_t=boost::arg<1> &
1> ]
1> c:\externalpackages\boost_1_55_0\boost\bind\bind_cc.hpp(26):
or 'boost::_bi::bind_t<R,F,L> boost::bind<void,const
std::string&,boost::arg<I>>(R (__cdecl *)(B1),A1)'
1> with
1> [
1> R=void,
1> F=void (__cdecl *)(const std::string &),
1> L=boost::_bi::list1<boost::arg<1>>,
1> I=1,
1> B1=const std::string &,
1> A1=boost::arg<1>
1> ]
1> while trying to match the argument list
'(overloaded-function, boost::arg<I>)'
1> with
1> [
1> I=1
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


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