I am very confused about the const version and non-const version member function like below:
value_type& top() { return this.item }
const value_type&
When member function is declared as const what's happening is that the implicit this pointer parameter passed to the function is typed to be a pointer to a const object. This allows the function to be called using a const object instance.
value_type& top(); // this function cannot be called using a `const` object
const value_type& top() const; // this function can be called on a `const` object