transform_width.hpp(156): error C2589: ‘(‘ : illegal token on right side of ‘::‘
通过仔细地查看transform_width.hpp文件,发现是其中的std::min使用有问题,因为min函数的两个传入参数类型不一样,这样进行模板 匹配时,就找不到相应的模板。这行代码如下: unsigned int i = std::min(missing_bits, m_remaining_bits);
通过函数的代码来分析,missing_bits是unsigned int类型,而m_remaining_bits是CHAR类型,导致编译出错。知道了出错的原因,就容易 解决了。把这行代码修改为: unsigned int i = std::min<unsigned int>(missing_bits, m_remaining_bits);
相关的模板代码: template< class Base, int BitsOut, int BitsIn, class CharType > void transform_width<Base, BitsOut, BitsIn, CharType>::fill() { unsigned int missing_bits = BitsOut; m_buffer_out = 0; do{ if(0 == m_remaining_bits){ if(m_end_of_sequence){ m_buffer_in = 0; m_remaining_bits = missing_bits; } else{ m_buffer_in = * this->base_reference()++; m_remaining_bits = BitsIn; } }
// append these bits to the next output // up to the size of the output 修改之前: unsigned int i = std::min(missing_bits, m_remaining_bits); 把这行修改为: unsigned int i = std::min<unsigned int>(missing_bits, m_remaining_bits);
// shift interesting bits to least significant position base_value_type j = m_buffer_in >> (m_remaining_bits - i); // and mask off the un interesting higher bits // note presumption of twos complement notation j &= (1 << i) - 1; // append then interesting bits to the output value m_buffer_out <<= i; m_buffer_out |= j;