我有类似的代码:
std::unique_ptr<Object> get_raii_object()
{
return std::make_unique<Object>(/* Many parameters that I don't want to write several times, if I remove this function altogether */ );
}
void some_code()
{
std::unique_ptr<Object> raii_object_holder = get_raii_object();
more_code();
}
Resharper C ++标记&#34; raii_object_holder&#34;作为未使用的局部变量,尽管有必要。
我更愿意避免在本地或全局禁用此警告
答案 0 :(得分:0)
为什么不:
class ConfiguredObject : public Object
{
public:
ConfiguredObject()
: Object(/* Many parameters that I don't want to write several times, if I remove this function altogether */)
{}
};
void some_code()
{
ConfiguredObject object_holder;
}