Boost logo

Proto :

Subject: Re: [proto] Active operator/function generation checking
From: Eric Niebler (eric_at_[hidden])
Date: 2011-01-30 22:38:04


On 1/31/2011 2:55 AM, Joel Falcou wrote:
> I'm trying to polish the last layer of compile time error handling in nt2.
> my concern at the moment is that, if have a function foo(a,b) that works
> on any real a and any char b, i dont want my foo function working on nt2
> container to work with nothing but matrix of real and matrix of char.
> nt2 has a is_callable_with metafunction that basically check for this on
> the scalar
> level.
>
> Considering the huge amount of functions nt2 has to support and their
> complex type requirement,
> grammar are a bit unusable here.
>
> Is it OK to have a custom nt2 generator that basically static_assert
> over is_callable_with
> to prevent wrong container expression to be built and hence ends up in
> error waaaaaay far in the
> expression evaluation code ?

This is a judgment call that only you, as library author, can make. If
doing the checking early imposes too high a compile-time requirement,
then it may make sense to delay it until it's less expensive to do, and
accept worse error messages.

You might also consider a "debugging mode" controlled with a compiler
switch, where things are checked up-front. Just a suggestion.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Proto list run by eric at boostpro.com