(hmm, first time post there. Hello, I'm mostly human and mostly harmless).<br><br>On Fri, Feb 26, 2010 at 11:45, Igor Lesik <span dir="ltr"><<a href="mailto:curoles@yahoo.com">curoles@yahoo.com</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I believe, I have a function that is good candidate to be in std.metastrings.<br>
Feedback is appreciated.<br>
<br></blockquote><div><br>Hi Igor,<br><br>Some remarks:<br><br>1- I guess that when t is the empty string you should return true, not false: the empty string is present in any string. So your first static if should be cut in two.<br>
<br>2- the .found necessary to get the result could be hidden with a two-levels template:<br><br>template substring(string s, string t)<br>{<br> enum bool substring = substringImpl!(s,t).found;<br>}<br><br>and rename your substring into substringImpl. Then you can do:<br>
<br>auto s = substring!("fun with gun", "run");<br><br>I don't know if you can put substringImpl as a private template inside substring?<br><br>3- Maybe you could do a (string s, char c) version which casts the char into a string and look for it.<br>
<br><br>Philippe<br><br></div></div>