On Mon, Jul 23, 2012 at 1:44 PM, Chris NS <ibisbase...@gmail.com> wrote:
> And for the curious, what I mean by embedding assertions in the conditions > is quite literally what it sounds like: > > Range minPos ( Range ) ( Range R1 ) > if( is( inputRange!Range ) ) > assert( !isInfinite!Range, "minPos cannot operate on infinite ranges." ) Would it be possible to create a If / Assert template that returns (er, becomes) true if the condition is true, and static asserts if not ? template Assert(bool condition, string message) { static if (condition) enum Assert = true; else static assert(false, message); } void foo(T,U)(T t, U u) if (is(T == int) && Assert!(isIntegral!U, "U must be an integer type")) {} void main() { foo(1,"a"); } Seems to work (tm).