c++ - 用户定义文字的别名,即'使用 NS::operator ""_suffix' 和另一个名称
问题描述
考虑一些库定义:
namespace NS {
constexpr atype operator ""_suffix(const char*, std::size_t);
};
如果我不喜欢这个名称_suffix
(可能与其他库冲突,或者与我的命名约定形成鲜明对比):我可以“重命名”操作员吗?
using _myalias = NS::operator ""_suffix`; // syntax error
using _myalias = NS::""_suffix`; // syntax error
using _myalias = NS::_suffix`; // undefined (`operator ""` is part of its name)
constexpr decltype(auto) operator ""_myalias(const char *str, std::size_t len)
{
return NS::operator ""_suffix(str, len); // very verbose, but it works
}
那么,是否有一种简单的语法来为用户定义的文字定义别名?
解决方案
推荐阅读
- php - 运行删除函数时调用未定义的方法 CI_DB_sqlsrv_driver
- sql - 在 avg() over () 子句内四舍五入不起作用 - SQL Server
- reactjs - 测试反应模态不能使关闭模态测试通过
- javascript - Highcharts Gantt - 在依赖路径悬停时显示工具提示
- css - 如何垂直对齐 div 中的文本(boostrap 4)?
- node.js - nodejs如何加载.env文件?
- powershell - 在线程作业中使用 SetImage
- r - 如何在 R 中为积分()做 for 循环
- python - 从第一个时代开始,我在 Keras 的损失函数中得到了一个 NaN
- python - 试图从网站上抓取数据,必须导航多个标签