memory 747 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef __GBLIBCPP_MEMORY__
  2. #define __GBLIBCPP_MEMORY__
  3. #include <type_traits>
  4. #include <utility>
  5. namespace std {
  6. template <typename T>
  7. constexpr T* addressof(T& arg) noexcept
  8. {
  9. return __builtin_addressof(arg);
  10. }
  11. // template <typename T>
  12. // constexpr enable_if_t<is_function_v<remove_reference_t<T>>, T*>
  13. // addressof(T& arg) noexcept
  14. // {
  15. // return &arg;
  16. // }
  17. // template <typename T>
  18. // constexpr enable_if_t<!is_function_v<remove_reference_t<T>>, T*>
  19. // addressof(T& arg) noexcept
  20. // {
  21. // return reinterpret_cast<T*>(
  22. // &const_cast<char&>(
  23. // reinterpret_cast<const volatile char&>(arg)
  24. // )
  25. // );
  26. // }
  27. template <typename T>
  28. const T* addressof(const T&&) = delete;
  29. } // namespace std
  30. #endif