|
Boost : |
From: jsiek_at_[hidden]
Date: 2000-07-21 17:37:09
Right, the meta_assert is good when you can express the check as some
expression convertible to bool. The mechanisms in concept_checks.h are
more for ensuring that the components that get plugged-together really
do what they are suppose to.
BTW, the lambda library uses a ct_assert which is the same as
meta_assert.
Cheers,
Jeremy
Beman Dawes writes:
> Well, it got me going:-)
>
> How about something a bit simpler:
>
> template<bool Pred> struct meta_assert
> { int assertion_failure_in_meta_assert[Pred ? 1 : -1]; };
>
> template<> struct meta_assert<true> {};
>
> This actually works for BCC, MWCW, and MSVC compilers. The specialization
> has to be the <true> flavor for some of them. Steve Cleary introduced me
> to the negative subscript trick, IIRCC. Kevlin Henney has used a similar
> (or maybe the same?) technique in other boost postings.
>
> The usage inside a generator (where b is a compile time expression
> convertible to bool) is:
>
> meta_assert< b > use_name_as_error_message_surogate;
>
> It could also be used as a base class, but I haven't tested that.
>
> Would this be sufficient for template metaprogramming?
>
> --Beman
>
>
> ------------------------------------------------------------------------
> Special Offer-Earn 300 Points from MyPoints.com for trying @Backup
> Get automatic protection and access to your important computer files.
> Install today:
> http://click.egroups.com/1/6347/4/_/9351/_/964209717/
> ------------------------------------------------------------------------
>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk