![]() |
Shamrock 2025.10.0
Astrophysical Code
|
Name tables mapping long and short names to units, with constexpr lookup. More...
#include "shamunits/Unit.hpp"#include <string_view>#include <span>#include <stdexcept>#include <string>Go to the source code of this file.
Classes | |
| struct | shamunits::NamedUnit |
| One registry entry: a unit and the two names it can be looked up by. More... | |
Namespaces | |
| namespace | shamunits |
| namespace containing the units library | |
Functions | |
| constexpr const NamedUnit * | shamunits::details::find_named (std::span< const NamedUnit > registry, std::string_view name) noexcept |
| Entry whose long or short name is name, or nullptr. | |
| Unit | shamunits::details::unit_from_name (std::span< const NamedUnit > registry, std::string_view name, std::string_view kind="unit") |
| Unit named name in registry; throws std::invalid_argument when unknown. | |
| constexpr bool | shamunits::details::names_are_valid (std::span< const NamedUnit > registry) noexcept |
| True when no name is empty and no name appears twice, long and short names together. | |
Name tables mapping long and short names to units, with constexpr lookup.
Each category (units, prefixes, constants) owns one registry, a constexpr array of NamedUnit next to its table. Names only need to be unique within one registry, so "m" can be both metre (units) and milli (prefixes). Host-only: unlike Unit.hpp this uses the standard library and exceptions.
Definition in file registry.hpp.
|
constexprnoexcept |
Entry whose long or short name is name, or nullptr.
Definition at line 47 of file registry.hpp.
|
constexprnoexcept |
True when no name is empty and no name appears twice, long and short names together.
Definition at line 70 of file registry.hpp.
|
inline |
Unit named name in registry; throws std::invalid_argument when unknown.
Definition at line 58 of file registry.hpp.