mirror of
https://github.com/dlang/phobos.git
synced 2025-05-04 17:11:26 +03:00
Merge pull request #8685 from burner/filter_static_assert_message
Better std.algorithm.iteration.joiner error messages
This commit is contained in:
commit
b77c739643
2 changed files with 25 additions and 3 deletions
8
changelog/joiner_assert_message.dd
Normal file
8
changelog/joiner_assert_message.dd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Better static assert messages for `std.algorithm.iteration.joiner`
|
||||||
|
|
||||||
|
Up until now `filter` used a template constraint to check if the passed Data
|
||||||
|
could be used. If it were not, it was very tedious to figure out why.
|
||||||
|
|
||||||
|
As the template constraint is not used to overload the symbol template
|
||||||
|
function, the constrains are move into static asserts with expressive error
|
||||||
|
messages.
|
|
@ -2969,10 +2969,24 @@ iterated from the back to the front, the separator will still be consumed from
|
||||||
front to back, even if it is a bidirectional range too.
|
front to back, even if it is a bidirectional range too.
|
||||||
*/
|
*/
|
||||||
auto joiner(RoR, Separator)(RoR r, Separator sep)
|
auto joiner(RoR, Separator)(RoR r, Separator sep)
|
||||||
if (isInputRange!RoR && isInputRange!(ElementType!RoR)
|
|
||||||
&& isForwardRange!Separator
|
|
||||||
&& is(ElementType!Separator : ElementType!(ElementType!RoR)))
|
|
||||||
{
|
{
|
||||||
|
static assert(isInputRange!RoR, "The type of RoR '", RoR.stringof
|
||||||
|
, " must be an InputRange (isInputRange!", RoR.stringof, ").");
|
||||||
|
static assert(isInputRange!(ElementType!RoR), "The ElementyType of RoR '"
|
||||||
|
, ElementType!(RoR).stringof, "' must be an InputRange "
|
||||||
|
, "(isInputRange!(ElementType!(", RoR.stringof , "))).");
|
||||||
|
static assert(isForwardRange!Separator, "The type of the Seperator '"
|
||||||
|
, Seperator.stringof, "' must be a ForwardRange (isForwardRange!("
|
||||||
|
, Seperator.stringof, ")).");
|
||||||
|
static assert(is(ElementType!Separator : ElementType!(ElementType!RoR))
|
||||||
|
, "The type of the elements of the separator range does not match "
|
||||||
|
, "the type of the elements that are joined. Separator type '"
|
||||||
|
, ElementType!(Separator).stringof, "' is not implicitly"
|
||||||
|
, "convertible to range element type '"
|
||||||
|
, ElementType!(ElementType!RoR).stringof, "' (is(ElementType!"
|
||||||
|
, Separator.stringof, " : ElementType!(ElementType!", RoR.stringof
|
||||||
|
, "))).");
|
||||||
|
|
||||||
static struct Result
|
static struct Result
|
||||||
{
|
{
|
||||||
private RoR _items;
|
private RoR _items;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue