Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-08-31 10:31:51


Paul Moore wrote:

>> PS: This codes works as expected under Metrowerks CodeWarrior,
fails
>> to compiler under Microsoft VC++, and hasn't been tried on any
other
>> compilers.
>
>As far as I can see, the MSVC issue is the use of both template and
>non-template versions of assertion(). Splitting the two by usage,
say
>as assertion_always() and assertion<flag>(), seems to cause MSVC
(6.0,
>SP2) to accept the code.

Giving the non-template version a different name would make it clear
that the assertion is always on. But maybe it wouldn't be that bad a
thing to not provide the non-template version at all. Then you would
write assertion<true>(...) or maybe assertion<always>(...).

The real question is whether to stick with assert() or try to develop
something along the lines of assertion<>(). It seems to me that
assertion<>() meets identified needs:

   * Code usually optimized away if not active.
   * As much or as little activation granularity as desired by user.
   * Reports failure via exception.
   * Separates activation condition from assertion condition.
   * Avoids ODR violations.
   * Avoids possibly harmful macro usage.

Needs identified so far that assertion<>() doesn't meet :

   * Reporting of file and line.
   * Parameterization of exception type.

Perhaps those last two can also be addressed. Something to work
towards.

--Beman

    


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