reinterpret_cast翻译

来源:互联网 发布:rocketdock类似软件 编辑:程序博客网 时间:2024/06/15 20:22

Allows any pointer to be converted into any other pointer type.

允许从任何指针类型转换成其他任意指针类型

reinterpret_cast < type-id > ( expression )

Remarks

The reinterpret_cast operator also allows any integral type to be converted into any pointer type and vice versa. Misuse of the reinterpret_cast operator can easily be unsafe. Unless the desired conversion is inherently low-level , you should use one of the other cast operators.

Reinterpret_cast操作符同样可以任何整型转换成任意指针类型,反之亦然。滥用reinterpret_cast操作符是很容易不安全,除非期望的转换是低级的,否则你可以使用其他转换符。

The reinterpret_cast operator can be used for conversions such as char* to int*, or One_class* to Unrelated_class*, which are inherently unsafe.

Reinterpret_cast可以用来从char*int*或者从one_class*Unrelated_class*的转换,他们都是不安全的

The result of a reinterpret_cast cannot safely be used for anything other than being cast back to its original type. Other uses are, at best, nonportable.

Reinterpret_cast对任何类型的转换都是不安全的,除了向后转化成他的原始类型,其他的使用,至多是不可以移植的

The reinterpret_cast operator cannot cast away the const, volatile, or __unaligned attributes. See const_cast Operator for information on removing these attributes.

Reinterpret_cast操作符在转化的过程中去掉const,volatile或者__unaligned属性。可以查看const_cast操作符关于去掉这些属性的信息

The reinterpret_cast operator converts a null pointer value to the null pointer value of the destination type.

Reinterpret_cast操作符可以将NULL指针值转换为指定类型的空指针值;

One practical use of reinterpret_cast is in a hash function, which maps a value to an index in such a way that two distinct values rarely end up with the same index.

Reinterpret_cast的一个实际的应用就是在哈希函数中,它是一个值映射到一个索引上,使得不同的两个值很难对应同一个索引

 1.inherently lower-level不知道如何理解,请指教

 2.being cast back to its original type这个如何来理解?

原创粉丝点击