pointer cause decay, references do not.
Decay means loss of type information. In C and C++, an array name 'decays' to pointer to the first element. The information lost is basically the number of elements in the array. This difference should be manifested by sizeof() operator in function f() and g(). References keep that information with them. such as 'constness' of int. Function names are also said to 'decay' into pointer to the function if only function name is used. But such a function pointer retains, I think, everything about the function signature: parameter types and function return type; even in C.
With following declarations,
template < typename T > void f (T);
template < typename T > void g (T &);
and with these declarations,
double x[20];
int const seven = 7;
f(x); T is double *
g(x); T is double [20]
f(seven); T is int
g(seven); T is int const
f(7); T is int
g(7); T is int, ERROR can't pass 7 to int&
Therefore, pointer cause decay, references do not.
source: C++ Templates - The Complete Guide
by David Vandevoorde and Nicolai M. Josuttis
Decay means loss of type information. In C and C++, an array name 'decays' to pointer to the first element. The information lost is basically the number of elements in the array. This difference should be manifested by sizeof() operator in function f() and g(). References keep that information with them. such as 'constness' of int. Function names are also said to 'decay' into pointer to the function if only function name is used. But such a function pointer retains, I think, everything about the function signature: parameter types and function return type; even in C.
With following declarations,
template < typename T > void f (T);
template < typename T > void g (T &);
and with these declarations,
double x[20];
int const seven = 7;
f(x); T is double *
g(x); T is double [20]
f(seven); T is int
g(seven); T is int const
f(7); T is int
g(7); T is int, ERROR can't pass 7 to int&
Therefore, pointer cause decay, references do not.
source: C++ Templates - The Complete Guide
by David Vandevoorde and Nicolai M. Josuttis
Comments
and we'll visit it again! I love surfing the internet
for blogs.
I want you to stop and compare with my 1800contacts coupon blog.
this. Your site was on point and will be back again!
No matter when you are, just stop by and check for my 1800contacts com coupon blog site.
the internet, when I have the time. I'm going to go
back to it!
It may look like it was hard work, but my blog was simple.
again! Websurfing is a good way to find blogs like
yours.
I can't explain, but you need to check my 1800contacts web coupon code blog!
finding it again! I surf the net for blogs like
yours.
In my spare time I will look for your coupon codes 1800contacts blog.
back! I love surfing the internet for blogs that are
exactly like this blog.
Everyday of the month you need to peep my 1800contacts com coupon blog.
back once again to view it! I use much of my spare
time searching for blogs like yours.
I want you to look for my coupon codes 1800contacts blog.
this site again. I just worship the site its comes
from! Believe me in my extra time I'm consistently
looking up blogs like this.
My blog, is something you need to peep out!
returning to it! When I web surf it always helps me to
find great blogs.
Please go over my blog.
returning to it! When I web surf it always helps me to
find great blogs.
My 1800contacts com coupon blog, is something you need to peep out!