functor: add begin
and end
convenience transforms
This commit is contained in:
parent
b87517759d
commit
9982ea2bb7
26
functor.hpp
26
functor.hpp
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user