Better std.algorithm.iteration.permutations error messages

This commit is contained in:
Robert burner Schadek 2023-05-25 22:37:14 +02:00 committed by The Dlang Bot
parent 43be08c3a7
commit e1f7edae57
2 changed files with 18 additions and 2 deletions

View file

@ -7939,15 +7939,23 @@ See_Also:
$(REF nextPermutation, std,algorithm,sorting).
*/
Permutations!Range permutations(Range)(Range r)
if (isRandomAccessRange!Range && hasLength!Range)
{
static assert(isRandomAccessRange!Range, Range.stringof,
" must be a RandomAccessRange");
static assert(hasLength!Range, Range.stringof
, " must have a length");
return typeof(return)(r);
}
/// ditto
struct Permutations(Range)
if (isRandomAccessRange!Range && hasLength!Range)
{
static assert(isRandomAccessRange!Range, Range.stringof,
" must be a RandomAccessRange");
static assert(hasLength!Range, Range.stringof
, " must have a length");
private size_t[] _indices, _state;
private Range _r;
private bool _empty;