reinterpret-cast

    0热度

    1回答

    我目前正在处理与排序相关的问题。 假设我在big-endian系统中有一个big-endian文件。 在此文件中的第一个值是2882400152 = 0xABCDEF98是一个整数4. 要在整数4,_myint4阅读价值,我简单地做: mystream.read(reinterpret_cast<char*>(&_myint4), sizeof(_myint4)) 的问题是:是什么相当于读取文

    6热度

    5回答

    参考SO C++ FAQ When should static_cast, dynamic_cast and reinterpret_cast be used?。 const_cast用于删除或添加const到一个变量及其唯一可靠,定义和合法的方式来消除常量。 reinterpret_cast用于更改类型的解释。 我理解一个合理的方式,为什么一个const变量应该只是使用const_cast转换为

    0热度

    1回答

    起初,我对我的英语:) 对不起所以,我有一个结构和可变 typedef struct { GHEADER m_Header; BYTE *m_Buf; Addr *m_Abonent; }__attribute__((packed)) PACKET; unsigned char* uc_ptr; 我需要发送一些功能无符号的字符指针参数。我尝试使用reint

    3热度

    1回答

    我试图破解Qt的信号和插槽,并且遇到了QMetaType :: invokeMethod无法将指针参数正确传递到被调用的插槽的问题。 call(QObject *receiver, const char *slot, const QList<QGenericArgument> &args) { const QMetaObject *meta = receiver->metaObject

    2热度

    3回答

    我有某种对象工厂(基于模板),这对我的目的非常有用。但是现在我已经尝试过使用QObject和纯抽象类(接口)派生的类,并且我有一些奇怪的运行时错误。 这里这个类(衍生) class Interface { public: Interface(){} virtual ~Interface(){} virtual int getResult() = 0; };

    2热度

    3回答

    这是我和的isEqual哈希运营商定制 - (BOOL)isEqual:(id)object; { BGSearchParameter * theOther = (BGSearchParameter *)object; BOOL isTheOtherEqual; isTheOtherEqual = isTheOtherEqual && [self.Location

    6热度

    6回答

    这是我想做的事: const int64_t randomIntNumber = reinterpret_cast<int64_t> (randomUintNumber); 哪里randomUintNumber是uint64_t类型。 该错误是(2010 MSVC): 错误C2440: '的reinterpret_cast':不能从 'const的uint64_t中' 转换 '的int64_t'

    -2热度

    2回答

    uint data1; ushort data2; ushort data3; uchar data4[8]; std::uint8_t buff[16]; std::uint8_t* out = buff; out = std::copy_n(reinterpret_cast<std::uint8_t*>(&quid.data1), 4, out); out = std::co

    0热度

    3回答

    C++标准提到reinterpret_cast是定义执行,并没有给出任何保证不同的是浇铸背面(使用reinterpret_cast)到原始类型将导致传递给第一原始值。 至少某些类型的C风格转型的行为方式非常相似 - 使用相同的值来回转换结果 - 目前我正在使用枚举和int s,但也有一些其他示例。 虽然C++标准给出了两个铸风格的定义,它也给混合管型相同的质量保证?如果库X从函数int Y()中返

    5热度

    3回答

    我现在有以下功能读取一个数组或原始数据的矢量(_readStream是std::ifstream): template<typename IteratorType> inline bool MyClass::readRawData( const IteratorType& first, const IteratorType& last, typename std::i