In VS2015 (but not using various other compilers on multiple platforms, including VS10), I'm getting
Charlie\Gamma.cpp(224): error C2668: 'boost::make_shared': ambiguous call to overloaded function
E:\C++Libs\boost_1_60_0\boost/smart_ptr/make_shared_object.hpp(246): note: could be 'boost::shared_ptr<T> boost::make_shared<Able::Bravo::Charlie::Dog,Able::Bravo::Charlie::Egg&,const uint32_t&,const Frank&>(Able::Bravo::Charlie::Egg &,const uint32_t &,const Frank &)' [found using argument-dependent lookup]
with
[
T=Able::Bravo::Charlie::Dog
] (compiling source file Charlie\Gamma.cpp)
D:\@Prog-Charon\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(968): note: or 'std::shared_ptr<Able::Bravo::Charlie::Dog> std::make_shared<Able::Bravo::Charlie::Dog,Able::Bravo::Charlie::Egg&,const uint32_t&,const Frank&>(Able::Bravo::Charlie::Egg &,const uint32_t &,const Frank &)' (compiling source file Charlie\Gamma.cpp)
Charlie\Gamma.cpp(224): note: while trying to match the argument list '(Able::Bravo::Charlie::Egg, const uint32_t, const Frank)'
(with my closed-source names sanitized, and Boost and standard names left intact)
The code is:
namespace Able {
namespace Bravo {
namespace Charlie {
using std::string;
using std::tr1::shared_ptr;
using std::tr1::make_shared;
⋮ // then later in the file
shared_ptr<Dog> Gamma::knockout (const Hotel& target)
{
Egg softboiled (target.ID);
softboiled.sequence ^= 0x40000000;
return make_shared<Dog>(softboiled, target.kin, Frank::myself());
}
The use of make_shared sees std::tr1::make_shared brought into scope via the using declaration, and that's what is intended. The error shows that it is resolving to std::make_shared, and I expect that tr1 is just a bunch of typedefs for backward compatibility.
But it also reports finding boost::make_shared via argument-dependent lookup. But the arguments are
Able::Bravo::Charlie::Egg &,
const uint32_t &,
const Frank &
none of which are in the boost namespace.
So why would it be finding boost::make_shared via argument-dependent lookup?
Hmm, could it be because Frank is derived privately from boost::totally_ordered1 (and Egg from boost::totally_ordered)? Is this a change in the lookup rules, a fix or bug in one of the compilers, or something like that?
If that's correct, then any use of boost's mix-in types will cause all sorts of ambiguities as old boost stuff matches the names of now-standard functions, or common names in general. These private base classes end up polluting my class's namespace without even being apparent in the public interface that it's at all related to boost! That can't be right.
Update: This occurs with Boost 1.60 but not with Boost 1.59. So disregard my conclusion that it varies by compiler/platform: it's worked on various platforms with an older version of Boost.
I moved to the latest release Boost as a first step to solve compile-time issues happening with Boost, and it seems to have introduced another instead.
Boost’s operators.hpp defines template struct totally_ordered2 etc. within namespace boost, not anything more fancy, in Boost version 1.59.
boost::make_sharedin 1.60 but not 1.59.