Is “inline” implicit in C++ member functions defined in class definition

后端 未结 4 737
无人及你
无人及你 2020-12-01 10:36

According to the C++ specification, are the following two classes equivalently defined?

class A
{
   void f()
   {
   }
};

class B
{
   inline void f()
   {         


        
4条回答
  •  失恋的感觉
    2020-12-01 11:03

    The C++ ISO standard says:

    A function defined within a class definition is an inline function.

    But, this doesn't mean the function will necessarily be inlined: generally nowadays, it appears that the compiler will decide if inlining the function will lead to any benefits.

提交回复
热议问题