1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:23:51 +00:00

Improve constness of the Nif RecordPtr structs

This commit is contained in:
Chris Robinson 2013-07-24 23:58:35 -07:00
parent 8e24cab935
commit fb0ee7f2fc

View file

@ -71,16 +71,26 @@ public:
} }
/// Look up the actual object from the index /// Look up the actual object from the index
X* getPtr() const const X* getPtr() const
{ {
assert(ptr != NULL); assert(ptr != NULL);
return ptr; return ptr;
} }
X& get() const X* getPtr()
{
assert(ptr != NULL);
return ptr;
}
const X& get() const
{ return *getPtr(); }
X& get()
{ return *getPtr(); } { return *getPtr(); }
/// Syntactic sugar /// Syntactic sugar
X* operator->() const const X* operator->() const
{ return getPtr(); }
X* operator->()
{ return getPtr(); } { return getPtr(); }
/// Pointers are allowed to be empty /// Pointers are allowed to be empty
@ -116,6 +126,8 @@ public:
const Ptr& operator[](size_t index) const const Ptr& operator[](size_t index) const
{ return list.at(index); } { return list.at(index); }
Ptr& operator[](size_t index)
{ return list.at(index); }
size_t length() const size_t length() const
{ return list.size(); } { return list.size(); }