Re: Are _T() and TEXT() macros equivalent?
On Mon, 09 Apr 2007 23:32:11 -0700, "Mihai N." <nmihai_year_2000@yahoo.com>
wrote:
// all these tests should succeed.
// some of these tests are rather simplistic (ie useless)
// in order to ensure that they compile on all platforms.
No, this is dumb.
If something is "in order to ensure that blah," then it is not useless.
That assert ensures nothing, it is useless and brainless.
To me it feels more like "I am clueless, but instead of checking the
standard it is easier to put an assert"
The problem is that boost pretends to have higher standards.
If they're doing what you think they're doing, they are doing a woefully
incomplete job of it. I mean, why stop with:
BOOST_STATIC_ASSERT(sizeof(int) >= sizeof(short));
Why not order all the integer types, the FP types, etc etc etc? Maybe this
seemingly inane assertion has another purpose?
I'm not familiar with the code, so I can only infer the intent, but I think
you've missed the point. They are asserting things they know to be true per
the language definition in a variety of contexts as a test of their
assertion mechanism. I guess I should have said, "Look at all the
comments", not just the one I quoted, including those preceding the
assertions:
// Namespace scope
// Function (block) scope
private: // can be in private, to avoid namespace pollution
// Member function scope: provides access to member variables
// Template class scope
// Template member function scope: provides access to member variables
void test_Bill() // BOOST_CT_ASSERTs are not triggerred until instantiated
I would guess the reason they do two different, guaranteed true
BOOST_STATIC_ASSERTs in each scope has to do with it declaring a typedef
for an array type whose size is determined by the truth of the assertion,
and you need to make sure you can have multiple valid ones in each scope so
you don't stop the compilation for no reason. I haven't looked at the
definition of BOOST_STATIC_ASSERT, but that's an old trick to perform a
compile-time assertion of things you can't test during preprocessing.
In any event, none of this changes the fact that sizeof(char) == 1 by
definition. If you have doubts about that, consult the standard.
--
Doug Harrison
Visual C++ MVP