
--- John Maddock <john@johnmaddock.co.uk> wrote:
Just when I thought I had got away with that update!
I take it changing the static_cast to a C style cast doesn't do the job?
That's something I hadn't thought of. Unfortunately it doesn't help. See below. template <class T> struct is_signed_helper { static const bool value = ((T)(-1) < 0); }; % CC -n32 -mips4 -LANG:std -c foo.cpp cc-3314 CC: ERROR File = foo.cpp, Line = 4 The expression must have arithmetic, enum, or pointer type. static const bool value = ((T)(-1) < 0); ^ 1 error detected in the compilation of "foo.cpp". template <class T> struct is_signed_helper { static const T minus_one = static_cast<T>(-1); static const bool value = (minus_one < 0); }; % CC -n32 -mips4 -LANG:std -c foo.cpp cc-3314 CC: ERROR File = foo.cpp, Line = 5 The expression must have arithmetic, enum, or pointer type. static const bool value = (minus_one < 0); ^ 1 error detected in the compilation of "foo.cpp". template <class T> struct is_signed_helper { static const T minus_one = static_cast<T>(-1); static const bool value = (minus_one < 0 ? true : false); }; % CC -n32 -mips4 -LANG:std -c foo.cpp cc-3314 CC: ERROR File = foo.cpp, Line = 5 The expression must have arithmetic, enum, or pointer type. static const bool value = (minus_one < 0 ? true : false); ^ 1 error detected in the compilation of "foo.cpp". template <class T> struct is_signed_helper { static const T minus_one = static_cast<T>(-1); static const bool value = minus_one < 0 ? true : false; }; % CC -n32 -mips4 -LANG:std -c foo.cpp cc-3314 CC: ERROR File = foo.cpp, Line = 5 The expression must have arithmetic, enum, or pointer type. static const bool value = minus_one < 0 ? true : false; ^ 1 error detected in the compilation of "foo.cpp". template <class T> struct is_signed_helper { typedef T t_type; static const bool value = (static_cast<t_type>(-1) < 0); }; % CC -n32 -mips4 -LANG:std -c foo.cpp cc-3314 CC: ERROR File = foo.cpp, Line = 5 The expression must have arithmetic, enum, or pointer type. static const bool value = (static_cast<t_type>(-1) < 0); ^ 1 error detected in the compilation of "foo.cpp". template <class T> struct is_signed_helper { typedef T t_type; static const bool value = ((t_type)(-1) < 0); }; % CC -n32 -mips4 -LANG:std -c foo.cpp cc-3314 CC: ERROR File = foo.cpp, Line = 5 The expression must have arithmetic, enum, or pointer type. static const bool value = ((t_type)(-1) < 0); ^ 1 error detected in the compilation of "foo.cpp". // I am not sure about the validity of this one, but just // to show that the error persists: #include <functional> template <class T> struct is_signed_helper { static const bool value = std::less<T>()(static_cast<T>(-1), 0); }; % CC -n32 -mips4 -LANG:std -c foo.cpp cc-1028 CC: ERROR File = foo.cpp, Line = 6 The expression used must have a constant value. static const bool value = std::less<T>()(static_cast<T>(-1), 0); ^ cc-1059 CC: ERROR File = foo.cpp, Line = 6 A function call is not allowed in a constant expression. static const bool value = std::less<T>()(static_cast<T>(-1), 0); ^ 2 errors detected in the compilation of "foo.cpp". // This one works, but any attempt to convert -1 appears to be doomed to fail. template <class T> struct is_signed_helper { static const bool value = (-1u < 0); }; __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail