|
Boost : |
Subject: Re: [boost] [boost::endian] Request for comments/interest
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-06-03 10:56:53
Terry Golubiewski wrote:
> Robert Stewart wrote:
> > Terry Golubiewski wrote:
> > > Robert Stewart wrote:
> > > > Terry Golubiewski wrote:
>
> >> I could make it more helpful; but then it would be called
> >> swap_in_place and would be implemented just like Tomas'!
> >
> > Yours would still be in terms of the endian types.
>
> What inteface would you suggest?
One that takes the raw pointer directly to avoid the reinterpret_cast in user code.
> >> >> --- 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.
> >
> > I don't think that's right. The copy is done in
> > interface::copy(), but the conversion (swap) doesn't occur
> > until you read from the endian objects, right?
>
> Not right. 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.
OK, I misunderstood what you were doing in interface::copy().
_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk