From 5e3a2492c7bb73daa4e27398daaf490d09980ff3 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 Jun 2022 17:41:59 -0400 Subject: Base system viewer with data loaded from csv files --- include/util.hpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/util.hpp (limited to 'include/util.hpp') diff --git a/include/util.hpp b/include/util.hpp new file mode 100644 index 0000000..3c795d1 --- /dev/null +++ b/include/util.hpp @@ -0,0 +1,45 @@ +#include +#ifndef UTIL_HPP +#define UTIL_HPP 1 + +#include +#include + +#if UNICODE == 1 +using screenchr = wchar_t; +#else +using screenchr = char; +#endif + +/*Shamelessly stolen from stackoverflow + * https://stackoverflow.com/questions/52303316/get-index-by-type-in-stdvariant + * by Barry*/ +template struct tag { }; +template +struct get_index; +template +struct get_index> + : std::integral_constant...>(tag()).index()> +{ }; + +template +struct is_variant : std::false_type {}; +template +struct is_variant> + : std::disjunction...> {}; +template +constexpr bool is_variant_v = is_variant::value; + +template +struct cxpow { static constexpr T value = (T)base * cxpow::value; }; +template +struct cxpow { static constexpr T value = 1; }; +template +constexpr T cxpow_v = cxpow::value; + +template +struct cxrt { static constexpr T value = (T)base / cxpow::value; }; +template +constexpr T cxrt_v = cxrt::value; + +#endif -- cgit v1.2.1