Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-11-30 09:52:53


At 09:22 PM 11/29/99 -0500, Dave Abrahams wrote:

>> So how about it? I think we will have to eventually at least get
our feet
>> wet with compile-time meta-programming in the Boost library.
There are
>> several situations where it is very useful; the one that prompted
this post
>> is the one to automate specializations. By using the Platform
concept, we
>> can write one specialization for every builtin type, and only have
to change
>> the corresponding platform class when compilers offer more
extended types
>> (__int128 is coming!)
>>
>> The controversial subjects here are the use of meta-programming
and
>> compile-time asserts. Meta-programming has already been brought
up here,
>> with the consensus that we did not wish to pursue it for Boost at
this time.
>> Compile-time asserts have been thrown around a _lot_, with no
known solution
>> to the problems raised. The compile-time assert I include here is
the one I
>> use in my personal programming; it works with BCB4, but maybe
nothing else.
>> . .
>
>Personally, I would like to see more well-documented, peer reviewed
examples
>of this sort of work publicly available. So I support at least
discussing
>this proposal.

Steve Cleary, Kevlin Henney, and I discussed compile-time assert
variations in private email for awhile. I guess the fact that quite
a few people have independently developed some form of compile time
assert shows a perceived need.

One problem we ran into was that we wanted something which was not
subject to inadvertent misuse. For example, we had several
implementations of a "require" template class, which you could
inherit or instantiate:

   template<typename T>
   class foo : require< std::numeric_limits<T>::is_integer > {...};

The problem was that it could be misused:

   template<typename T>
   class foo
   {
       require< std::numeric_limits<T>::is_integer >;
   };

This code looks right, but is actually totally ineffective (because
it should have been coded "require<
std::numeric_limits<T>::is_integer > some_name;").

Any compile time assert should be bullet-proof, IMO.

--Beman


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