Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
reinterpret_cast 到 C 样式数组是非法的 C++11 吗?
为什么下面的代码不受欢迎 double d 4 0 1 2 3 reinterpret cast
c
casting
reinterpretcast
Arrays
当将 void* 转换为任何内容时,我应该使用 static_cast 还是 reinterpret_cast
Both static cast and reinterpret cast似乎适合铸造void 到另一个指针类型 是否有充分的理由偏爱其中之一 Use static cast 这是最精确的转换 准确地描述了此处进行的转换 有一个误解 认为使
c
pointers
staticcast
reinterpretcast
将此 c-cast 更改为reinterpret_cast 是否安全?
我正在尝试从我正在处理的某些代码中删除 c 风格的强制转换 并且我对唯一的替代方案感到担忧 原来的代码是 WPARAM param WPARAM GetDlgItem IDC WORKFLOW m hWnd this gt PostMess
c
WINAPI
casting
reinterpretcast
通过 void* 进行铸造而不是使用reinterpret_cast [重复]
这个问题在这里已经有答案了 我正在读一本书 我发现reinterpret cast不应该直接使用 而应该结合使用强制转换为 void static cast T1 p1 void pv p1 T2 p2 static cast
c
casting
voidpointers
languagelawyer
reinterpretcast
为什么reinterpret_cast不是constexpr?
考虑以下片段 static constexpr uint8 t a 0 static constexpr const int8 t b reinterpret cast
c
C11
AVR
constexpr
reinterpretcast
使用 C++ 风格转换从 Void* 转换为 TYPE*:static_cast 或 reinterpret_cast
因此 如果您从 Void 转换为 Type 或从 Type 转换为 Void 您应该使用 void func void p Params params static cast
c
casting
staticcast
reinterpretcast
reinterpret_cast bug 还是 UB? [复制]
这个问题在这里已经有答案了 考虑以下代码 include
c
languagelawyer
undefinedbehavior
reinterpretcast
当两个链接的 static_cast 可以完成它的工作时,为什么我们在 C++ 中需要 reinterpret_cast 呢?
说我想投A to char 反之亦然 我们有两种选择 我的意思是 我们很多人认为我们有两种选择 because两者似乎都有效 因此造成混乱 struct A int age char name 128 A a char buffer sta
c
casting
reinterpretcast
staticcast
重新解释底层位模式并将其写入数组或字段的最有效方法是什么?
Using Unsafe putXXX可以将原始类型放入数组或对象字段中 但是像下面这样的代码会产生错误 import java lang invoke MethodHandles import java lang invoke VarHa
Java
Arrays
performance
unsafe
reinterpretcast
为什么我必须重新解释指针指针?
So this static cast代码是完全合法的 int n 13 void pn static cast
c
voidpointers
reinterpretcast
staticcast
doublepointer
reinterpret_cast 类型双关实际上是未定义的行为吗?
这种类型的双关语似乎被广泛持有reinterpret cast以某种方式被禁止 正确地说 未定义的行为 即 本国际标准没有提出要求的行为 https timsong cpp github io cppwp n4659 defns undef
c
casting
languagelawyer
reinterpretcast
typepunning
以下reinterpret_cast是否会导致未定义的行为?
是否reinterpret cast下面的代码中会导致未定义的行为吗 如果确实如此 是否可以定义rpd以类型安全的方式 class Base public virtual Base default class Derived public
c
pointers
reinterpretcast
隐式对象创建是否规避了 std::launder 的可达性条件?
这个问题源于对我的回答的思考给定两个不同类型的对象及其在内存中的相对位置 我可以从指向另一个对象的指针派生出指向另一个对象的指针吗 https stackoverflow com questions 76113351 given two o
c
languagelawyer
reinterpretcast
stdlaunder
取消引用 void 指针时的reinterpret_cast 行为
在与某人争论他在评论中提出的建议时这个答案 https stackoverflow com a 21177728 241631 我遇到了一些 gcc4 8 和 VS2013 拒绝编译的代码 但 clang 很高兴地接受它并显示正确的结果 i
c
reinterpretcast
转换为不相关的引用类型是否违反了严格的别名规则?
严格的别名规则说 如果程序尝试通过以下方式访问对象的存储值 除以下类型之一之外的左值 其行为是 不明确的 对象的动态类型 对象动态类型的 cv 限定版本 与对象的动态类型类似 如 4 4 中定义 的类型 与对象的动态类型相对应的有符号或无符
c
languagelawyer
undefinedbehavior
reinterpretcast
strictaliasing
严格的指针别名:针对特定问题的任何解决方案?
我遇到了由于违反严格的指针别名规则而引起的问题 我有一个类型T来自模板和一些整数类型Int相同大小 如sizeof 我的代码基本上执行以下操作 T x some other t if reinterpret cast
c
generics
reinterpretcast
strictaliasing
typepunning
reinterpret_cast 为相同类型
考虑以下程序 struct A int main A a A b a A c reinterpret cast a a 编译器 g 14 抛出一个错误invalid cast from type A to type A 为什么转换为相同类型
c
c14
standards
reinterpretcast
何时使用reinterpret_cast?
我对以下内容的适用性有点困惑reinterpret cast vs static cast 根据我的阅读 一般规则是当类型可以在编译时解释时使用静态强制转换 因此这个词static 这也是 C 编译器在内部用于隐式转换的转换 reinter
c
casting
reinterpretcast
放置 new 的返回值与其操作数的强制转换值之间是否存在(语义)差异?
放置 new 的返回值与其操作数的强制转换值之间是否存在 语义 差异 struct Foo char buffer Foo a new buffer Foo Foo b reinterpret cast
c
languagelawyer
reinterpretcast
strictaliasing
placementnew
将结构体转换为数组[重复]
这个问题在这里已经有答案了 这是一个严格的别名问题 因为编译器会导致任何优化顺序问题 说我有三个公共floats in a struct XMFLOAT3 不像this one 我想投射到float 这会让我陷入优化麻烦吗 XMFLOAT3
c
Arrays
struct
alias
reinterpretcast
1
2
»