[M94 Dev][Tizen] Fix for errors for generating ninja files
[platform/framework/web/chromium-efl.git] / base / cxx20_to_address.h
1 // Copyright 2021 The Chromium Authors. All rights reserved.
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_CXX20_TO_ADDRESS_H_
6 #define BASE_CXX20_TO_ADDRESS_H_
7
8 #include <type_traits>
9
10 namespace base {
11
12 // Simplified C++14 implementation of C++20's std::to_address.
13 // Note: This does not consider specializations of pointer_traits<>::to_address,
14 // since that member function may only be present in C++20 and later.
15 //
16 // Reference: https://wg21.link/pointer.conversion#lib:to_address
17 template <typename T>
18 constexpr T* to_address(T* p) noexcept {
19   static_assert(!std::is_function<T>::value,
20                 "Error: T must not be a function type.");
21   return p;
22 }
23
24 template <typename Ptr>
25 constexpr auto to_address(const Ptr& p) noexcept {
26   return to_address(p.operator->());
27 }
28
29 }  // namespace base
30
31 #endif  // BASE_CXX20_TO_ADDRESS_H_