functor: add begin and end convenience transforms

This commit is contained in:
Danny Robson 2019-02-05 11:58:31 +11:00
parent b87517759d
commit 9982ea2bb7

View File

@ -12,6 +12,32 @@
namespace cruft::functor {
/// A trivial functor that wraps std::begin without any static typing.
struct begin {
template <typename valuet>
decltype (auto)
operator() (valuet &&value) noexcept (noexcept (std::begin (value)))
{
return std::begin (
std::forward<valuet> (value)
);
}
};
/// A trivial functor that wraps std::end without any static typing.
struct end {
template <typename valuet>
decltype (auto)
operator() (valuet &&value) noexcept (noexcept (std::end (value)))
{
return std::end (
std::forward<valuet> (value)
);
}
};
///////////////////////////////////////////////////////////////////////////
/// returns the value provided at construction time regardless of the
/// arguments supplied in the call operator.