Sophisticated constraint checks

Chris Jefferson caj@cs.york.ac.uk
Thu Mar 3 19:46:00 GMT 2005


Stephen M. Webb wrote:
> Hello all
> 
> I'm beavering away trying to implement the TR1 [5.1] random stuff and I need 
> to add a number of constraint checks.  I'm using concept requirements where 
> possible and __enable_if<> where I need to constrain a templated type based 
> on a type trait, but I need more.
> 
> First, some functions have strict constraints on input domain at runtime, 
> which to me says throw an exception but TR1 seems to forbid this.  Is using 
> _GLIBCXX_DEBUG_ASSERT() to raise an assertion only in debug mode really the 
> best that can be done?
> 
I think thats what is done in other places. Without looking at the 
specific section, in general C++ assumes if you give invalid input to a 
function, invalid behaviour occurs, but it's nice to put a debugging 
check in.

Chris



More information about the Libstdc++ mailing list