`ref T` should be a type!!
Rubn
where at is.this
Tue Apr 2 00:20:54 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.
>
>
>> 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. Be careful what
> you wish for.
Let's put it this way, is const a type? No? You would say it is a
"sturage class". Considering the following now though:
What do you think the following code is going to print?
import std.stdio;
void foo(T)(T a) {
writeln(T.stringof);
}
template is_same(T, G) {
enum is_same = is(T == G);
}
void main() {
int a;
const int b;
foo( a );
foo( b );
writeln( "is_same: ", is_same!(typeof(a), typeof(b)) );
}
More information about the Digitalmars-d
mailing list