}
constexpr phys_ptr<T>& operator++() {
- phys_addr += sizeof(T);
+ return *this += 1;
}
- constexpr phys_ptr<T>& operator++(int) {
+ constexpr phys_ptr<T> operator++(int) {
const auto old = *this;
operator++();
return old;
}
constexpr phys_ptr<T>& operator--() {
- phys_addr -= sizeof(T);
+ return *this -= 1;
}
- constexpr phys_ptr<T>& operator--(int) {
+ constexpr phys_ptr<T> operator--(int) {
const auto old = *this;
operator--();
return old;
}
constexpr phys_ptr<T>& operator+=(std::ptrdiff_t offset) {
- phys_addr += offset * sizeof(T);
- return *this;
+ return *this = *this + offset;
}
constexpr phys_ptr<T>& operator-=(std::ptrdiff_t offset) {
- phys_addr -= offset * sizeof(T);
- return *this;
+ return *this = *this - offset;
}
- friend constexpr auto operator<=>(phys_ptr<T> a, phys_ptr<T> b) { return a.phys_addr <=> b.phys_addr; }
- friend constexpr auto operator== (phys_ptr<T> a, phys_ptr<T> b) { return a.phys_addr == b.phys_addr; }
-
friend constexpr phys_ptr<T> operator+(phys_ptr<T> ptr, std::ptrdiff_t offset) {
return phys_ptr<T>{ptr.phys_addr + offset * sizeof(T)};
}
return phys_addr;
}
+ friend constexpr auto operator<=>(phys_ptr<T> a, phys_ptr<T> b) = default;
+
private:
T* get_virt_addr() const {
return reinterpret_cast<T*>(phys_addr + 0xFFFF800000000000);