gpt4 book ai didi

c++ - 类主体中定义的内联友元函数

转载 作者:行者123 更新时间:2023-11-30 01:10:16 24 4
gpt4 key购买 nike

通常当我们直接在类体中定义一个成员函数时,它是隐式的内联。但是这个呢:

class Foo {
public:
friend void swap(Foo& a, Foo& b) { ... }

...
};

swap 是否隐式内联

最佳答案

是的。请参阅标准中的 [class.friend/6-7]:

A function can be defined in a friend declaration of a class if and only if the class is a non-local class (9.8), the function name is unqualified, and the function has namespace scope.

Such a function is implicitly inline.

关于c++ - 类主体中定义的内联友元函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38318475/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com