<分区>
Possible Duplicate:
prohibiting instantiation as a temporary object (C++)
我像这样使用 Scopeguard 进行锁定(简化):
{ ScopeGuard sg(mutex); // ...critical code }
我不小心在某个地方打字了
{ ScopeGuard(mutex); // ...critical code }
这是有效的代码,但不会将 ScopeGuard 对象的生命周期延长到语句之后。
问题:如果我像第二个示例那样创建一个临时的 ScopeGuard 对象,是否有任何模式会导致编译器错误或警告?