基于函数返回的stl容器构造效率(Efficiency of construction of stl container based on a function return)
我有一个返回stl容器的工厂函数:
const std::vector<int> f(...) { std::vector<int> retval; return retval; }
我想可以定义一个stl实例如下(没有错误):
const std::vector<int> stl_instance(f(...));
但这样做有效吗?
临时stl对象是否直接分配给
stl_instance
?I have a factory function which return a stl container:
const std::vector<int> f(...) { std::vector<int> retval; return retval; }
I guess it is ok to define a stl instance as follow(no error):
const std::vector<int> stl_instance(f(...));
But is it efficient to do so?
Is the temporary stl object directly assigned to
stl_instance
?
原文:https://stackoverflow.com/questions/14251010
最满意答案
您可以编写一个调用PMD的Ant脚本,并在保存/构建项目时运行它。 这样做的缺点是在IDE之外提供PMD报告。 这将否定原始程序的任何时间节省。 如果您只是想知道是否有任何错误,它可能会很有用。
或者您可以扩展Eclipse插件以添加快捷方式。
You could write an Ant script that calls PMD and have it run whenever you save/build the project. That has the disadvantage of giving you a PMD report outside the IDE. Which would negate any time savings from the original procedure. It could be useful if you just want to know whether there are any errors or not.
Or you could extend the Eclipse plugin to add a shortcut.
相关问答
更多-
如果将jar作为Eclipse插件片段添加到Eclipse安装中,则可以使用自定义规则类。 插件片段的主机必须是ch.acanda.eclipse.pmd.core 。 要将jar转换为插件片段,您必须修改文件MANIFEST.MF文件并添加一些清单头。 以下是Eclipse插件片段的完整清单: Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Custom PMD Rules Bundle-SymbolicName: org.exam ...
-
Gradle的默认配置是使用java-basic ( 源代码 ) 然而,这是一种非常保守的方法,几乎没有PMD所提供的优势。 我作为PMD维护者的个人建议是: 查看https://pmd.github.io/pmd-5.8.1/pmd-java/rules/index.html上提供的所有规则 创建您自己的规则集,包括您同意的那些规则,以及您可能希望从默认值更改的所有额外属性。 Gradle和PMD Eclipse插件都可以从文件规则集加载规则,这样可以很容易地使它们始终保持同步。 The default ...
-
Eclipse重复注释@SurpressWarnings for PMD(Eclipse duplication annotation @SurpressWarnings for PMD)[2023-03-14]
你必须把它们列在一个数组中。 喜欢这个: @SuppressWarnings({ "PMD.OnlyOneReturn", "PMD.ShortVariable" }) You have to list them in an array. Like this: @SuppressWarnings({ "PMD.OnlyOneReturn", "PMD.ShortVariable" }) -
eclipse插件使用PMD分析文件。 如果你想自动化分析,那么你想直接使用PMD,而不是eclipse插件。 看看PMD的课。 它具有启动分析的静态方法PMD.doPMD(配置) 。 如果您想从命令行启动它,同一个类还包含主要方法 。 你可以找到一个如何在eclipse插件的Analyser.runPMD()方法中调用PMD.doPMD(配置)的例子。 The eclipse plugin uses PMD to analyse the files. If you want to automate the ...
-
要安装PMD for Eclipse插件: 在Eclipse中,单击“帮助” - >“安装新软件”... 点击添加.. 输入以下内容:名称:Eclipse更新站点URL的PMD: https : //sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/ ,然后单击“确定”。 您应该看到Eclipse的PMD 选中它旁边的复选框,然后单击下一步>。 您需要接受许可证并确认您要安装未经过数字签名的插件。 无论如何,继续安装它。 重启eclipse ...
-
您可以编写一个调用PMD的Ant脚本,并在保存/构建项目时运行它。 这样做的缺点是在IDE之外提供PMD报告。 这将否定原始程序的任何时间节省。 如果您只是想知道是否有任何错误,它可能会很有用。 或者您可以扩展Eclipse插件以添加快捷方式。 You could write an Ant script that calls PMD and have it run whenever you save/build the project. That has the disadvantage of giving ...
-
您可以使用PMD编写新规则。 在您的情况下,新的XPath规则足以快速检查AST(抽象语法树)并执行您需要的检测。 替代文字http://pmd.sourceforge.net/images/designer_screenshot.png 因此,您可以声明新的规则集 ,并将它们与您的PMD插件一起集成到您的eclipse中 。 注意: PMD代表很多东西 ;) 我们一直试图找到PMD字母的含义 - 坦率地说,我们并不知道。 我们只是认为这些字母听起来很合适。 相当多 项目混乱探测器 项目监督指令 项目符合截 ...
-
首选项 - > PMD(请不要在搜索栏上搜索PMD,然后找不到规则配置,尝试通过滚动每个首选项来查找)。 选择所需的规则。 点击应用和确定(它会重新建立规则) 现在右键单击代码并选择PMD->代码检查 Preferences -> PMD (please do not search PMD on search bar then you can not find the rule configuration try to find by scrolling each preference). Select t ...
-
从sourceforge托管的更新站点安装pmd-eclipse时可能会出现一些已知问题,请参阅https://github.com/pmd/pmd-eclipse-plugin/issues/19 要解决所有这些问题,请按照以下说明操作: 从那里下载最新的pmd-eclipse-plugin版本的更新站点作为zip文件: https : //github.com/pmd/pmd-eclipse-plugin/releases 在eclipse中,转到:帮助>安装新软件>添加>存档并选择更新站点zip文件( ...
-
命令行解析器在PMD 5.0.1中已更改,但遗憾的是文档从未更新过。 这些是变化: args[0]现在是-dir args[1]现在是-format args[2]现在是-rulesets 当你-format ideaj ,它还需要三个参数。 现在使用-property {name}={value}指定那些报告格式特定参数: args[3]现在是-property sourcePath args[4]现在是-property classAndMethodName args[5]现在是-property si ...