From f8b3c341164fdb336eea43a820af814cff5b6485 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 7 May 2017 11:13:47 +0200 Subject: compat/functional: add generic value-constant type --- compat/functional.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compat/functional.hpp b/compat/functional.hpp index e7229d6e..141bbef7 100644 --- a/compat/functional.hpp +++ b/compat/functional.hpp @@ -38,6 +38,19 @@ inline void maybe_reserve_space(seq_& seq, unsigned sz) } // ns +template +struct constant final +{ + using type = t; + constexpr type operator()() const noexcept + { + return value_; + } + static constexpr type value = value_; + + constant() = delete; +}; + template auto map(F&& fun, const seq_& seq) { -- cgit v1.2.3