3 ms·
std::vector<quantity<si::milli<si::seconds>>> vec; I've seen efforts like this in the past, but in my experience there's a substantial readability cost when yo
by michaelt 3y ago
std::vector<quantity<si::milli<si::seconds>>> vec;
I've seen efforts like this in the past, but in my experience there's a substantial readability cost when you replace a single-line calculation with a multi-line one to accommodate giant type definitions like this.
And you just know anyone who's adopting this library is also going to have long variable names and a strict line length limit, both of which they will describe as "clean code" :)
- jeffreygoesto 3y agoShorthands for some heavily used units are not forbidden. ;) For vectors you can take that one step further even... https://cpponsea.uk/2022/sessions/taking-static-type-safety-to-the-next-level-physical-units-for-matrices.html https://cpponsea.uk/2022/sessions/taking-static-type-safety-...
- Y_Y 3y agoDoesn't your calculation happen after you've declared your types? I agree that this is needlessly long, but in my experience you can say what the physical units of your input variables and constants are up top and the let everything else be inferred and your computations should look the same as ever, but with extra checking at compile time.