[Multi-index] : code fail to compile with VS2010 and boost 1.46.1. Proposed workaround

Hello, I had some code using boost 1.46.1 Multi-index library that used to compile and work very well with VS2008. I recently turned to VS2010 and some code is not compiling anymore. The problem is located in the boost_1_46_1\boost\multi_index\composite_key.hpp file and the compiler complains about not being able to distinguish between ambiguous overloads... I had to modify the composite_key.hpp file and have following changes : line 1001 : //return operator()(x,make_tuple(cref(y))); return operator()(x,make_tuple(boost::cref(y))); line 1036 : //return operator()(make_tuple(cref(x)),y); return operator()(make_tuple(boost::cref(x)),y); In order to explicitely add the boost namespace for cref. With those changes, it do compile and works very well. Can those changes in composite_key.hpp break something else ? Is there another workaround I would have missed ? I'm suspecting some conflict with new TR1 things i'm not very familiar with... Best regards, Mathieu Peyréga

I had to modify the composite_key.hpp file and have following changes :
line 1001 : //return operator()(x,make_tuple(cref(y))); return operator()(x,make_tuple(boost::cref(y)));
line 1036 : //return operator()(make_tuple(cref(x)),y); return operator()(make_tuple(boost::cref(x)),y);
In order to explicitely add the boost namespace for cref.
With those changes, it do compile and works very well. Can those changes in composite_key.hpp break something else ? Is there another workaround I would have missed ? I'm suspecting some conflict with new TR1 things i'm not very familiar
Perhaps, you have "using namespace std;" directive somewhere before you include this header?

Hello,
I've just been checking and could not find any "using namespace std"
statement in any of the includes...
I've even been checking with reverting to genuine composite_key file and
adding an explicit
namespace boost
{
}
using namespace boost;
before the includes in my cpp file which appear in the following order :
#include
I had to modify the composite_key.hpp file and have following changes :
line 1001 : //return operator()(x,make_tuple(cref(y))); return operator()(x,make_tuple(boost::cref(y)));
line 1036 : //return operator()(make_tuple(cref(x)),y); return operator()(make_tuple(boost::cref(x)),y);
In order to explicitely add the boost namespace for cref.
With those changes, it do compile and works very well. Can those changes in composite_key.hpp break something else ? Is there another workaround I would have missed ? I'm suspecting some conflict with new TR1 things i'm not very familiar
Perhaps, you have "using namespace std;" directive somewhere before you include this header? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Here is an example of the described behaviour
Here, it does not compile with non modified composite_key.hpp file, and
do compile with modified file.
Regards,
Mathieu Peyréga
-----------------------------
test_multi_index.cpp
-----------------------------
#include <string>
#include

The same, but a bit shorter:
#include <string>
#include
key;
typedef multi_index_container
container;
void fail_to_compile() { container c; std::string val = "abcd"; c.equal_range(val); } };

Igor R
The same, but a bit shorter: [...]
Although I can'r reproduce the behavior (I don't have VS2010 here) this is no doubt produced by ADL ambiguities between std::ref(broght in by std::string in this example) and boost::ref. The change at https://svn.boost.org/trac/boost/changeset/71671 should fix this. Can you please check out before I merge to the release branch? Thank you, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Hello, your modified version works for me with Visual Studio 2010 sp1 and boost 1.46.1 Regards, Mathieu Peyréga Le 02/05/2011 17:10, Joaquin M Lopez Munoz a écrit :
Igor R
writes: The same, but a bit shorter: [...] Although I can'r reproduce the behavior (I don't have VS2010 here) this is no doubt produced by ADL ambiguities between std::ref(broght in by std::string in this example) and boost::ref.
The change at
https://svn.boost.org/trac/boost/changeset/71671
should fix this. Can you please check out before I merge to the release branch?
Thank you,
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

The same, but a bit shorter: [...]
Although I can'r reproduce the behavior (I don't have VS2010 here) this is no doubt produced by ADL ambiguities between std::ref(broght in by std::string in this example) and boost::ref.
The change at
https://svn.boost.org/trac/boost/changeset/71671
should fix this. Can you please check out before I merge to the release branch?
Yes, it seems to be ok. Thanks.
participants (3)
-
Igor R
-
Joaquin M Lopez Munoz
-
Mathieu Peyréga