using C++11 attributes(使用 C++11 属性)
问题描述
您能否解释一下如何从 C++ 中的属性中获取信息?例如,我想编写 C++ 到 python 绑定.为此,我需要用一些特定的绑定信息来注释类中的所有方法.现在我需要按属性生成一些代码.或者另一个例子,将类映射到数据库实体.还是 C++11 的属性与 Java 或 C# 中的注解不一样?
Could you please explain how to get information from attributes in C++? For example, I want to write C++ to python binding. For this I need to annotate all methods in class with some specific binding info. Now I need to generate some code by attributes. Or another example, map class to db entity. Or C++11 attributes is not the same as in Java or C# annotations?
推荐答案
属性(新的 C++11 功能) 只是编译器扩展的标准化语法.要执行您想要的操作,您需要一个具有适当扩展名的编译器.到目前为止,我认为任何编译器都没有实现属性语法,更不用说 Python 绑定的任何特定属性了.
Attributes (a new C++11 feature) are just a standardized syntax for compiler extensions. To do what you want you would need a compiler with the proper extensions. So far, I don't think any compiler even implements attribute syntax, much less any specific attributes for Python bindings.
因为它们是为编译器扩展而设计的,所以没有创建自己的属性的标准方法,就像使用 Java 注释或 C# 属性一样.当然,编译器可以提供这种能力作为扩展... ;)
Because they're intended for compiler extensions, there's no standard way of creating your own attributes, like you can with Java annotations or C# attributes. Of course, a compiler could provide this ability as an extension... ;)
这篇关于使用 C++11 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 C++11 属性
基础教程推荐
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- c++ STL设置差异 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
