From 5a6f8cac09770d315fe4a3258fa6116e65750f24 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 29 Jan 2023 21:33:34 -0500 Subject: first pass compile time optimization --- src/util.hpp | 59 ++++++++++++++++------------------------------------------- 1 file changed, 16 insertions(+), 43 deletions(-) (limited to 'src/util.hpp') diff --git a/src/util.hpp b/src/util.hpp index 4b14a7e..fc9568b 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -13,17 +13,26 @@ #include #include #include -#include -#define NOOP_CALLBACK [](...) {} +#include -namespace util { -template -struct is_optional : ::std::false_type {}; +namespace Glib { +class ustring; +} -template -struct is_optional<::std::optional> : ::std::true_type {}; +namespace Gdk { +class RGBA; +} + +namespace Gtk { +class Widget; +class Menu; +class ListBox; +} // namespace Gtk +#define NOOP_CALLBACK [](...) {} + +namespace util { bool IsFolder(std::string_view path); bool IsFile(std::string_view path); @@ -44,42 +53,6 @@ std::string HumanReadableBytes(uint64_t bytes); std::string FormatISO8601(const std::string &in, int extra_offset = 0, const std::string &fmt = "%x %X"); void AddPointerCursor(Gtk::Widget &widget); -template -struct Bitwise { - static const bool enable = false; -}; - -template -typename std::enable_if::enable, T>::type operator|(T a, T b) { - using x = typename std::underlying_type::type; - return static_cast(static_cast(a) | static_cast(b)); -} - -template -typename std::enable_if::enable, T>::type operator|=(T &a, T b) { - using x = typename std::underlying_type::type; - a = static_cast(static_cast(a) | static_cast(b)); - return a; -} - -template -typename std::enable_if::enable, T>::type operator&(T a, T b) { - using x = typename std::underlying_type::type; - return static_cast(static_cast(a) & static_cast(b)); -} - -template -typename std::enable_if::enable, T>::type operator&=(T &a, T b) { - using x = typename std::underlying_type::type; - a = static_cast(static_cast(a) & static_cast(b)); - return a; -} - -template -typename std::enable_if::enable, T>::type operator~(T a) { - return static_cast(~static_cast::type>(a)); -} - template inline void AlphabeticalSort(T start, T end, std::function::value_type &)> get_string) { std::sort(start, end, [&](const auto &a, const auto &b) -> bool { -- cgit v1.2.3