• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_FUNCTIONAL_IDENTITY_H_
6 #define BASE_FUNCTIONAL_IDENTITY_H_
7 
8 #include <utility>
9 
10 namespace base {
11 
12 // Implementation of C++20's std::identity.
13 //
14 // Reference:
15 // - https://en.cppreference.com/w/cpp/utility/functional/identity
16 // - https://wg21.link/func.identity
17 struct identity {
18   template <typename T>
operatoridentity19   constexpr T&& operator()(T&& t) const noexcept {
20     return std::forward<T>(t);
21   }
22 
23   using is_transparent = void;
24 };
25 
26 }  // namespace base
27 
28 #endif  // BASE_FUNCTIONAL_IDENTITY_H_
29