
On 8/13/2010 12:44 PM, Kim Kuen Tang wrote:
Hi all,
the question might be not directly related to boost. But i just want to be sure that i am not reventing the wheel. I am searching for a macro that is able to detect that a system is 32bit or 64bit no matter what compiler is used. Is there something similar already implemented in boost?
Perhaps some background about this feature.
Template specialization for std::size_t is not needed, when the specialization already exists for unsigned int. But on a 64bit system this is not true. So you need explicitly added the specialization whenever a 64bit compiler is used.
See the following example.
# include <cstddef>
template<typename T> struct Null;
template<> struct Null<unsigned int> {}; template<> struct Null<std::size_t> {}; // compile only on a 64bit compiler
int main() { return 0; };
Thx for any comments, help or suggestions
Kim
Perhaps you should just specialize on std::size_t conditional on it being different from an unsigned int, rather than on 64bit-ness: template< class T, bool = boost::is_same< T, unsigned int >::value > struct Null2; template<> struct Null2< unsigned int, true > { ... }; template<> struct Null2< std::size_t, false > { ... }; template< class T > struct Null : Null2<T> { }; There might be a "cleaner" way to achieve the same effect, but does that help? - Jeff