Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2000-02-25 07:38:51


Steve -
 
>So let's try. . . um. .
>. function declarations!<

Dare I admit this? My thought process went like this -

1) use annomimous structs - compiler complained and I got tones of
errors/warnings
2) use function declarations - works like a treat in g++, but neither
Builder 4/5 nor MSVC can handle this (loads of errors), I'm not sure if
these are compiler bugs, or just different interpetations of the standard,
C++ Builder seems to check everything at the very last moment and that
means that default arguments are only instantiated at point of use - which
means the assert has no effect - unless its in a function body in which
case both VC6 and C++ Builder choke badly. Also, I can imagine function
scope function declarations being depreciated - it catches too many people
out, and some compilers (Borland and MSVC) don't seem to handle this
correctly now.
3) Use enum's (last post).

I'm not saying that enums are perfect (they're not) or that they give great
error messages (they don't), but they do seem to be well supported, and
give reasonable messages.

WRT static: I'm not sure about this - as things stand a name collision can
only occur if:

1) two assert are placed on the same line (don't do that).
2) two asserts are placed on the same line in separate headers, both at the
same namespace scope, IMO the best approach is to insist that use of
ct_asserts at namespace scope is along these lines:

namespace boost {
namespace my_file_asserts{

BOOST_CT_ASSERT(sizeof(int) == 4)
BOOST_CT_ASSERT(sizeof(char) == 1)

} // namespace

/* code goes here */

} namespace

I have to admit though, it's the best of a bad job so to speak, what would
be really nice is compiler support :-)

- John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk