diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/check-visible.cpp | 2 | ||||
-rw-r--r-- | compat/correlation-calibrator.cpp | 2 | ||||
-rw-r--r-- | compat/macros.hpp | 7 | ||||
-rw-r--r-- | compat/meta.hpp | 35 | ||||
-rw-r--r-- | compat/timer.cpp | 3 |
5 files changed, 25 insertions, 24 deletions
diff --git a/compat/check-visible.cpp b/compat/check-visible.cpp index 0f4c6e6d..0e154dd0 100644 --- a/compat/check-visible.cpp +++ b/compat/check-visible.cpp @@ -4,7 +4,7 @@ #include "timer.hpp" -#include <QMutexLocker> +#include <QMutex> #include <windows.h> diff --git a/compat/correlation-calibrator.cpp b/compat/correlation-calibrator.cpp index 70455818..b2e83153 100644 --- a/compat/correlation-calibrator.cpp +++ b/compat/correlation-calibrator.cpp @@ -61,7 +61,7 @@ bool correlation_calibrator::check_buckets(const vec6& data) if (pos[k] >= nbuckets[k]) { - once_only(qDebug() << "idx" << k + eval_once(qDebug() << "idx" << k << "bucket" << (int)pos[k] << "outside bounds" << nbuckets[k]); diff --git a/compat/macros.hpp b/compat/macros.hpp index 61c49975..0807df4c 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -44,8 +44,13 @@ // from now only C++ +#include <utility> + //#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false) -#define once_only(expr) ([&] { static decltype(auto) ret___1132 = (expr); return ret___1132; }()) +//#define once_only(expr) ([&] { static decltype(auto) ret___1132 = (expr); return (decltype(ret___1132) const&) ret___1132; }()) + +#define eval_once__2(expr, ident) (([&] { static bool ident = ((expr), true); (void)(ident); })) +#define eval_once(expr) eval_once__2(expr, PP_CAT(eval_once_init__, __COUNTER__)) #include <type_traits> diff --git a/compat/meta.hpp b/compat/meta.hpp index 8682fdc8..11c5ca0f 100644 --- a/compat/meta.hpp +++ b/compat/meta.hpp @@ -11,9 +11,7 @@ static_assert(sizeof...(x) == ~0ul); \ static_assert(sizeof...(x) == 0u) -namespace meta { - -namespace detail { +namespace meta::detail { template<typename... xs> struct tuple; @@ -47,27 +45,26 @@ namespace detail { { using type = to<xs...>; }; -} // ns detail - - -template<typename... xs> -using reverse = typename detail::reverse_<detail::tuple<xs...>, detail::tuple<>>::type; +} // ns meta::detail -// the to/from order is awkward but mimics function composition -template<template<typename...> class to, typename from> -using lift = typename detail::lift_<to, from>::type; +namespace meta { + template<typename... xs> + using reverse = typename detail::reverse_<detail::tuple<xs...>, detail::tuple<>>::type; -template<typename x, typename... xs> -using first = x; + // the to/from order is awkward but mimics function composition + template<template<typename...> class to, typename from> + using lift = typename detail::lift_<to, from>::type; -template<typename x, typename... xs> -using rest = detail::tuple<xs...>; + template<typename x, typename... xs> + using first = x; -template<typename... xs> -using butlast = reverse<rest<reverse<xs...>>>; + template<typename x, typename... xs> + using rest = detail::tuple<xs...>; -template<typename... xs> -using last = lift<first, reverse<xs...>>; + template<typename... xs> + using butlast = reverse<rest<reverse<xs...>>>; + template<typename... xs> + using last = lift<first, reverse<xs...>>; } // ns meta diff --git a/compat/timer.cpp b/compat/timer.cpp index dc9808b1..b9664263 100644 --- a/compat/timer.cpp +++ b/compat/timer.cpp @@ -6,9 +6,8 @@ * notice appear in all copies. */ -#include <cassert> - #include "timer.hpp" +#include <cassert> #include <cmath> using time_type = Timer::time_type; |