Make Time trivially copyable?


#1

Would it be possible to make Time trivially copyable so I can use it in a std::atomic please?
I think all that needs to happen it to delete the destructor and default the copy constructor and assignment operators.

Is there any reason this shouldn’t be done?


#2

Yep, good idea.


#3

Thanks.

Interestingly this revealed a couple of “unused variable” instances of Time.
It must be that now it’s trivial, the compiler knows the constructor can’t have side effects so it’s useless to have one and not use it.

I guess that also means it’s much more likely to just sit in a register rather than create memory as well…


#4

Ah, that’s interesting. We should probably trawl the codebase for other classes like this that could benefit from the same change.


#5

Yeah. I think @t0m did a bunch a couple of months ago with the ArrayBase changes as trivially copyable objects can also use the memcpy version of Array.

I’m sure there are few more out there though. Maybe adding static_asserts for classes that you think should be trivial is a good place to start.