From 9982ea2bb7a254a9c95a9584859469cae7d261bd Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 5 Feb 2019 11:58:31 +1100 Subject: [PATCH] functor: add `begin` and `end` convenience transforms --- functor.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/functor.hpp b/functor.hpp index fd0013bc..8ad31dfb 100644 --- a/functor.hpp +++ b/functor.hpp @@ -12,6 +12,32 @@ namespace cruft::functor { + /// A trivial functor that wraps std::begin without any static typing. + struct begin { + template + decltype (auto) + operator() (valuet &&value) noexcept (noexcept (std::begin (value))) + { + return std::begin ( + std::forward (value) + ); + } + }; + + + /// A trivial functor that wraps std::end without any static typing. + struct end { + template + decltype (auto) + operator() (valuet &&value) noexcept (noexcept (std::end (value))) + { + return std::end ( + std::forward (value) + ); + } + }; + + /////////////////////////////////////////////////////////////////////////// /// returns the value provided at construction time regardless of the /// arguments supplied in the call operator.