On Mon, 28 Apr 2014 06:04:53 -0400, John Colvin <john.loughran.col...@gmail.com> wrote:

On Monday, 28 April 2014 at 09:36:08 UTC, Andrey wrote:
not a bug.

b.f[10] is indexing the pointer to the array, not the array itself.

b.f[0][10] is indexing the array (with the 10), but I would argue it is better to write *(b.f)[10] so as to be clear that f is not an array.

thank you, John.

compiler said that '*(b.f)[10]' is deprecated, and I should write like this

void foo()
{
   Type3 b;
   Type1  d;
   d = *(b.f[10]).ptr;
}

struct T
{
        int[10]* f;
}

void main()
{
        int[10] test;
        T t = T(&test);
        T* b = &t;
        
        auto d = (*(b.f))[4]; //ugly but clear.
        d = b.f[0][4]; //prettier but less clear.
}

note the extra brackets on the ugly one, I forgot them before.

You don't need them. (*b.f)[4] works. '.' has precedence over '*'.

-Steve
  • Is this a bug? Andrey via Digitalmars-d-learn
    • Re: Is this a bug? John Colvin via Digitalmars-d-learn
      • Re: Is this a bug? Andrey via Digitalmars-d-learn
        • Re: Is this a bu... John Colvin via Digitalmars-d-learn
          • Re: Is this ... Andrey via Digitalmars-d-learn
          • Re: Is this ... Steven Schveighoffer via Digitalmars-d-learn
            • Re: Is ... John Colvin via Digitalmars-d-learn
            • Re: Is ... Andrey via Digitalmars-d-learn
              • Re:... Andrey via Digitalmars-d-learn
                • ... via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
              • Re:... John Colvin via Digitalmars-d-learn
                • ... Ali Çehreli via Digitalmars-d-learn
                • ... Meta via Digitalmars-d-learn
                • ... Ali Çehreli via Digitalmars-d-learn
                • ... David Held via Digitalmars-d-learn

Reply via email to