forked from mpusz/mp-units
Name renamed to symbol in a derived_unit
This commit is contained in:
@@ -242,7 +242,7 @@ struct unit : downcast_base<unit<D, R>> {
|
|||||||
All units are created with a `derived_unit` helper:
|
All units are created with a `derived_unit` helper:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Child, fixed_string Name, typename...>
|
template<typename Child, fixed_string Symbol, typename...>
|
||||||
struct derived_unit;
|
struct derived_unit;
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -259,8 +259,8 @@ to provide downcasting facility (described below).
|
|||||||
- helper to create a base unit of a specified dimension
|
- helper to create a base unit of a specified dimension
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Child, fixed_string Name, Dimension D>
|
template<typename Child, fixed_string Symbol, Dimension D>
|
||||||
struct derived_unit<Child, Name, D>;
|
struct derived_unit<Child, Symbol, D>;
|
||||||
```
|
```
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -270,8 +270,8 @@ struct metre : derived_unit<metre, "m", length> {};
|
|||||||
- helper to create other units for a specified dimension
|
- helper to create other units for a specified dimension
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Child, fixed_string Name, Dimension D, Ratio R>
|
template<typename Child, fixed_string Symbol, Dimension D, Ratio R>
|
||||||
struct derived_unit<Child, Name, D, R>;
|
struct derived_unit<Child, Symbol, D, R>;
|
||||||
```
|
```
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -281,8 +281,8 @@ struct yard : derived_unit<yard, "yd", length, ratio<9'144, 10'000>> {};
|
|||||||
- helper to create a unit with a SI prefix
|
- helper to create a unit with a SI prefix
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Child, fixed_string Name, Unit U>
|
template<typename Child, fixed_string Symbol, Unit U>
|
||||||
struct derived_unit<Child, Name, U>;
|
struct derived_unit<Child, Symbol, U>;
|
||||||
```
|
```
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -293,8 +293,8 @@ struct kilometre : derived_unit<kilometre, "km", kilo<metre>> {};
|
|||||||
of units of base dimensions
|
of units of base dimensions
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Child, fixed_string Name, Dimension D, Unit U, Unit... Us>
|
template<typename Child, fixed_string Symbol, Dimension D, Unit U, Unit... Us>
|
||||||
struct derived_unit<Child, Name, D, U, Us...>;
|
struct derived_unit<Child, Symbol, D, U, Us...>;
|
||||||
```
|
```
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -554,8 +554,8 @@ struct derived_dimension : downcast_helper<Child, detail::make_dimension_t<Es...
|
|||||||
```
|
```
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Child, fixed_string Name, Dimension D>
|
template<typename Child, fixed_string Symbol, Dimension D>
|
||||||
struct derived_unit<Child, Name, D, R> : downcast_helper<Child, unit<D, ratio<1>>> {};
|
struct derived_unit<Child, Symbol, D, R> : downcast_helper<Child, unit<D, ratio<1>>> {};
|
||||||
```
|
```
|
||||||
|
|
||||||
With such CRTP types the only thing the user has to do to register a new type to the downcasting
|
With such CRTP types the only thing the user has to do to register a new type to the downcasting
|
||||||
|
@@ -119,50 +119,50 @@ namespace units {
|
|||||||
// TODO gcc:92101
|
// TODO gcc:92101
|
||||||
// Gated by the following gcc bug
|
// Gated by the following gcc bug
|
||||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92101
|
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92101
|
||||||
// template<typename Child, fixed_string Name, typename...>
|
// template<typename Child, fixed_string Symbol, typename...>
|
||||||
// struct derived_unit;
|
// struct derived_unit;
|
||||||
|
|
||||||
// template<typename Child, fixed_string Name, Dimension D>
|
// template<typename Child, fixed_string Symbol, Dimension D>
|
||||||
// struct derived_unit<Child, Name, D> : downcast_helper<Child, unit<D, ratio<1>>> {
|
// struct derived_unit<Child, Symbol, D> : downcast_helper<Child, unit<D, ratio<1>>> {
|
||||||
// static constexpr auto name = Name;
|
// static constexpr auto symbol = Symbol;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// template<typename Child, fixed_string Name, Dimension D, Ratio R>
|
// template<typename Child, fixed_string Symbol, Dimension D, Ratio R>
|
||||||
// struct derived_unit<Child, Name, D, R> : downcast_helper<Child, unit<D, R>> {
|
// struct derived_unit<Child, Symbol, D, R> : downcast_helper<Child, unit<D, R>> {
|
||||||
// static constexpr auto name = Name;
|
// static constexpr auto symbol = Symbol;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// template<typename Child, fixed_string Name, Unit U>
|
// template<typename Child, fixed_string Symbol, Unit U>
|
||||||
// struct derived_unit<Child, Name, U> : downcast_helper<Child, U> {
|
// struct derived_unit<Child, Symbol, U> : downcast_helper<Child, U> {
|
||||||
// static constexpr auto name = Name;
|
// static constexpr auto symbol = Symbol;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// template<typename Child, fixed_string Name, Dimension D, Unit U, Unit... Us>
|
// template<typename Child, fixed_string Symbol, Dimension D, Unit U, Unit... Us>
|
||||||
// struct derived_unit<Child, Name, D, U, Us...> : downcast_helper<Child, detail::make_derived_unit<D, U, Us...>> {
|
// struct derived_unit<Child, Symbol, D, U, Us...> : downcast_helper<Child, detail::make_derived_unit<D, U, Us...>> {
|
||||||
// static constexpr auto name = Name;
|
// static constexpr auto symbol = Symbol;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
template<typename Child, typename Name, typename...>
|
template<typename Child, typename Symbol, typename...>
|
||||||
struct derived_unit;
|
struct derived_unit;
|
||||||
|
|
||||||
template<typename Child, typename Name, Dimension D>
|
template<typename Child, typename Symbol, Dimension D>
|
||||||
struct derived_unit<Child, Name, D> : downcast_helper<Child, unit<D, ratio<1>>> {
|
struct derived_unit<Child, Symbol, D> : downcast_helper<Child, unit<D, ratio<1>>> {
|
||||||
static constexpr auto name = Name::c_str();
|
static constexpr auto symbol = Symbol::c_str();
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Child, typename Name, Dimension D, Ratio R>
|
template<typename Child, typename Symbol, Dimension D, Ratio R>
|
||||||
struct derived_unit<Child, Name, D, R> : downcast_helper<Child, unit<D, R>> {
|
struct derived_unit<Child, Symbol, D, R> : downcast_helper<Child, unit<D, R>> {
|
||||||
static constexpr auto name = Name::c_str();
|
static constexpr auto symbol = Symbol::c_str();
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Child, typename Name, Unit U>
|
template<typename Child, typename Symbol, Unit U>
|
||||||
struct derived_unit<Child, Name, U> : downcast_helper<Child, U> {
|
struct derived_unit<Child, Symbol, U> : downcast_helper<Child, U> {
|
||||||
static constexpr auto name = Name::c_str();
|
static constexpr auto symbol = Symbol::c_str();
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Child, typename Name, Dimension D, Unit U, Unit... Us>
|
template<typename Child, typename Symbol, Dimension D, Unit U, Unit... Us>
|
||||||
struct derived_unit<Child, Name, D, U, Us...> : downcast_helper<Child, detail::make_derived_unit<D, U, Us...>> {
|
struct derived_unit<Child, Symbol, D, U, Us...> : downcast_helper<Child, detail::make_derived_unit<D, U, Us...>> {
|
||||||
static constexpr auto name = Name::c_str();
|
static constexpr auto symbol = Symbol::c_str();
|
||||||
};
|
};
|
||||||
|
|
||||||
// SI prefixes
|
// SI prefixes
|
||||||
|
@@ -30,7 +30,7 @@ namespace units {
|
|||||||
template<typename Unit, typename Rep>
|
template<typename Unit, typename Rep>
|
||||||
std::ostream& operator<<(std::ostream& os, const quantity<Unit, Rep>& value)
|
std::ostream& operator<<(std::ostream& os, const quantity<Unit, Rep>& value)
|
||||||
{
|
{
|
||||||
return os << value.count() << Unit::name;
|
return os << value.count() << Unit::symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user