Max*_*hof 3 c++ member-functions one-definition-rule language-lawyer
In my understanding, member functions defined inside a class definition are implicitly inline
:
class X {
int f() { return 1; } // Implicitly inline.
};
int g() { return 2; } // Not implicitly inline.
Run Code Online (Sandbox Code Playgroud)
I was looking for the standard quote to support this, but I can only find basic.link/7:
In addition, a member function, static data member, a named class or enumeration of class scope, or an unnamed class or enumeration defined in a class-scope typedef declaration such that the class or enumeration has the typedef name for linkage purposes ([dcl.typedef]), has the same linkage, if any, as the name of the class of which it is a member.
I can't find anything relevant in dcl.typedef that relates to simple class definitions (without typedef
being involved).
我在找对地方了吗?如果不是,确切的标准措辞在哪里?
也许在有关的部分中查找inline
。
[dcl.inline]/4:
在类定义中定义的函数是内联函数。
实际上,稍后会在有关成员函数的部分中重复上述操作(这似乎也很明智!):
[class.mfct]/1:
成员函数可以在其类定义中定义,在这种情况下,它是内联成员函数[..]
归档时间: |
|
查看次数: |
74 次 |
最近记录: |