<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Hi Philippe,</DIV>
<DIV>&nbsp;</DIV>
<DIV>thanks for the remarks</DIV>
<DIV>&nbsp;</DIV>
<DIV>&gt;1- I guess that&nbsp; when t is the empty string you should return true, not false: the empty string is present in any string.</DIV>
<DIV>That is true, empty string is present in any string. But usually when I look for an empty substring it happens by mistake. On other hand, returning true is&nbsp;probably what most people would expect, so I tend to agree with you.</DIV>
<DIV><BR>&gt;2- the .found necessary to get the result could be hidden with a two-levels template:<BR>&gt;auto s = substring!("fun with gun", "run");<BR>I try to comply to the style of std.metastrigns, they do not do it there.</DIV>
<DIV>And when I see "auto s = substring!("fun with gun", "run");" I presume s is substring, not</DIV>
<DIV>boolean.</DIV>
<DIV>&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&gt;3- Maybe you could do a (string s, char c) version which casts the char into a string and look for it.<BR>Agree.</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">I would like to hear if people think that substring&nbsp;deserves to be in std.metastrings. Otherwise all this discussion is pointless.</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Thanks,</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Igor</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Philippe Sigaud &lt;philippe.sigaud@gmail.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Discuss the phobos library for D &lt;phobos@puremagic.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Sun, February 28, 2010 9:59:50 AM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [phobos] substring for std.metastrings<BR></FONT><BR>(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>&lt;<A href="mailto:curoles@yahoo.com" target=_blank rel=nofollow ymailto="mailto:curoles@yahoo.com">curoles@yahoo.com</A>&gt;</SPAN> wrote:<BR>
<DIV class=gmail_quote>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">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&nbsp; 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>&nbsp;&nbsp;&nbsp; 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></DIV></div><br>

      </body></html>