Boost logo

Boost Users :

Subject: Re: [Boost-users] reinterpret_cast boost integer
From: Brad Tilley (kj4eit_at_[hidden])
Date: 2012-02-05 10:06:35


I can make the cast work by storing it in a uint16_t or larger type:

void process_uint8_t( const std::string& bytes )
{
    const boost::uint16_t * data_ptr;
    boost::uint16_t data;

    data_ptr = reinterpret_cast<const boost::uint16_t*>(bytes.data());
    data = *data_ptr;

    std::cout << data << "," << sizeof(data) << std::endl;
}

I thought this would work in a uint8_t as well, but it doesn't.

Thanks,

Brad


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net