S
siddhu
why can't we have array of references.
siddhu said:why can't we have array of references.
why can't we have array of references.
why can't we have array of references.
* siddhu:
A reference is not an object, it has no size.
why can't we have array of references.
terminator said:it has a size usually equal to that of a pointer in case of usage an
argument to a none inlined function.
it has a size usually equal to that of a pointer in case of usage an
argument to a none inlined function.
it has a size usually equal to that of a pointer in case of usage an
argument to a none inlined function.
* siddhu:
A reference is not an object, it has no size.
Abhishek said:If by size you mean storage, it is *unspecified* that they have
storage or not. So, saying they have no size would be incorrect.
Chapter and verse: 8.3.2 (4) (2007-06-25 draft).
why can't we have array of references.
If by size you mean storage, it is *unspecified* that they have
storage or not. So, saying they have no size would be incorrect.
Chapter and verse: 8.3.2 (4) (2007-06-25 draft).
The more proper way of answering the original question would then
be "becuase the Standard says so in [dcl.ref]/4".
No, references don't even have to have a physical representation.
Analogous to typedef, a reference only introduces a new name for an object.
It turns out that usually memory for an address is allocated for reference
parameters and reference object members, but it would be a pretty poor
compiler that allocated anything at all for a local reference.
joe
* terminator:
Sorry, that's incorrect. Or not even wrong. If you want to make an
argument, cough up chapter and verse from the standard.
And when the size isn't equal to that of a pointer, what is it?
I said in case of usage as **an argument to a none inlined function**.
If by size you mean storage, it is *unspecified* that they have
storage or not. So, saying they have no size would be incorrect.
Chapter and verse: 8.3.2 (4) (2007-06-25 draft).
Arrays of references are not possible because they may or may not
require storage (implemented as to have size or not). In the cases
(implementations) when they won't have a size, arrays of them won't be
possible. References are not considered as objects by the standards.
They are just aliases. In next standards revision, there might be a
reference_wrapper added that can be used instead of plain references
wherever you need to make arrays of them or use them with standard
containers.
Alf said:Sorry, that's incorrect. Or not even wrong. If you want to make an
argument, cough up chapter and verse from the standard.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.