1234567891011121314151617181920212223242526272829303132 |
- #ifndef __GBLIBCPP_MEMORY__
- #define __GBLIBCPP_MEMORY__
- #include <type_traits>
- #include <utility>
- namespace std {
- template <typename T>
- constexpr enable_if_t<is_function_v<remove_reference_t<T>>, T*>
- addressof(T& arg) noexcept
- {
- return &arg;
- }
- template <typename T>
- constexpr enable_if_t<!is_function_v<remove_reference_t<T>>, T*>
- addressof(T& arg) noexcept
- {
- return reinterpret_cast<T*>(
- &const_cast<char&>(
- reinterpret_cast<const volatile char&>(arg)
- )
- );
- }
- template <typename T>
- T* addressof(const T&&) = delete;
- } // namespace std
- #endif
|