diff options
author | 2019-11-02 23:39:24 +0100 | |
---|---|---|
committer | 2019-11-02 23:39:24 +0100 | |
commit | db0dbeaea506a44c3acfaf64b0160c3cb397edb9 (patch) | |
tree | 3ca51390ead7b80fdb96843fcc812cf173f97762 /src/lib/netlist/plib/putil.h | |
parent | eccede6c05ec366d875c6fcf0b4d16db4d20a077 (diff) |
netlist: improve readability. (nw)
Renamed cast member of the constants struct to magic to clearly identify
magic numbers.
Introduced nlconst struct inheriting from plib::constants<nl_fptype> to
make code better understandable.
Diffstat (limited to 'src/lib/netlist/plib/putil.h')
-rw-r--r-- | src/lib/netlist/plib/putil.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/netlist/plib/putil.h b/src/lib/netlist/plib/putil.h index 1fa3971f8a6..e72eccfe01f 100644 --- a/src/lib/netlist/plib/putil.h +++ b/src/lib/netlist/plib/putil.h @@ -257,9 +257,15 @@ namespace plib * \brief Intrinsic carrier concentration in 1/m^3 of Silicon */ static inline constexpr T NiSi() noexcept { return static_cast<T>(1.45e16); } - + /*! + * \brief clearly identify magic numbers in code + * + * Magic numbers should be avoided. The magic member at least clearly + * identifies them and makes it easier to convert them to named constants + * later. + */ template <typename V> - static inline constexpr const T cast(V &&v) noexcept { return static_cast<T>(v); } + static inline constexpr const T magic(V &&v) noexcept { return static_cast<T>(v); } }; /*! typesafe reciprocal function |