Skip to content

Remove c'tor from underlying types #434

@BenFrantzDale

Description

@BenFrantzDale

In C++, explicit isn't explicit enough. If I have

std::vector<millimeters_t> vec;
vec.emplace_back(42.0);

that's not robust against changing it to std::vector<furlongs_t> vec;; I'll wind up with 42.0 furlongs!

In my codebase I'm using a wrapper function, fromCount<Unit>(double) -> Unit. I picked "count" to match std::chrono's terminology. To be consistent with this library, I think it would be from_number<Unit>(double) -> Unit.

I'm fine with a default c'tor and with a converting c'tor (mm -> inches), but how explicit that sort of thing is is an editorial choice :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions