|
Boost : |
Subject: [boost] Boost.Operators and make_shared
From: Pieter (PieterB_at_[hidden])
Date: 2013-07-12 04:41:09
LS,
I have noticed that using Boost.Operators has a side-effect which I can't
explain. I am using std::make_shared as a default, however, some of the
boost libraries I use pull in boost::make_shared as well.
When using some class T2 derived from one of the boost.operators classes,
this causes MSVC2010 to not compile when invoking make_shared<T2> as the
compiler can no longer resolve between the two overloaded versions of
make_shared for some reason.
I am hoping that someone out can explain what is happening here. A minimal
example is included here:
#include <memory>
#include <boost\operators.hpp>
#include <boost\make_shared.hpp>
struct T1 {};
struct T2 : boost::equality_comparable<T2> {};
int main( int argc, const char* argv[] )
{
T1 Object1;
T2 Object2;
using std::make_shared;
std::shared_ptr<T1> Ptr1 = make_shared<T1>(Object1); // OK
std::shared_ptr<T2> Ptr2 = make_shared<T2>(Object2); // error C2668:
'boost::make_shared' : ambiguous call to overloaded function
return 1;
}
Thanks in advance!
Pieter
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk