使用C ++ 11的属性 [英] using C++11 attributes
问题描述
能否请你解释一下如何从属性的信息,在C ++?例如,我想要写C ++到Python绑定。为此,我需要做注解,类的所有方法与某些特异结合的信息。现在我需要通过生成一些属性code。或再比如,地图类数据库实体。或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的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!