#include <iostream>
struct A
{
template < typename T >
void foo( const T& v )
{ std::cout << "A::foo( const T& v ) - v == " << v << '\n' ; }
template < typename T, std::size_t N >
void foo( const T(&array)[N] )
{
std::cout << "A::foo( const T(&array)[" << N << "] ): " ;
for( const auto& v : array ) std::cout << v << ' ' ;
std::cout << '\n' ;
}
template < typename T >
void foo( const T array[], std::size_t n )
{
std::cout << "A::foo( const T array[], n ) - n == " << n << ": " ;
for( std::size_t i = 0 ; i < n ; ++i ) std::cout << array[i] << ' ' ;
std::cout << '\n' ;
}
};
int main()
{
double d[5] = { 1.1, 2.3, 3.3, 4.4, 5.5 } ;
A a ;
a.foo( d[3] ) ; // A::foo( const T& v ) - v == 4.4
a.foo(d) ; // A::foo( const T(&array)[5] ): 1.1 2.3 3.3 4.4 5.5
a.foo( d, 5 ) ; // A::foo( const T array[], n ) - n == 5: 1.1 2.3 3.3 4.4 5.5
a.foo( +d ) ; // A::foo( const T& v ) - v == <pointer> (T is pointer to double)
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEEKewogICAgdGVtcGxhdGUgPCB0eXBlbmFtZSBUID4KICAgIHZvaWQgZm9vKCBjb25zdCBUJiB2ICkKICAgIHsgc3RkOjpjb3V0IDw8ICJBOjpmb28oIGNvbnN0IFQmIHYgKSAtIHYgPT0gIiA8PCB2IDw8ICdcbicgOyB9CgogICAgdGVtcGxhdGUgPCB0eXBlbmFtZSBULCBzdGQ6OnNpemVfdCBOID4KICAgIHZvaWQgZm9vKCBjb25zdCBUKCZhcnJheSlbTl0gKQogICAgewogICAgICAgIHN0ZDo6Y291dCA8PCAiQTo6Zm9vKCBjb25zdCBUKCZhcnJheSlbIiA8PCBOIDw8ICJdICk6ICIgOwogICAgICAgIGZvciggY29uc3QgYXV0byYgdiA6IGFycmF5ICkgc3RkOjpjb3V0IDw8IHYgPDwgJyAnIDsKICAgICAgICBzdGQ6OmNvdXQgPDwgJ1xuJyA7CiAgICB9CgogICAgdGVtcGxhdGUgPCB0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