How to realize isSortedRange?

Alexandr Druzhinin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 19 23:43:52 PDT 2014


I need to ensure that range passed to function is SortedRange to use 
binary search. I did something like:

static if(!__traits(compiles,
	{
		ElementType!(typeof(data)) element;
		auto d = data.trisect(element);
	}
	)) assert(0, "DataRange shall be SortedRange");

It works for me, but in fact it checks if the type of 'data' have 
'trisect' method and conception of SortedRange is something more than 
having 'trisect' method.
	I remember there is(?) some way to get general type of template (i.e. 
SortedRange instead of SortedRange!int), but can not find it.


More information about the Digitalmars-d-learn mailing list