Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Identity

The header <boost/functional/identity.hpp> provides the function object boost::identity whose operator() returns its argument. It is an implementation of C++20's std::identity that supports C++03 and above.

Example

It is commonly used as the default projection in constrained algorithms.

template<class Range, class Projection = boost::identity>
void print(Range&& range, Projection projection = {});

Reference

namespace boost {

struct identity {
    using is_transparent = unspecified;

    template<class T>
    T&& operator()(T&& value) const noexcept;
};

} // boost

Operators

template<class T> T&& operator()(T&& value) const noexcept;
Returns std::forward<T>(value)

Copyright 2021 Glen Joseph Fernandes.

Distributed under the Boost Software License, Version 1.0.