In a template-context, pointers to overloaded methods are not correctly
resolved. the following main.cpp does not compile on gcc 4.1.2, however it does
compile on version 3.4.6:
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/mem_fun.hpp>
namespace mi = boost::multi_index;
struct field_ts
{
int ts() const { return 10; }
void ts(const int &arg) { }
};;
template <typename T>
struct mi_key
{
typedef typename mi::composite_key<
field_ts,
mi::const_mem_fun<field_ts, int, &field_ts::ts>
> type;
};
mi_key<int>::type key;
int main (int argc, char **argv)
{
return 0;
}
I get the following error-message:
main2.cpp: In instantiation of mi_key<int>:
main2.cpp:26: instantiated from here
main2.cpp:23: error: invalid use of field_ts::ts to form a
pointer-to-member-function
main2.cpp:23: note: a qualified-id is required
The compiler should do this automatically without you having
to disambiguate the overload, see 14.3.2/5:
"For a non-type template-parameter of type pointer to member
function, no conversions apply. If the template-argument represents
a set of overloaded member functions, the matching member
function is selected from the set (13.4)."
--
Summary: pointers to overloaded methods not correctly resolved
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mavdzee at yahoo dot co dot uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32322