错误:类型“std::bitset<16>”不提供调用运算符

问题描述 投票:0回答:1

我正在研究这个:来自 github 上 Andrei Tkachenko 的 WavReaderQt.cpp。 复制了我要从原始代码编辑的代码。

我想打印它输出的文本文件中的位,但也将带符号的波形数据转换为无符号的。

我收到此错误:

error: Type 'std::bitset<16>' does not provide a call operator
    

如果我尝试在 switch 语句中创建位集,我会收到另一个错误。

std::string mystring = "";
std::bitset<0b10000> decimalBitset;

while (wavFile.read(buff, 0x04) > 0)
{
    chunkDataSize -= 4;
    ++samples;
    //quint8 sampleChannel1;
    qint16 sampleChannel1;
    qint16 sampleChannel2;
    //std::bitset<16> bitset;
    //QBitArray bitset;
    switch (wavHeader.numChannels) {
    case 1:
        sampleChannel1 = qFromLittleEndian<qint16>((const uchar*)buff);

        decimalBitset(sampleChannel1);
        
        mystring =  decimalBitset.to_string<char,std::string::traits_type,std::string::allocator_type>();

        
        saveFile.write(QString("%1\t %2\n").arg(sampleChannel1).arg(mystring.c_str()).toUtf8());
        qDebug("sample:\r %d", sampleChannel1);
        break;
}

c++ qt bitset std-bitset
1个回答
0
投票

解决办法是:

decimalBitset = sampleChannel1;

cppreference.com、geeksforgeeks.org、cplusplus.com 上未注明。

© www.soinside.com 2019 - 2024. All rights reserved.