units
Use physical dimensions at compile-time or run-time.
dim-base-off.hpp
Go to the documentation of this file.
1 /// @file vnix/units/dim-base-off.hpp
2 /// @brief Definition of dim_base_off.
3 /// @copyright 2019 Thomas E. Vaughan; all rights reserved.
4 /// @license BSD three-clause; see LICENSE.
5 
6 // THIS FILE IS GENERATED FROM 'dim-base-off.hpp.erb'.
7 
8 #ifndef VNIX_UNITS_DIM_BASE_OFF_HPP
9 #define VNIX_UNITS_DIM_BASE_OFF_HPP
10 
11 #include <array>
12 
13 namespace vnix {
14 namespace units {
15 
16 
17 /// Enumeration of offsets, one for each base dimension in class dim.
18 template <typename T> struct basic_dim_base_off {
19  /// C-style enumeration of offsets.
20  enum off : T {
21  length, ///< Offset of rational exponent for length.
22  mass, ///< Offset of rational exponent for mass.
23  time, ///< Offset of rational exponent for time.
24  charge, ///< Offset of rational exponent for charge.
25  temperature, ///< Offset of rational exponent for temperature.
26  };
27 
28  off offset; ///< Allow declaration of meaningful instance of dim_base_off.
29 
30  /// Automatically convert instance to type of enum.
31  constexpr operator off() const { return offset; }
32 
33  /// Allow construction of constant-expression instance.
34  constexpr basic_dim_base_off(off os) : offset(os) {}
35 
36  /// Number of offsets.
37  constexpr static T num_offs = 5;
38 
39  /// Array of enumerated offsets for iterating.
40  constexpr static off const array[num_offs] = {
42 
43  /// Array of basis-dimension symbols, one for each offset.
44  constexpr static char const *const sym[num_offs] = {
45 "m","g","s","C","K",};
46 };
47 
48 template <typename T>
49 constexpr typename basic_dim_base_off<T>::off const
51 
52 template <typename T>
53 constexpr char const *const
55 
56 using dim_base_off = basic_dim_base_off<uint_fast8_t>;
57 
58 } // namespace units
59 } // namespace vnix
60 
61 #endif // ndef VNIX_UNITS_DIM_BASE_OFF_HPP
Enumeration of offsets, one for each base dimension in class dim.
constexpr operator off() const
Automatically convert instance to type of enum.
constexpr basic_dim_base_off(off os)
Allow construction of constant-expression instance.
off offset
Allow declaration of meaningful instance of dim_base_off.
Offset of rational exponent for charge.
Offset of rational exponent for temperature.
Offset of rational exponent for mass.
static constexpr T num_offs
Number of offsets.
static constexpr off const array[num_offs]
Array of enumerated offsets for iterating.
Offset of rational exponent for length.
Thomas E. Vaughan&#39;s public software.
Definition: rational.hpp:13
Offset of rational exponent for time.
Classes and functions supporting a model of physically dimensioned quantities.
static constexpr char const *const sym[num_offs]
Array of basis-dimension symbols, one for each offset.
off
C-style enumeration of offsets.