Sujet : Re: "span"
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.cDate : 23. Mar 2024, 20:32:06
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <utnanu$2r0de$1@i2pn2.org>
References : 1
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
Stefan Ram wrote:
Some people suggested to introduce a feature "span" (probably a
type) into C++, so that when one has an int array "a" and calls
"f( a )", the length of a is being transferred to "f", which "f"
is defined using "void f(span<int> a)". The "span" in "f" then
knows the length of "a". This is supposed to be less error prone
than passing a pointer with a separate length argument.
>
i wrote on such thing for years here - i name it "full array"
i mean
int a[20] is "full array" when a is a structure of int* to begoning and int* to end or length (there are natural two wersions and i tried both
though the one with pointer+_size is maybe more handy)
this foo(a) will pass this structure if a is full array - but this is to be done on language and compiler level
what c got
int a[20] //when a is only int*
i name half-array