This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ambiguous overload ?


Hi,

I have the following question about overloading the following two functions.

int& Reg(string& name) ;
int Reg(string& name);

The g++ reports that:

CRegisterMap.c: In function `int & Reg(class basic_string<char,string_char_traits<char>,__default_alloc_template<false,0> > &)':
CRegisterMap.c:32: new declaration `int & Reg(class basic_string<char,string_char_traits<char>,__default_alloc_template<false,0> > &)'
CRegisterMap.c:24: ambiguates old declaration `int Reg(class basic_string<char,string_char_traits<char>,__default_alloc_template<false,0> > &)'

I thought g++ should make the difference between the two functions and will
call the functions correctly based on whether it is used as  lvalue or rvalue, that
is actually my purpose of overloading these two functions in this way!

Any suggestions,

Thanks for your attension!
weifeng


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]