reinterpret-cast
interpret unsigned as signed
I\'m working on an embedded platform (ARM) and have to be careful when dealing with bit patterns. Let\'s pretend this line is beyond my influence:[详细]
2023-04-03 19:39 分类:问答How to implement safe copy constructor for class that has internal placement new (with std::string)
Here\'s my code: struct RS_Token { char id; char cleanup; unsigned char array[sizeof (std::string) > sizeof (double) ? sizeof (std::string) : sizeof (double)];[详细]
2023-03-27 10:36 分类:问答Reinterpret_cast use in C++
Just a simple question,having this: fftw_complex *H_cast; H_cast = (fftw_complex*) fftw_malloc(sizeof(fftw_comp开发者_运维知识库lex)*M*N);[详细]
2023-03-21 00:19 分类:问答C++ When should we prefer to use a two chained static_cast over reinterpret_cast
First of all, this is not a duplicate of Why do we have reinterpret_cast in C++ when two chained static_cast can do it\'s job?.[详细]
2023-03-18 20:13 分类:问答May I have a real life example where casting through void* works and reinterpret_cast doesn't?
There\'s a set of questions regarding c开发者_StackOverflow中文版ross-casts (cast from T1* to unrelated T2*), for example this and this. The answer usually goes like this: reinterpret_cast is implemen[详细]
2023-03-18 03:49 分类:问答Safe way to reinterpret_cast raw struct at particular offset and type?
return *reinterpret_cast<UInt32*>((reinterpret_cast<char*>(this) + 2)); Struct is pragma packed 1 and contains a bunch of uint, char, short fields...[详细]
2023-03-16 18:14 分类:问答casting member function pointer
I need to use a member function pointer that takes in an argument of base class that used in other code. Well, simply I want do to [something] like the example below. This code works fine, but I wonde[详细]
2023-03-09 07:35 分类:问答Can I convert a null pointer of int to a long type by reinterpret_cast
int *pt = 0; long i = reinterpret_cast<long>(pt); Is i guaranteed to be 0? Is this well defined or implementation-defined?[详细]
2023-02-24 09:04 分类:问答Is std::complex stored in an interleaved fashion?
That is, on disk, if I have an array of std::complex, is it stored RIRIRIRI or RRRRIIII or something else?[详细]
2023-02-17 05:07 分类:问答reinterpret_cast for almost pod data (is layout-compatibility enough)
I am trying to learn about static_cast and reinterpret_cast. If I am correct the standard (9.2.18) says that reinterpret_cast for pod data is safe:[详细]
2023-02-12 01:24 分类:问答