summaryrefslogtreecommitdiff
path: root/src/util.hpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-01-29 21:33:34 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2023-01-29 21:33:34 -0500
commit5a6f8cac09770d315fe4a3258fa6116e65750f24 (patch)
treed74c5407e4ba9b11700666ce1eed0c94984ae14a /src/util.hpp
parentff47134dc64ac2f0fa7bfee64313b2522709b9b9 (diff)
downloadabaddon-portaudio-5a6f8cac09770d315fe4a3258fa6116e65750f24.tar.gz
abaddon-portaudio-5a6f8cac09770d315fe4a3258fa6116e65750f24.zip
first pass compile time optimization
Diffstat (limited to 'src/util.hpp')
-rw-r--r--src/util.hpp59
1 files changed, 16 insertions, 43 deletions
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 <condition_variable>
#include <optional>
#include <type_traits>
-#include <gtkmm.h>
-#define NOOP_CALLBACK [](...) {}
+#include <sigc++/slot.h>
-namespace util {
-template<typename T>
-struct is_optional : ::std::false_type {};
+namespace Glib {
+class ustring;
+}
-template<typename T>
-struct is_optional<::std::optional<T>> : ::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);
@@ -45,42 +54,6 @@ std::string FormatISO8601(const std::string &in, int extra_offset = 0, const std
void AddPointerCursor(Gtk::Widget &widget);
template<typename T>
-struct Bitwise {
- static const bool enable = false;
-};
-
-template<typename T>
-typename std::enable_if<Bitwise<T>::enable, T>::type operator|(T a, T b) {
- using x = typename std::underlying_type<T>::type;
- return static_cast<T>(static_cast<x>(a) | static_cast<x>(b));
-}
-
-template<typename T>
-typename std::enable_if<Bitwise<T>::enable, T>::type operator|=(T &a, T b) {
- using x = typename std::underlying_type<T>::type;
- a = static_cast<T>(static_cast<x>(a) | static_cast<x>(b));
- return a;
-}
-
-template<typename T>
-typename std::enable_if<Bitwise<T>::enable, T>::type operator&(T a, T b) {
- using x = typename std::underlying_type<T>::type;
- return static_cast<T>(static_cast<x>(a) & static_cast<x>(b));
-}
-
-template<typename T>
-typename std::enable_if<Bitwise<T>::enable, T>::type operator&=(T &a, T b) {
- using x = typename std::underlying_type<T>::type;
- a = static_cast<T>(static_cast<x>(a) & static_cast<x>(b));
- return a;
-}
-
-template<typename T>
-typename std::enable_if<Bitwise<T>::enable, T>::type operator~(T a) {
- return static_cast<T>(~static_cast<typename std::underlying_type<T>::type>(a));
-}
-
-template<typename T>
inline void AlphabeticalSort(T start, T end, std::function<std::string(const typename std::iterator_traits<T>::value_type &)> get_string) {
std::sort(start, end, [&](const auto &a, const auto &b) -> bool {
const std::string &s1 = get_string(a);