1234567891011121314151617181920212223242526272829303132333435363738 |
- #ifndef __GBLIBCPP_MEMORY__
- #define __GBLIBCPP_MEMORY__
- #include <type_traits>
- #include <utility>
- namespace std {
- template <typename T>
- constexpr T* addressof(T& arg) noexcept
- {
- return __builtin_addressof(arg);
- }
- // 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>
- const T* addressof(const T&&) = delete;
- } // namespace std
- #endif
|