1 //===- llvm/ADT/Identity.h - Provide std::identity from C++20 ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides an implementation of std::identity from C++20.
10 //
11 // No library is required when using these functions.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_ADT_IDENTITY_H
16 #define LLVM_ADT_IDENTITY_H
17 
18 
19 namespace llvm {
20 
21 template <class Ty> struct identity {
22   using argument_type = Ty;
23 
24   Ty &operator()(Ty &self) const {
25     return self;
26   }
27   const Ty &operator()(const Ty &self) const {
28     return self;
29   }
30 };
31 
32 } // end namespace llvm
33 
34 #endif // LLVM_ADT_IDENTITY_H
35