c++ - Ambiguous call to a function -


i have 4 functions:

template<class exception,class argument>  void allocate_help(const argument& arg,int2type<true>)const;   template<class exception,class argument>  std::nullptr_t allocate_help(const argument& arg,int2type<false>)const;   template<class exception>  void allocate_help(const exception& ex,int2type<true>)const;   template<class exception>  std::nullptr_t allocate_help(const exception& ex,int2type<false>)const; 

but when call:

allocate_help<std::bad_alloc>(e,int2type<true>()); //here e of std::bad_alloc type  

i'm getting error:
error 3 error c2668: ambiguous call overloaded function why?

because call matches both:

template<class exception,class argument>  void allocate_help(const argument& arg,int2type<true>)const; 

with exception = std::bad_alloc , argument = std::bad_alloc (argument automatically deduced), and:

template<class exception>  void allocate_help(const exception& ex,int2type<true>)const; 

with exception = std::bad_alloc. hence ambiguity of call.

also think compiler should output matching function after error line, answer question yourself.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -