forked from boostorg/functional
Add identity function object
This commit is contained in:
1 parent
09d7a311a5
commit
0be868143d
6 files changed
+241
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Boost Function Object Adapter Library</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Identity</h1>
|
||||
<p>The header <a href="../../boost/functional/identity.hpp">
|
||||
<boost/functional/identity.hpp></a> provides the function object
|
||||
<code>boost::identity</code> whose <code>operator()</code> returns its
|
||||
argument. It is an implementation of C++20's <code>std::identity</code>
|
||||
that supports C++03 and above.</p>
|
||||
<h2>Example</h2>
|
||||
<p>It is commonly used as the default projection in constrained algorithms.</p>
|
||||
<pre>
|
||||
<code>template<class Range, class Projection = boost::identity>
|
||||
void print(Range&& range, Projection projection = {});</code>
|
||||
</pre>
|
||||
<h2>Reference</h2>
|
||||
<pre>
|
||||
<code>namespace boost {
|
||||
|
||||
struct identity {
|
||||
using is_transparent = <em>unspecified</em>;
|
||||
|
||||
template<class T>
|
||||
T&& operator()(T&& value) const noexcept;
|
||||
};
|
||||
|
||||
} // boost</code>
|
||||
</pre>
|
||||
<h3>Operators</h3>
|
||||
<dl>
|
||||
<dt><code>template<class T>
|
||||
T&& operator()(T&& value) const noexcept;</code></dt>
|
||||
<dd>Returns <code>std::forward<T>(value)</code></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<p>Copyright 2021 Glen Joseph Fernandes.</p>
|
||||
<p>Distributed under the
|
||||
<a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License,
|
||||
Version 1.0</a>.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user