aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/stllike/identity.h
blob: ccc49b96a950ae9e7b432a9de701c06c7e9a4b28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <utility>

namespace vespalib {

// Functor which returns its argument unchanged.
// Functionally identical to C++20's std::identity
// TODO remove and replace with std::identity once it is available.
struct Identity {
    template <typename T>
    constexpr T&& operator()(T&& v) const noexcept {
        return std::forward<T>(v);
    }
};

}