On Tue, 12 Mar 2013 11:25:54 -0400, deadalnix <[email protected]> wrote:

On Tuesday, 12 March 2013 at 10:49:57 UTC, monarch_dodra wrote:

Having "isInfinite" can also have the advantage of protecting users from stupid calls. For example, calling "count" on an infinite range is forbidden => shifting problems from runtime to compile time is a HUGE gain.


Clearly this is a good point. I however think that a static assert within count is much better because it allow to give nicer feedback. The problem with InfiniteRange is that it does gives you cryptic error message like the count function do not exists.


Hm... is there a way to test for inifinitness without requiring to be an enum?

Wouldn't this also be valid?

if(!R.init.empty)

Essentially, you can evaluate R.init.empty at compile time AND it's false on an uninitialized range. How can a correctly written non-infinite range pass that?

That would make forwarding much easier, as the 'dumb' implementation still would result in an infinite range.

-Steve

Reply via email to