`ref T` should be a type!!
Rubn
where at is.this
Tue Apr 2 00:00:34 UTC 2019
On Monday, 1 April 2019 at 20:51:44 UTC, Walter Bright wrote:
> On 4/1/2019 1:00 PM, Rubn wrote:
>> Arrays in C++ are just pointers.
>
> No, they're not.
Yes they are. The only time an array exists in C++ is (oddly)
only when you pass it by reference :). Otherwise every operation
you do on array, any time you pass an array to a function that
isn't a reference it is just a pointer. This is why buffer
overflows exist in C++, because an is literally just a pointer --
it doesn't even know it's own size! How can you call that an
array?
>> If you can't have a pointer to something, it is only natural
>> you can't have array either.
>
> g++ -c test.cpp
> test.cpp: In function void test():
> test.cpp:1:24: error: declaration of p as array of references
> void test() { int& p[3]; }
> ^
>
> As I said, C++ ref can only appear at the top of an AST, which
> is what a "storage class" is.
>
> C++ tries to have it be both a floor wax and a desert topping,
> making for a device that nobody understands.
So you are saying void is also a "storage class" ?
> Be careful what you wish for.
I'm not wishing for anything. You entered the discussion and
stated that it isn't a type. And that's what I've been arguing
against.
More information about the Digitalmars-d
mailing list