Skip to content

Instantly share code, notes, and snippets.

@garethlewin
Last active Aug 29, 2015
Embed
What would you like to do?
// Why does this work:
int addrInfoRet = getaddrinfo(host.c_str(), port.c_str(), &hints, &remoteHost);
auto deleter = [](addrinfo* p){ if (p) {freeaddrinfo (p);} };
std::unique_ptr<addrinfo, decltype(deleter)> remoteHostContainer(remoteHost, deleter);
// But this doesn't:
int addrInfoRet = getaddrinfo(host.c_str(), port.c_str(), &hints, &remoteHost);
std::unique_ptr<addrinfo, decltype(freeaddrinfo)> remoteHostContainer(remoteHost, freeaddrinfo);
//(Error spam is):
/*
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\memory(1221): warning C4180: qualifier applied to function type has no meaning; ignored
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\memory(1283) : see reference to class template instantiation 'std::_Unique_ptr_base<_Ty,_Dx,_Empty_deleter>' being compiled
1> with
1> [
1> _Ty=addrinfo,
1> _Dx=void (PADDRINFOA),
1> _Empty_deleter=false
1> ]
1> x:\dev\sdk\twitchsdk\twitchcore\source\win32\socket.cpp(106) : see reference to class template instantiation 'std::unique_ptr<_Ty,_Dx>' being compiled
1> with
1> [
1> _Ty=addrinfo,
1> _Dx=void (PADDRINFOA)
1> ]
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\memory(1227): error C2207: 'std::_Unique_ptr_base<_Ty,_Dx,_Empty_deleter>::_Mydel' : a member of a class template cannot acquire a function type
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\memory(1322): warning C4180: qualifier applied to function type has no meaning; ignored
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment