summaryrefslogtreecommitdiff
path: root/util.hpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-09-24 02:15:25 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-09-24 02:15:25 -0400
commit83417819186394e8d840167841103211ebe5fe33 (patch)
tree5dce1e411716d5be161d2e9795a99460b80e6c8c /util.hpp
parentdbe9dc3c64555f1aaaed1755d37e6f8b450a54f6 (diff)
downloadabaddon-portaudio-83417819186394e8d840167841103211ebe5fe33.tar.gz
abaddon-portaudio-83417819186394e8d840167841103211ebe5fe33.zip
basic permission handling + use for edit/delete
Diffstat (limited to 'util.hpp')
-rw-r--r--util.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/util.hpp b/util.hpp
index 5caa49b..925ace9 100644
--- a/util.hpp
+++ b/util.hpp
@@ -10,6 +10,42 @@
#include <iomanip>
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<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);