From 31afd9dcfdf6280ef87dfb7920b1846eb810e08d Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 28 Aug 2017 12:59:06 +1000 Subject: [PATCH] coord/ops: initial stubs for coord::apply --- coord/ops.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/coord/ops.hpp b/coord/ops.hpp index d1c37654..3ee732e4 100644 --- a/coord/ops.hpp +++ b/coord/ops.hpp @@ -335,6 +335,47 @@ namespace util { #undef UNARY_OP + /////////////////////////////////////////////////////////////////////////// + namespace detail { + template < + typename RetT, + typename ArgT, + typename FuncT, + std::size_t ...Indices, + typename = std::enable_if_t< + is_coord_v && is_coord_v, void + > + > + constexpr auto + apply (const std::index_sequence, + FuncT &&func, + const ArgT &a, + const ArgT &b) + { + return RetT { + std::invoke (func, a[Indices], b[Indices])... + }; + } + } + + + template < + typename RetT, + std::size_t S, + typename T, + template class ArgT, + typename FuncT, + typename = std::enable_if_t< + is_coord_v && is_coord_v, void + >, + typename Indices = std::make_index_sequence + > + constexpr auto + apply (FuncT &&func, const ArgT &a, const ArgT &b) + { + return detail::apply (Indices{}, std::forward (func), a, b); + } + /////////////////////////////////////////////////////////////////////////// // logic operators