Bug 21582 – ApplyLeft fails with some function templates

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-01-25T19:34:20Z
Last change time
2024-12-01T16:38:17Z
Assigned to
No Owner
Creator
John Colvin
Moved to GitHub: phobos#9815 →

Comments

Comment #0 by john.loughran.colvin — 2021-01-25T19:34:20Z
import std.meta : ApplyLeft; alias orIfNull = ApplyLeft!(orIf, x => x is null); auto ref orIf(alias test, T0, T1)(auto ref T0 v, auto ref T1 def) { return test(v) ? def : v; } alias orIfNull2 = ApplyLeft!(orIf2, x => x is null); template orIf2(alias test) { auto ref orIf2(T0, T1)(auto ref T0 v, auto ref T1 def) { return test(v) ? def : v; } } auto foo() { string s; auto a = s.orIfNull(""); // fails in std.meta auto b = s.orIfNull2(""); // ok } full error: /dlang/dmd/linux/bin64/../../src/phobos/std/meta.d(1297): Error: template instance Template!((x) => x is null) does not match template declaration orIf(alias test, T0, T1)(auto ref T0 v, auto ref T1 def) onlineapp.d(19): Error: template instance onlineapp.ApplyLeft!() error instantiating onlineapp.d(19): Error: template onlineapp.ApplyLeft!(orIf, (x) => x is null).ApplyLeft cannot deduce function from argument types !()(string, string), candidates are: /dlang/dmd/linux/bin64/../../src/phobos/std/meta.d(1297): ApplyLeft(right...)
Comment #1 by robert.schadek — 2024-12-01T16:38:17Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9815 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB