functor: add the identity functor

This commit is contained in:
Danny Robson 2019-09-09 07:37:37 +10:00
parent 077ecf5682
commit 39759805ac

View File

@ -13,6 +13,20 @@
namespace cruft::functor { namespace cruft::functor {
/// Returns the supplied argument unchanged
///
/// CXX#20: Revisit when C++20 support is available. This is just a
/// trivial implementation of std::identity.
struct identity {
template <typename ValueT>
ValueT&&
operator() (ValueT &&val)
{
return std::forward<ValueT> (val);
}
};
/// A trivial functor that wraps std::begin without any static typing. /// A trivial functor that wraps std::begin without any static typing.
struct begin { struct begin {
template <typename valuet> template <typename valuet>