diff --git a/main/au.hh b/main/au.hh index 745513b4..44af35b9 100644 --- a/main/au.hh +++ b/main/au.hh @@ -24,7 +24,7 @@ #include #include -// Version identifier: 0.3.5-3-g40c8e0c +// Version identifier: 0.3.5-4-gf77cc5e // support: INCLUDED // List of included units: // amperes @@ -5561,31 +5561,47 @@ struct AssociatedUnit> : stdx::type_identity {}; } // namespace au - namespace au { -// Define 1:1 mapping between duration types of chrono library and our library. -template -struct CorrespondingQuantity> { - using Unit = decltype(Seconds{} * (mag() / mag())); - using Rep = RepT; +// DO NOT follow this pattern to define your own units. This is for library-defined units. +// Instead, follow instructions at (https://aurora-opensource.github.io/au/main/howto/new-units/). +template +struct MinutesLabel { + static constexpr const char label[] = "min"; +}; +template +constexpr const char MinutesLabel::label[]; +struct Minutes : decltype(Seconds{} * mag<60>()), MinutesLabel { + using MinutesLabel::label; +}; +constexpr auto minute = SingularNameFor{}; +constexpr auto minutes = QuantityMaker{}; - using ChronoDuration = std::chrono::duration; +namespace symbols { +constexpr auto min = SymbolFor{}; +} +} // namespace au - static constexpr Rep extract_value(ChronoDuration d) { return d.count(); } - static constexpr ChronoDuration construct_from_value(Rep x) { return ChronoDuration{x}; } + +namespace au { + +// DO NOT follow this pattern to define your own units. This is for library-defined units. +// Instead, follow instructions at (https://aurora-opensource.github.io/au/main/howto/new-units/). +template +struct HoursLabel { + static constexpr const char label[] = "h"; +}; +template +constexpr const char HoursLabel::label[]; +struct Hours : decltype(Minutes{} * mag<60>()), HoursLabel { + using HoursLabel::label; }; +constexpr auto hour = SingularNameFor{}; +constexpr auto hours = QuantityMaker{}; -// Convert any Au duration quantity to an equivalent `std::chrono::duration`. -template -constexpr auto as_chrono_duration(Quantity dt) { - constexpr auto ratio = unit_ratio(U{}, seconds); - static_assert(is_rational(ratio), "Cannot convert to chrono::duration with non-rational ratio"); - return std::chrono::duration(numerator(ratio)), - get_value(denominator(ratio))>>{dt}; +namespace symbols { +constexpr auto h = SymbolFor{}; } - } // namespace au @@ -6439,3 +6455,65 @@ constexpr bool numeric_limits>::tinyness_before; } // namespace std + + +namespace au { + +// Define 1:1 mapping between duration types of chrono library and our library. +template +struct CorrespondingQuantity> { + using Unit = decltype(Seconds{} * (mag() / mag())); + using Rep = RepT; + + using ChronoDuration = std::chrono::duration; + + static constexpr Rep extract_value(ChronoDuration d) { return d.count(); } + static constexpr ChronoDuration construct_from_value(Rep x) { return ChronoDuration{x}; } +}; + +// Define special mappings for widely used chrono types. +template +struct SpecialCorrespondingQuantity { + using Unit = AuUnit; + using Rep = decltype(ChronoType{}.count()); + + static constexpr Rep extract_value(ChronoType d) { return d.count(); } + static constexpr ChronoType construct_from_value(Rep x) { return ChronoType{x}; } +}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +// Convert any Au duration quantity to an equivalent `std::chrono::duration`. +template +constexpr auto as_chrono_duration(Quantity dt) { + constexpr auto ratio = unit_ratio(U{}, seconds); + static_assert(is_rational(ratio), "Cannot convert to chrono::duration with non-rational ratio"); + return std::chrono::duration(numerator(ratio)), + get_value(denominator(ratio))>>{dt}; +} + +} // namespace au + diff --git a/main/au_all_units.hh b/main/au_all_units.hh index 4415b12c..e2a02132 100644 --- a/main/au_all_units.hh +++ b/main/au_all_units.hh @@ -24,7 +24,7 @@ #include #include -// Version identifier: 0.3.5-3-g40c8e0c +// Version identifier: 0.3.5-4-gf77cc5e // support: INCLUDED // List of included units: // amperes @@ -7036,34 +7036,6 @@ constexpr bool numeric_limits>::tinyness_before; } // namespace std - -namespace au { - -// Define 1:1 mapping between duration types of chrono library and our library. -template -struct CorrespondingQuantity> { - using Unit = decltype(Seconds{} * (mag() / mag())); - using Rep = RepT; - - using ChronoDuration = std::chrono::duration; - - static constexpr Rep extract_value(ChronoDuration d) { return d.count(); } - static constexpr ChronoDuration construct_from_value(Rep x) { return ChronoDuration{x}; } -}; - -// Convert any Au duration quantity to an equivalent `std::chrono::duration`. -template -constexpr auto as_chrono_duration(Quantity dt) { - constexpr auto ratio = unit_ratio(U{}, seconds); - static_assert(is_rational(ratio), "Cannot convert to chrono::duration with non-rational ratio"); - return std::chrono::duration(numerator(ratio)), - get_value(denominator(ratio))>>{dt}; -} - -} // namespace au - - namespace au { // DO NOT follow this pattern to define your own units. This is for library-defined units. @@ -7219,6 +7191,67 @@ constexpr auto bar = SymbolFor{}; +namespace au { + +// Define 1:1 mapping between duration types of chrono library and our library. +template +struct CorrespondingQuantity> { + using Unit = decltype(Seconds{} * (mag() / mag())); + using Rep = RepT; + + using ChronoDuration = std::chrono::duration; + + static constexpr Rep extract_value(ChronoDuration d) { return d.count(); } + static constexpr ChronoDuration construct_from_value(Rep x) { return ChronoDuration{x}; } +}; + +// Define special mappings for widely used chrono types. +template +struct SpecialCorrespondingQuantity { + using Unit = AuUnit; + using Rep = decltype(ChronoType{}.count()); + + static constexpr Rep extract_value(ChronoType d) { return d.count(); } + static constexpr ChronoType construct_from_value(Rep x) { return ChronoType{x}; } +}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +// Convert any Au duration quantity to an equivalent `std::chrono::duration`. +template +constexpr auto as_chrono_duration(Quantity dt) { + constexpr auto ratio = unit_ratio(U{}, seconds); + static_assert(is_rational(ratio), "Cannot convert to chrono::duration with non-rational ratio"); + return std::chrono::duration(numerator(ratio)), + get_value(denominator(ratio))>>{dt}; +} + +} // namespace au + + namespace au { // DO NOT follow this pattern to define your own units. This is for library-defined units. @@ -7263,6 +7296,7 @@ constexpr auto W = SymbolFor{}; } // namespace au + namespace au { // DO NOT follow this pattern to define your own units. This is for library-defined units. diff --git a/main/au_all_units_noio.hh b/main/au_all_units_noio.hh index f62c2811..2bd4c435 100644 --- a/main/au_all_units_noio.hh +++ b/main/au_all_units_noio.hh @@ -23,7 +23,7 @@ #include #include -// Version identifier: 0.3.5-3-g40c8e0c +// Version identifier: 0.3.5-4-gf77cc5e // support: EXCLUDED // List of included units: // amperes @@ -7004,34 +7004,6 @@ constexpr auto ftm = SymbolFor{}; } // namespace au - -namespace au { - -// Define 1:1 mapping between duration types of chrono library and our library. -template -struct CorrespondingQuantity> { - using Unit = decltype(Seconds{} * (mag() / mag())); - using Rep = RepT; - - using ChronoDuration = std::chrono::duration; - - static constexpr Rep extract_value(ChronoDuration d) { return d.count(); } - static constexpr ChronoDuration construct_from_value(Rep x) { return ChronoDuration{x}; } -}; - -// Convert any Au duration quantity to an equivalent `std::chrono::duration`. -template -constexpr auto as_chrono_duration(Quantity dt) { - constexpr auto ratio = unit_ratio(U{}, seconds); - static_assert(is_rational(ratio), "Cannot convert to chrono::duration with non-rational ratio"); - return std::chrono::duration(numerator(ratio)), - get_value(denominator(ratio))>>{dt}; -} - -} // namespace au - - namespace au { // DO NOT follow this pattern to define your own units. This is for library-defined units. @@ -7187,6 +7159,67 @@ constexpr auto bar = SymbolFor{}; +namespace au { + +// Define 1:1 mapping between duration types of chrono library and our library. +template +struct CorrespondingQuantity> { + using Unit = decltype(Seconds{} * (mag() / mag())); + using Rep = RepT; + + using ChronoDuration = std::chrono::duration; + + static constexpr Rep extract_value(ChronoDuration d) { return d.count(); } + static constexpr ChronoDuration construct_from_value(Rep x) { return ChronoDuration{x}; } +}; + +// Define special mappings for widely used chrono types. +template +struct SpecialCorrespondingQuantity { + using Unit = AuUnit; + using Rep = decltype(ChronoType{}.count()); + + static constexpr Rep extract_value(ChronoType d) { return d.count(); } + static constexpr ChronoType construct_from_value(Rep x) { return ChronoType{x}; } +}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +// Convert any Au duration quantity to an equivalent `std::chrono::duration`. +template +constexpr auto as_chrono_duration(Quantity dt) { + constexpr auto ratio = unit_ratio(U{}, seconds); + static_assert(is_rational(ratio), "Cannot convert to chrono::duration with non-rational ratio"); + return std::chrono::duration(numerator(ratio)), + get_value(denominator(ratio))>>{dt}; +} + +} // namespace au + + namespace au { // DO NOT follow this pattern to define your own units. This is for library-defined units. @@ -7231,6 +7264,7 @@ constexpr auto W = SymbolFor{}; } // namespace au + namespace au { // DO NOT follow this pattern to define your own units. This is for library-defined units. diff --git a/main/au_noio.hh b/main/au_noio.hh index 3d8bab53..acb6af61 100644 --- a/main/au_noio.hh +++ b/main/au_noio.hh @@ -23,7 +23,7 @@ #include #include -// Version identifier: 0.3.5-3-g40c8e0c +// Version identifier: 0.3.5-4-gf77cc5e // support: EXCLUDED // List of included units: // amperes @@ -6358,31 +6358,47 @@ constexpr bool numeric_limits>::tinyness_before; } // namespace std - namespace au { -// Define 1:1 mapping between duration types of chrono library and our library. -template -struct CorrespondingQuantity> { - using Unit = decltype(Seconds{} * (mag() / mag())); - using Rep = RepT; +// DO NOT follow this pattern to define your own units. This is for library-defined units. +// Instead, follow instructions at (https://aurora-opensource.github.io/au/main/howto/new-units/). +template +struct MinutesLabel { + static constexpr const char label[] = "min"; +}; +template +constexpr const char MinutesLabel::label[]; +struct Minutes : decltype(Seconds{} * mag<60>()), MinutesLabel { + using MinutesLabel::label; +}; +constexpr auto minute = SingularNameFor{}; +constexpr auto minutes = QuantityMaker{}; - using ChronoDuration = std::chrono::duration; +namespace symbols { +constexpr auto min = SymbolFor{}; +} +} // namespace au - static constexpr Rep extract_value(ChronoDuration d) { return d.count(); } - static constexpr ChronoDuration construct_from_value(Rep x) { return ChronoDuration{x}; } + +namespace au { + +// DO NOT follow this pattern to define your own units. This is for library-defined units. +// Instead, follow instructions at (https://aurora-opensource.github.io/au/main/howto/new-units/). +template +struct HoursLabel { + static constexpr const char label[] = "h"; +}; +template +constexpr const char HoursLabel::label[]; +struct Hours : decltype(Minutes{} * mag<60>()), HoursLabel { + using HoursLabel::label; }; +constexpr auto hour = SingularNameFor{}; +constexpr auto hours = QuantityMaker{}; -// Convert any Au duration quantity to an equivalent `std::chrono::duration`. -template -constexpr auto as_chrono_duration(Quantity dt) { - constexpr auto ratio = unit_ratio(U{}, seconds); - static_assert(is_rational(ratio), "Cannot convert to chrono::duration with non-rational ratio"); - return std::chrono::duration(numerator(ratio)), - get_value(denominator(ratio))>>{dt}; +namespace symbols { +constexpr auto h = SymbolFor{}; } - } // namespace au @@ -6407,3 +6423,65 @@ constexpr auto b = SymbolFor{}; } } // namespace au + + +namespace au { + +// Define 1:1 mapping between duration types of chrono library and our library. +template +struct CorrespondingQuantity> { + using Unit = decltype(Seconds{} * (mag() / mag())); + using Rep = RepT; + + using ChronoDuration = std::chrono::duration; + + static constexpr Rep extract_value(ChronoDuration d) { return d.count(); } + static constexpr ChronoDuration construct_from_value(Rep x) { return ChronoDuration{x}; } +}; + +// Define special mappings for widely used chrono types. +template +struct SpecialCorrespondingQuantity { + using Unit = AuUnit; + using Rep = decltype(ChronoType{}.count()); + + static constexpr Rep extract_value(ChronoType d) { return d.count(); } + static constexpr ChronoType construct_from_value(Rep x) { return ChronoType{x}; } +}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity> {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +template <> +struct CorrespondingQuantity + : SpecialCorrespondingQuantity {}; + +// Convert any Au duration quantity to an equivalent `std::chrono::duration`. +template +constexpr auto as_chrono_duration(Quantity dt) { + constexpr auto ratio = unit_ratio(U{}, seconds); + static_assert(is_rational(ratio), "Cannot convert to chrono::duration with non-rational ratio"); + return std::chrono::duration(numerator(ratio)), + get_value(denominator(ratio))>>{dt}; +} + +} // namespace au +