我正在使用一个代码库,我在其中看到以下代码行
auto a = static_cast<custom_type*>(obj.get())->a();
auto b = static_cast<custom_type*>(obj.get())->b();
auto c = static_cast<custom_type*>(obj.get())->c();
Run Code Online (Sandbox Code Playgroud)
期望编译器优化一系列get()andstatic_cast调用是否合理,或者最好执行以下操作:
auto temp = static_cast<custom_type*>(obj.get());
auto a = temp->a();
auto b = temp->b();
auto c = temp->c();
Run Code Online (Sandbox Code Playgroud)