什么是C ++的##运营商的目的,什么叫? [英] What is the purpose of the ## operator in C++, and what is it called?

查看:143
本文介绍了什么是C ++的##运营商的目的,什么叫?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找通过自带的DirectX的2009年3月SDK中的DXUTCore项目,并注意到反而让正常的访问方法,他们用宏来创建通用的访问,类似于以下内容:

I was looking through the DXUTCore project that comes with the DirectX March 2009 SDK, and noticed that instead of making normal accessor methods, they used macros to create the generic accessors, similar to the following:

#define GET_ACCESSOR( x, y )  inline x Get##y()  { DXUTLock l; return m_state.m_##y;};
...

GET_ACCESSOR( WCHAR*, WindowTitle );

如此看来,##只操作者从插入第二个参数文成宏创建使用该文本的操作变量的函数。这东西是用C ++标准(即不是微软具体说明)?是其使用好的做法?而且,什么是所谓的运营商?

It seems that the ## operator just inserts the text from the second argument into the macro to create a function operating on a variable using that text. Is this something that is standard in C++ (i.e. not Microsoft specific)? Is its use considered good practice? And, what is that operator called?

推荐答案

Token-粘贴操作者,使用由pre处理器将两个标记成一个单一的令牌。

Token-pasting operator, used by the pre-processor to join two tokens into a single token.

这篇关于什么是C ++的##运营商的目的,什么叫?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆