bsnes-libretro/nall/pointer.hpp
Tim Allen ec9729a9e1 Update to v106r36 release.
byuu says:

Changelog:

  - nall: renamed array to adaptive_array; marked it as deprecated
  - nall: created new array class; which is properly static (ala
    std::array) with optional bounds-checking
  - sfc/ppu-fast: converted unmanaged arrays to use nall/array (no speed
    penalty)
  - bsnes: rewrote the cheat code editor to a new design
  - nall: string class can stringify pointer types directly now, so
    pointer() was removed
  - nall: added array_view and pointer types (still unsure if/how I'll
    use pointer)
2018-06-04 12:44:57 +10:00

35 lines
865 B
C++

#pragma once
namespace nall {
template<typename T>
struct pointer {
explicit operator bool() const { return value; }
pointer() = default;
pointer(T* source) { value = source; }
pointer(const pointer& source) { value = source.value; }
auto& operator=(T* source) { value = source; return *this; }
auto& operator=(const pointer& source) { value = source.value; return *this; }
auto operator()() -> T* { return value; }
auto operator()() const -> const T* { return value; }
auto operator->() -> T* { return value; }
auto operator->() const -> const T* { return value; }
auto operator*() -> T& { return *value; }
auto operator*() const -> const T& { return *value; }
auto reset() -> void { value = nullptr; }
auto data() -> T* { return value; }
auto data() const -> const T* { return value; }
private:
T* value = nullptr;
};
}