Reputation: 1
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?
Upvotes: 0
Views: 30
Reputation: 179809
You don't need it. It's redundant. Just like repeating virtual
in the declaration of an override
.
The grammar allows it, because it's a function definition, and there's no additional wording that bans it.
Upvotes: 2