CLion 中的方法签名重构为 const

Method signature refactor to const in CLion

我正在为 C++ 程序使用 intellij clion。
我正在使用方法签名重构 (ctrl+F6)。
如何将签名从非 const 方法更改为 const?

Link明白了。

不幸的是,adding/removing CLion 尚未实现更改签名重构期间的 CV 限定符,请关注或投票相应的 issue

到目前为止最简单的方法是在整个项目中替换字符串(编辑->查找->替换路径):

"<method name>(<parameters>) <existing attributes set>"

"<method name>(<parameters>) <new attributes set>"

例如:

replace what: "initImpl(GraphicsContext *context)"
replace with: "initImpl(GraphicsContext *context) const"

这将取代:

  • 方法声明
  • 覆盖子 类
  • 中的声明
  • 所有方法定义。

嗯,这不适用于您使用不同类型同义词的地方。

干杯!