删除类的所有RVALUE功能超载
假设我有一个类对象,当从函数调用返回该类的对象时,呼叫者必须捕获必须捕获。
// no_can_rvalue *must* be captured
[[nodiscard]] no_can_rvalue a_func();
我可以通过删除所有RVALUE函数过载来强制执行此功能,从而无法使用类功能,除非呼叫者捕获了它的对象(c ++ 17中的nodiscard
加倍)。
是否可以删除给定类的全部 rvalue函数过载。
结果等同于:
struct no_can_rvalue {
void f() && = delete;
void f() &;
void g() && = delete;
void g() &;
// etc
};
Say I have a class object that must be captured by the caller when returning this class's object from a function call.
// no_can_rvalue *must* be captured
[[nodiscard]] no_can_rvalue a_func();
I can enforce this by deleting all rvalue function overloads, thus making it impossible to use the class functionality unless a caller has captured an object of it (doubled with nodiscard
in c++17).
Is it possible to delete all rvalue function overloads of a given class in one fell swoop?
The result being equivalent to :
struct no_can_rvalue {
void f() && = delete;
void f() &;
void g() && = delete;
void g() &;
// etc
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,不可能这样做。
No, it is not possible to do so.