add in-class initializers to primitive fields - #689
Conversation
|
I want to think about this one for a bit |
|
Joseph Borodach (@JosephBorodach) - I spent some time musing about this. As an old-school high-performance C++ type, my initial reaction was that I didn't like the idea. Basically, by giving these types non-static data-member initializers, they are no longer trivial types. So, for instance, it is no longer free to allocate an array of them, because now each one needs initialization. From there, I'd have argued that users who write, for instance, However, practical considerations I think rule the day the other way, in favor of your change.
So, having thought about it and done some research, I'm somewhat reluctantly in favor. I will take a pass through the changes themselves to see if any of them require more thought. |
|
Thanks for taking the time to think it through Andrew C. Morrow (@acmorrow) - the tradeoff you're weighing is the right one, and I appreciate you landing on the ergonomics side despite the triviality cost. |
Andrew C. Morrow (acmorrow)
left a comment
There was a problem hiding this comment.
LGTM, but I'd like lia (@lia-viam) to take a second look in case any of the defaults have semantics I'm not aware of.
|
Hey Joseph Borodach (@JosephBorodach) — this PR has been approved and CI has been green for 3+ business days. Ready to merge? Auto-comment from overwatch. Will not re-nudge for 7 days. |
| std::chrono::nanoseconds start_timestamp_ns; | ||
| std::chrono::nanoseconds end_timestamp_ns; | ||
| int sequence_number; // sequential chunk number | ||
| std::chrono::nanoseconds start_timestamp_ns = std::chrono::nanoseconds::zero(); |
There was a problem hiding this comment.
can this not just be = {} ?
There was a problem hiding this comment.
Good catch and it's more consistent with the other defaults in this PR. Updating
Add in-class initializers to primitive fields across all remaining POD types in the SDK
Why
Followup to #687, which fixed Camera::properties only. Same footgun exists in every other POD carried over gRPC