Boost logo

Boost Users :

Subject: Re: [Boost-users] How to find: best integer type for processor
From: Francesco Biscani (bluescarni_at_[hidden])
Date: 2008-10-30 13:56:36


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Cory Nelson wrote:
> Most things don't need 64-bit ints, so it would just be wasting memory
> to use them if 32-bit ints are as fast or faster. This is why "int"
> stays 32-bit on most x64 ABIs.
>
> If you want the largest native integer, though not 100% portable to
> weird archs, this should work in x86/x64 and most others:
>
> typedef boost::int_t<sizeof(void*) * 8>::fast fastint_t;
>

I use this approach when I need the maximum "fast" integer type. If you
are really paranoid about the pointer/fast integer size ratio not being
1, you can add a BOOST_STATIC_ASSERT somewhere to prevent compilation on
weird archs.

  Francesco.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkJ9VQACgkQFCtI0YdDCEthfgCeOtSG862w6LO2pLdIErmClZ95
VsMAoJ5OY/Fz3tgBzcjbnPdmgVl25JtW
=svbV
-----END PGP SIGNATURE-----


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