dimanche 29 novembre 2020

Why there is still a inline specifier when member fuctions define inside class?

The C++ ISO standard says: A function defined within a class definition is an inline function.

But look at the code as follows: leveldb-skiplist

class template <typename Key, class Comparator>
class SkipList{
 public:
  /*
   ...
  */
 private:
  inline int GetMaxHeight() const {
    return max_height_.load(std::memory_order_relaxed);
  }
};

there is still an explicit inline specifier when GetMaxHeight is defined inside class.

So, I want to know why we still need an explicit inline when a function defined within a class?

Aucun commentaire:

Enregistrer un commentaire