I noticed in the spec on arrays that "A [fixed-size] array with a
dimension of 0 is allowed, but no space is allocated for it. It's
useful as the last member of a variable length struct.." This sounds
like C99's "flexible array members," where a struct can have an array
as its last element that is
On Wednesday, 8 July 2009 at 22:55:47 UTC, Jarrett Billingsley
wrote:
I noticed in the spec on arrays that "A [fixed-size] array with
a
dimension of 0 is allowed, but no space is allocated for it.
It's
useful as the last member of a variable length struct.." This
sounds
like C99's "flexible ar
Jarrett Billingsley wrote:
I noticed in the spec on arrays that "A [fixed-size] array with a
dimension of 0 is allowed, but no space is allocated for it. It's
useful as the last member of a variable length struct.." ...
It would be interesting if anyone has yet to find this useful. In c
You'd have to be mad to use it like that.
struct S
{
int a;
private { size_t size; char[0] data; }
char[] message() { return data.ptr[0..length]; }
size_t length() { return size; }
S* opCall(size_t size)
{
return cast(S*)((new ubyte[S.sizeof+size]).ptr);
}
}
Daniel Keep wrote:
You'd have to be mad to use it like that.
I am mad.
struct S
{
int a;
private { size_t size; char[0] data; }
char[] message() { return data.ptr[0..length]; }
size_t length() { return size; }
S* opCall(size_t size)
{
return cast(S*)((new uby
On Thu, Jul 9, 2009 at 2:38 AM, Daniel Keep wrote:
>
> You'd have to be mad to use it like that.
>
> struct S
> {
> int a;
> private { size_t size; char[0] data; }
> char[] message() { return data.ptr[0..length]; }
> size_t length() { return size; }
>
> S* opCall(size_t size)
> {
On Thu, 09 Jul 2009 09:47:44 -0400, Jarrett Billingsley
wrote:
On Thu, Jul 9, 2009 at 2:38 AM, Daniel Keep
wrote:
You'd have to be mad to use it like that.
struct S
{
int a;
private { size_t size; char[0] data; }
char[] message() { return data.ptr[0..length]; }
...
You can
On Thu, Jul 9, 2009 at 1:09 PM, Steven Schveighoffer wrote:
> Would something like this work?
>
> (&data)[0..length]
Nope; &data is a char[0]*, and slicing it will get you a char[0][].
Which is pretty useless :D
On Thu, 09 Jul 2009 20:24:16 -0400, Jarrett Billingsley
wrote:
On Thu, Jul 9, 2009 at 1:09 PM, Steven
Schveighoffer wrote:
Would something like this work?
(&data)[0..length]
Nope; &data is a char[0]*, and slicing it will get you a char[0][].
Which is pretty useless :D
d'oh!
Yeah, th
Steven Schveighoffer wrote:
Having the compiler do the right
thing is a much better option :)
-Steve
Have you reported this issue as a bug/enhancement?
10 matches
Mail list logo