Boost logo

Boost :

Subject: [boost] [function] function_template.hpp has ambiguous mem_fn calls on compilers with std::mem_fn (VC10); simple 2-line fix
From: Conrad Poelman (cpboost_at_[hidden])
Date: 2010-04-29 12:47:51


*Summary*: It seems that function_template.hpp needs "boost::" in front
of mem_fn in two spots so as not to be ambiguous with std::mem_fn on
compilers that have std::mem_fn. (mem_fn appears in that file 4 times;
two spots already use fully-qualified "boost::mem_fn".)

I entered this at https://svn.boost.org/trac/boost/ticket/4073, but just
wondered what the process is for having this fix committed to boost
repository.

**Example**: Here's a reproducible example that won't compile in Visual
Studio 2010 (produces an "ambiguous call to overloaded function" error
regarding mem_fn - could be boost::mem_fn or could be std::mem_fn) but
that compiles fine in other compilers that don't have an std::mem_fn:

#include<boost/function.hpp>
#include<string>

class PrimitiveBuilder
{
public:
   bool someFunction( std::string& token );
   void registerSomeFunction() {
     mPrimitiveFunctor =&PrimitiveBuilder::someFunction; // ambiguity
error is here
   }
private:
   typedef boost::function<bool (PrimitiveBuilder*, std::string&
token)> PrimitiveFunctor;
   PrimitiveFunctor mPrimitiveFunctor;
};

The above code compiles and works fine in VS 2010 once "boost::" is
added to mem_fn in function_template.hpp.

I look forward to hearing your thoughts. Thanks!

-- Conrad


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk