From f2faf7acf4445fef2a149ebbdecb569a2d119d94 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 2 Jul 2018 08:20:47 +0200 Subject: nothing important --- compat/check-visible.cpp | 2 +- compat/correlation-calibrator.cpp | 2 +- compat/macros.hpp | 7 ++++++- compat/meta.hpp | 35 ++++++++++++++++------------------- compat/timer.cpp | 3 +-- 5 files changed, 25 insertions(+), 24 deletions(-) (limited to 'compat') 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 +#include #include 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 + //#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 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 struct tuple; @@ -47,27 +45,26 @@ namespace detail { { using type = to; }; -} // ns detail - - -template -using reverse = typename detail::reverse_, detail::tuple<>>::type; +} // ns meta::detail -// the to/from order is awkward but mimics function composition -template class to, typename from> -using lift = typename detail::lift_::type; +namespace meta { + template + using reverse = typename detail::reverse_, detail::tuple<>>::type; -template -using first = x; + // the to/from order is awkward but mimics function composition + template class to, typename from> + using lift = typename detail::lift_::type; -template -using rest = detail::tuple; + template + using first = x; -template -using butlast = reverse>>; + template + using rest = detail::tuple; -template -using last = lift>; + template + using butlast = reverse>>; + template + using last = lift>; } // 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 - #include "timer.hpp" +#include #include using time_type = Timer::time_type; -- cgit v1.2.3