functor: add the identity functor
This commit is contained in:
parent
077ecf5682
commit
39759805ac
14
functor.hpp
14
functor.hpp
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user