1313#include < mach/vm_types.h>
1414#include < bitset>
1515#include < os/lock.h>
16- #include " page .hpp"
16+ #include " page_const .hpp"
1717
1818OG_ASSUME_NONNULL_BEGIN
1919
@@ -33,44 +33,70 @@ template <typename T> class ptr {
3333 template <typename U> friend class ptr ;
3434
3535public:
36- ptr (difference_type offset = 0 ) : _offset(offset){};
37- ptr (nullptr_t ){};
36+ OG_INLINE OG_CONSTEXPR ptr (difference_type offset = 0 ) : _offset(offset){};
37+ OG_INLINE OG_CONSTEXPR ptr (nullptr_t ){};
3838
39+ OG_INLINE OG_CONSTEXPR
3940 void assert_valid () const {
4041 if (_offset >= table::shared ().data_capacity ()) {
4142 precondition_failure (" invalid data offset: %u" , _offset);
4243 }
4344 }
4445
45- element_type *_Nonnull get () const noexcept {
46+ OG_INLINE OG_CONSTEXPR
47+ element_type *_Nonnull get () const OG_NOEXCEPT {
4648 assert (_offset != 0 );
4749 return reinterpret_cast <element_type *>(table::shared ().data_base () + _offset);
4850 }
4951
50- ptr<page> page_ptr () const noexcept { return ptr<page>(_offset & page_alignment); }
52+ OG_INLINE OG_CONSTEXPR
53+ ptr<page> page_ptr () const OG_NOEXCEPT { return ptr<page>(_offset & page_alignment); }
5154
52- difference_type page_relative_offset () const noexcept { return _offset & page_mask; }
55+ OG_INLINE OG_CONSTEXPR
56+ difference_type page_relative_offset () const OG_NOEXCEPT { return _offset & page_mask; }
5357
5458 template <typename U> ptr<U> aligned (difference_type alignment_mask = sizeof (difference_type) - 1) const {
5559 return ptr<U>((_offset + alignment_mask) & ~alignment_mask);
5660 };
5761
58- operator bool () const noexcept { return _offset != 0 ; };
59- std::add_lvalue_reference_t <T> operator *() const noexcept { return *get (); };
60- T *_Nonnull operator ->() const noexcept { return get (); };
62+ OG_INLINE OG_CONSTEXPR
63+ operator bool () const OG_NOEXCEPT { return _offset != 0 ; };
6164
62- bool operator ==( nullptr_t ) const noexcept { return _offset == 0 ; };
63- bool operator !=( nullptr_t ) const noexcept { return _offset != 0 ; };
65+ OG_INLINE OG_CONSTEXPR
66+ std:: add_lvalue_reference_t <T> operator *( ) const OG_NOEXCEPT { return * get () ; };
6467
65- bool operator <(difference_type offset) const noexcept { return _offset < offset; };
66- bool operator <=(difference_type offset) const noexcept { return _offset <= offset; };
67- bool operator >(difference_type offset) const noexcept { return _offset > offset; };
68- bool operator >=(difference_type offset) const noexcept { return _offset >= offset; };
68+ OG_INLINE OG_CONSTEXPR
69+ T *_Nonnull operator ->() const OG_NOEXCEPT { return get (); };
6970
70- template < typename U> ptr<U> operator +(difference_type shift) const noexcept { return ptr (_offset + shift); };
71- template < typename U> ptr<U> operator -(difference_type shift ) const noexcept { return ptr ( _offset - shift) ; };
71+ OG_INLINE OG_CONSTEXPR
72+ bool operator ==( nullptr_t ) const OG_NOEXCEPT { return _offset == 0 ; };
7273
73- template <typename U> difference_type operator -(const ptr<U> &other) const noexcept {
74+ OG_INLINE OG_CONSTEXPR
75+ bool operator !=(nullptr_t ) const OG_NOEXCEPT { return _offset != 0 ; };
76+
77+ OG_INLINE OG_CONSTEXPR
78+ bool operator <(difference_type offset) const OG_NOEXCEPT { return _offset < offset; };
79+
80+ OG_INLINE OG_CONSTEXPR
81+ bool operator <=(difference_type offset) const OG_NOEXCEPT { return _offset <= offset; };
82+
83+ OG_INLINE OG_CONSTEXPR
84+ bool operator >(difference_type offset) const OG_NOEXCEPT { return _offset > offset; };
85+
86+ OG_INLINE OG_CONSTEXPR
87+ bool operator >=(difference_type offset) const OG_NOEXCEPT { return _offset >= offset; };
88+
89+ template <typename U>
90+ OG_INLINE OG_CONSTEXPR
91+ ptr<U> operator +(difference_type shift) const OG_NOEXCEPT { return ptr (_offset + shift); };
92+
93+ template <typename U>
94+ OG_INLINE OG_CONSTEXPR
95+ ptr<U> operator -(difference_type shift) const OG_NOEXCEPT { return ptr (_offset - shift); };
96+
97+ template <typename U>
98+ OG_INLINE OG_CONSTEXPR
99+ difference_type operator -(const ptr<U> &other) const OG_NOEXCEPT {
74100 return _offset - other._offset ;
75101 };
76102}; /* ptr */
0 commit comments