C++ Logo

std-discussion

Advanced search

Function overload resolution

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Mon, 27 Sep 2021 19:22:37 +0300
In my opinion there is some inconsistence in the function overload resolution when a function parameter has a referenced array type.
 
Let assume that we have two functions
 
void f( const ( &a )[] );
 
and
 
void f( const ( &a )[2] );
 
If to write
 
f( { 1, 2 } );
 
then the second function will be selected.
 
However if to write
 
int a[2];
 
and then
 
f( a );
 
then the compiler will issue an error relative to an ambiguity.
 
It would be more natural if in this case also the second function would be selected.
 
With best regards
(Vlad from Moscow)
 
 
 
 
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

Received on 2021-09-27 11:23:04