Boost logo

Boost Users :

From: Ryan Barrett (rbarrett_at_[hidden])
Date: 2003-04-21 16:48:01


check out boost's template metaprogramming library...i won't guarantee
anything, but you might be able to contort it to do what you need.

http://boost.org/libs/mpl/doc/index.html

-Ryan

-------------------------------
"...real recognize real."
        -Rakim

On Mon, 21 Apr 2003, Mike Wilson wrote:

> Hi,
>
> There is an application I use that always produces a little endian binary
> file.
> I have written a program to process this file.
> As my program can port to both little/big endian platforms I have a #define
> (LITTLE_ENDIAN_TARGET)
> acting as a flag for the necessary byte swapping that is needed on the
> big-endian platforms.
>
> I was wondering if there is a better way to do this, so I searched the Web &
> boost archives.
> I found the following code snippet in the boost archives.
>
> bool isLittleEndian() {
> int temp = 1;
> return (*(char*)&temp) != 0;
> }
>
> which is of some help (eliminating my #define).
>
> However, I was wondering if there is a PP or mpl way of testing for
> endian-ness at compile time.
>
> For example, I'd like to do something like the following:
>
> const bool IsLittleEndian = ..to be determined automatically..;
>
> I've got a gut feeling that I can't do the above at complile time, but maybe
> something like Wave may do the job?
>
> Thanks for any assistance in this matter.
>
> Mike
>
>
>
>
>
>
>
>
> Info: <http://www.boost.org>
> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>


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