mirror of
https://github.com/boostorg/hof.git
synced 2026-01-31 20:22:11 +00:00
54 lines
1.1 KiB
C++
54 lines
1.1 KiB
C++
/*=============================================================================
|
|
Copyright (c) 2012 Paul Fultz II
|
|
identity.h
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
==============================================================================*/
|
|
|
|
#ifndef FIT_GUARD_FUNCTION_IDENTITY_H
|
|
#define FIT_GUARD_FUNCTION_IDENTITY_H
|
|
|
|
/// identity
|
|
/// ========
|
|
///
|
|
/// Description
|
|
/// -----------
|
|
///
|
|
/// The `identity` function is an unary function object that returns whats given to it.
|
|
///
|
|
/// Synopsis
|
|
/// --------
|
|
///
|
|
/// struct
|
|
/// {
|
|
/// template<class T>
|
|
/// constexpr T operator()(T&& x) const
|
|
/// {
|
|
/// return fit::forward<T>(x);
|
|
/// }
|
|
/// } identity;
|
|
///
|
|
|
|
#include <utility>
|
|
#include <fit/detail/forward.h>
|
|
#include <fit/detail/static_const_var.h>
|
|
|
|
namespace fit { namespace detail {
|
|
|
|
struct identity_base
|
|
{
|
|
template<class T>
|
|
constexpr T operator()(T&& x) const
|
|
{
|
|
return fit::forward<T>(x);
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
FIT_DECLARE_STATIC_VAR(identity, detail::identity_base);
|
|
|
|
}
|
|
|
|
#endif
|