Boost logo

Boost :

Subject: Re: [boost] [boost::endian] Request for comments/interest
From: Terry Golubiewski (tjgolubi_at_[hidden])
Date: 2010-06-03 11:45:39


>> >> >> --- typed based ---
>> >> >> for (int trial=0; trial != 1000; ++trial) {
>> >> >> {
>> >> >> ifstream input("array.dat", ios::binary);
>> >> >> input.read(reinterpret_cast<char*>(&tmp_array),
>> >> >> sizeof(tmp_array));
>> >> >> interface::copy(tmp_array.begin(), tmp_array.end(),
>> >> >> array2.begin());
>> >> >
>> >> > Does this actually swap anything? Doesn't this just copy
>> >> > the data to unswapped objects that *would* swap on access?
>> >> > That's hardly a fair comparison.
>> >>
>> >> array2 is just a plain array<uint32_t, SIZE>. tmp_array is an
>> >> array<endian<big, uint32_t>, SIZE>. So the conversion/copy
>> >> happens in interface::copy.
>> >
>> ... The conversion happens inside of interface::copy which is
>> performing a *swap-in-place* in this example. After the call to
>> interface::copy, array2 is in native-endian format.

Correction: the above example does not do a conversion-in-place.
It does a conversion/copy. Sorry for any confusion.

terry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk