Closed JohelEGP closed 6 years ago
Consider the following program.
#include <units/length.h>
using namespace units::literals;
const auto sq_m = 2_m * 2_m;
In face of strong type aliases for units, it would result in a compile-time error since the type of 2_m * 2_m
would be incomplete. It works today because everything's an alias.
I tried to rebase the first commit, by first doing a git mv include/units.h include/units/core.h
and then moving non-core functionality into units.h
, in order to reduce the number of apparent changed lines and ease review. It failed, and worse, the changed lines count increased. I think it has to do with the fact that units.h
still exists, and thus the git mv
doesn't help.
@johelegp per your earlier comment... yikes. We can't guarantee (and don't want to) that a definition will exist for every ephemeral unit type. That sounds like a show-stopper for strong type aliases, at least for unit
.
As explained above (https://github.com/nholthaus/units/pull/171#issuecomment-411916790), the reason it would result in a compile-time error is because core.h
would include the forward declaration of square_meter_t
and specialization of traits::strong
or similar for it, which the operator would use for its return type. Ephemeral units don't need that.
The headers have been split.
Resolves #164.
How does it look like so far? If it's good, I'll continue with the rest of dimensions.