aboutsummaryrefslogtreecommitdiff
path: root/c/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/common.h')
-rw-r--r--c/common.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/c/common.h b/c/common.h
index 0343914..4b42f45 100644
--- a/c/common.h
+++ b/c/common.h
@@ -74,6 +74,19 @@ inline T prefer(const T x)
return x;
}
+/* Conditionally select between ANSI and wide string literal. */
+#define AWTEXT(t, s) cond_text<t>(s, L"" s)
+template <typename T> constexpr const T* cond_text(const char*, const wchar_t*);
+template <> constexpr const char* cond_text<char>(const char* sz, const wchar_t*) { return sz; }
+template <> constexpr const wchar_t* cond_text<wchar_t>(const char*, const wchar_t* wsz) { return wsz; }
+
+/* Conditionally select between ANSI and wide Windows API function. */
+#define AWFUN(t, f) cond_fun<t, f##A, f##W>()
+template <typename T, auto F, auto G>
+constexpr std::enable_if_t<std::is_same_v<T, char>, decltype(F)> cond_fun() { return F; }
+template <typename T, auto F, auto G>
+constexpr std::enable_if_t<std::is_same_v<T, wchar_t>, decltype(G)> cond_fun() { return G; }
+
/* Return integer scaled for current DPI. */
inline int Dpi(const int i)
{