1 /* 2 * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 // This implementation is borrowed from Chromium. 12 13 #ifndef RTC_BASE_CONTAINERS_IDENTITY_H_ 14 #define RTC_BASE_CONTAINERS_IDENTITY_H_ 15 16 #include <utility> 17 18 namespace webrtc { 19 20 // Implementation of C++20's std::identity. 21 // 22 // Reference: 23 // - https://en.cppreference.com/w/cpp/utility/functional/identity 24 // - https://wg21.link/func.identity 25 struct identity { 26 template <typename T> operatoridentity27 constexpr T&& operator()(T&& t) const noexcept { 28 return std::forward<T>(t); 29 } 30 31 using is_transparent = void; 32 }; 33 34 } // namespace webrtc 35 36 #endif // RTC_BASE_CONTAINERS_IDENTITY_H_ 37