Ay's Blog@CNSSUESTC

ATL的offsetofclass中,为啥_ATL_PACKING是8的解释

解答出处

http://stackoverflow.com/questions/5014061/whats-the-use-of-atl-packing-constant-when-computing-distance-from-the-start-o

 

C++标准规定:

编译器的类的类型转换对空指针(NULL)特殊处理,即你NULL进行强制类型转化的结果还是NULL,所以….

				static_cast类型转化的时候,_ATL_PACKING的值得是非零就好
		
				
				 

C++ Standard 4.10/3 Pointer conversions [conv.ptr]:

An rvalue of type “pointer to cv D,” where D is a class type, can be converted to an rvalue of type “pointer to cv B,” where B is a base class (clause 10) of D. If B is an inaccessible (clause 11) or ambiguous (10.2) base class of D, a program that necessitates this conversion is ill-formed. The result of the conversion is a pointer to the base class sub-object of the derived class object. The null pointer value is converted to the null pointer value of the destination type.

posted on 2012-01-12 13:52 __ay 阅读(1904) 评论(1)  编辑 收藏 引用 所属分类: 算法 && C/C++

Feedback

# re: ATL的offsetofclass中,为啥_ATL_PACKING是8的解释 2012-01-25 11:56 泡菜

说实话没看懂。。。。

不过,C++/C的NULL之前都是宏实现,每个编译器的底层实现是不同的,所以进行特殊处理是很正常的,在正式C++2011中就出台了一个‘nullptr——空指针标识’,来统一,减少各个编译器的相互’兼容‘性
这里有文章:

http://imcc.blogbus.com/logs/107147212.html  回复  更多评论   



只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理