pointer.hpp 865 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. namespace nall {
  3. template<typename T>
  4. struct pointer {
  5. explicit operator bool() const { return value; }
  6. pointer() = default;
  7. pointer(T* source) { value = source; }
  8. pointer(const pointer& source) { value = source.value; }
  9. auto& operator=(T* source) { value = source; return *this; }
  10. auto& operator=(const pointer& source) { value = source.value; return *this; }
  11. auto operator()() -> T* { return value; }
  12. auto operator()() const -> const T* { return value; }
  13. auto operator->() -> T* { return value; }
  14. auto operator->() const -> const T* { return value; }
  15. auto operator*() -> T& { return *value; }
  16. auto operator*() const -> const T& { return *value; }
  17. auto reset() -> void { value = nullptr; }
  18. auto data() -> T* { return value; }
  19. auto data() const -> const T* { return value; }
  20. private:
  21. T* value = nullptr;
  22. };
  23. }