What type does byGrapheme() return?
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Dec 31 21:22:12 UTC 2019
On Tue, Dec 31, 2019 at 04:02:47PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote:
> On 12/31/19 2:58 PM, H. S. Teoh wrote:
> > On Tue, Dec 31, 2019 at 09:33:14AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote:
> > > e.g.:
> > >
> > > writeln(" Text = ", gr1.map!((ref g) => g[]).joiner.to!string);
> > [...]
> >
> > Unfortunately this doesn't work. Somehow the ref parameter doesn't
> > match whatever it is std.algorithm.map is trying to pass to it.
>
> Huh, it seemed to work for me. Got the full "Robert" with an R. map
> does support ref-ness. Maybe you didn't put ref in the right place?
Here's my full non-working code:
import std;
void main() {
auto x = "Bla\u0301hbla\u0310h\u0309!";
auto r = x.byGrapheme;
writefln("%s", r.map!((ref g) => g[]).joiner.to!string);
}
The compiler says:
/usr/src/d/phobos/std/algorithm/iteration.d(604): Error: template D main.__lambda1 cannot deduce function from argument types !()(Grapheme), candidates are:
test.d(5): __lambda1
/usr/src/d/phobos/std/algorithm/iteration.d(499): Error: template instance test.main.MapResult!(__lambda1, Result!string) error instantiating
test.d(5): instantiated from here: map!(Result!string)
What did I do wrong?
T
--
What do you get if you drop a piano down a mineshaft? A flat minor.
More information about the Digitalmars-d-learn
mailing list