c++ - 使 ReSharper 使用 m_ 约定
问题描述
我在 Visual Studio 中使用 ReSharper C++,但它使用了一些我不喜欢的奇怪命名约定。我想使用这个约定,它m_
在类成员变量和蛇形大小写上使用前缀。他们说.clang-format
可以使用,但我使用的不是 LLVM,而是 VS 的编译器。
有人制作了应用这些约定的文件吗?可以肯定的是,大多数人都在使用它们。
#ifndef RESOURCE_CLONER_HPP
#define RESOURCE_CLONER_HPP
#include <Windows.h>
#include <algorithm>
#include <stdexcept>
#include <string_view>
namespace resource_cloner
{
class resource_cloner
{
public:
resource_cloner() = default;
resource_cloner(const resource_cloner&) = delete;
resource_cloner(resource_cloner&& obj) noexcept
{
*this = std::move(obj);
}
~resource_cloner()
{
unload();
}
resource_cloner& operator=(const resource_cloner&) = delete;
resource_cloner& operator=(resource_cloner&& rhs) noexcept
{
m_source_path = rhs.m_source_path;
return *this;
}
void load()
{
m_module = LoadLibraryExW(m_source_path.data(), nullptr, LOAD_LIBRARY_AS_DATAFILE);
if (!m_module)
{
throw std::runtime_error("Could not open source file.");
}
}
void unload() const
{
if (m_module)
{
FreeLibrary(m_module);
}
}
private:
std::wstring_view m_source_path;
HMODULE m_module{ nullptr };
};
}
#endif
解决方案
您可以在“ReSharper | 选项 | 代码编辑 | C++ | 命名样式”选项页面上配置命名约定,或选择其中一种预定义方案。也就是说,同时使用“m_”作为类成员前缀和“t_”作为参数名称前缀是不寻常的,并且没有一个主要的 C++ 样式指南使用这种约定。
推荐阅读
- python - sklearn,DecisionTreeRegressor:我可以优先考虑一列数据而不是其他列吗?
- java - 如何将所需格式的值传递给@RequestParam 中的日期对象?
- node.js - 将流信息写入视频文件
- android - Is there any limitation using google apps script for google sheets in chrome OS (chromebook)?
- nativescript - Nativescript 6 - page.showModal 不再起作用
- react-native - 使用 React Native 的 Axios 发布请求上的 401
- c++ - 完全读取命名管道后,防止 FFmpeg 关闭
- xml - 在 XML Schema 中将本地类型转换为全局类型
- laravel - 包含模型之间是否存在关系的自定义属性
- ansible - ansible mount模块找不到特殊设备