Error in trying to use an inout(char)[] with a regex
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Oct 16 19:31:32 PDT 2015
On 10/16/2015 07:06 PM, Shriramana Sharma wrote:
> /usr/include/dmd/phobos/std/regex/package.d(557): Error: variable
> std.regex.RegexMatch!(inout(char)[],
BacktrackingMatcher).RegexMatch._input
> only parameters or stack based variables can be inout
Reduced:
inout(char)[] foo(inout(char)[] text) {
import std.regex;
static auto inlineRE = ctRegex!`\$\(ta (.*?)\)`;
return text.replaceAll!(m => textAttr(m[1]))(inlineRE);
}
void main() {
}
This may be an oversight in the regex module that it may not be
well-tested with inout data. If others agree, please open a bug report.
Meanwhile, can you try the following template which works at least for
the reduced code:
import std.range;
auto foo(S)(S text)
if (isSomeString!S) {
import std.regex;
static auto inlineRE = ctRegex!`\$\(ta (.*?)\)`;
return text.replaceAll!(m => textAttr(m[1]))(inlineRE);
}
void main() {
}
Ali
More information about the Digitalmars-d-learn
mailing list