Date: Sun, 1 May 2022 04:28:19 -0400
A programmer should not expect alignof to return the number of bytes in a
char array. If I'm understanding what you're suggesting correctly. I'm a
little confused.
From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of
Abdullah Qasim via Std-Proposals
Sent: Sunday, May 1, 2022 04:23 AM
To: Jason McKesson via Std-Proposals <std-proposals_at_[hidden]>
Cc: Abdullah Qasim <iamminecraftredstoner_at_[hidden]>
Subject: [std-proposals] operator alignof
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!
char array. If I'm understanding what you're suggesting correctly. I'm a
little confused.
From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of
Abdullah Qasim via Std-Proposals
Sent: Sunday, May 1, 2022 04:23 AM
To: Jason McKesson via Std-Proposals <std-proposals_at_[hidden]>
Cc: Abdullah Qasim <iamminecraftredstoner_at_[hidden]>
Subject: [std-proposals] operator alignof
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!
Received on 2022-05-01 08:28:22