Consider:

 

class cstring {

  // assume public functions...

 

private:

  char* ptr;         // used for dynamic allocation

  uint64_t length;

}

 

Now, assume I make cstring c(“12”)

 

Length takes 8 bytes.

Allocated char array takes 3 bytes.

Therefore:

  alignof(c)

returns 8

 

Why not 3?:

 

// In cstring

operator alignof () {

  return alignof (charArr);

}

 

Which is what the user expected!