diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-05-07 11:13:47 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-05-10 11:19:22 +0200 |
commit | f8b3c341164fdb336eea43a820af814cff5b6485 (patch) | |
tree | bbad8a224fd770179620e2bf68e82acfff8e3d99 /compat | |
parent | d561e59cacc4e22cb5fb87c3fee09c7c50c7dde2 (diff) |
compat/functional: add generic value-constant type
Diffstat (limited to 'compat')
-rw-r--r-- | compat/functional.hpp | 13 |
1 files changed, 13 insertions, 0 deletions
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<typename t, t value_> +struct constant final +{ + using type = t; + constexpr type operator()() const noexcept + { + return value_; + } + static constexpr type value = value_; + + constant() = delete; +}; + template<typename seq_, typename F> auto map(F&& fun, const seq_& seq) { |