我们是否可以增加这种面向密钥的访问保护模式的可重用性:
class SomeKey {
friend class Foo;
// more friends... ?
SomeKey() {}
// possibly non-copyable too
};
class Bar {
public:
void protectedMethod(SomeKey); // only friends of SomeKey have access
};
Run Code Online (Sandbox Code Playgroud)
为了避免持续的误解,这种模式不同于律师 - 客户的习惯用语:
(在这个问题中提出了一个侧面讨论,因此我打开了这个问题.)
显然,这种面向密钥的访问保护模式:
class SomeKey {
friend class Foo;
SomeKey() {}
// possibly non-copyable too
};
class Bar {
public:
void protectedMethod(SomeKey); // only friends of SomeKey have access
};
Run Code Online (Sandbox Code Playgroud)
......还没有一个已知的名字,因此我想找到一个好的名字,所以我们可以在不断言的情况下参考它.建议?
它应该是:
我想知道是否有任何方法可以知道当前执行的函数在哪里被调用,这是在什么文件和行中.我正在使用C语言,我正在寻找类似于__FUNCTION __,__LINE__或__FILE__宏的东西.