digitalmars.D.learn - templated find() working with static arrays, seeking help on.
- David L. Davis (185/185) Jul 15 2006 I'm trying to build a module of templated std.string functions that allo...
- Oskar Linde (6/9) Jul 15 2006 see www.csc.kth.se/~ol/array.d for an implementation of find that I beli...
- David L. Davis (35/45) Jul 15 2006 Oskar thanks!
- Peter Neubauer (3/5) Jul 01 2007 That stuff is extremely useful for any project. Thanks!
- David L. Davis (196/196) Jul 15 2006 I thought for completeness, I'd post the full working example code. Just...
I'm trying to build a module of templated std.string functions that allows any character (char, wchar, or dchar) or string (void[], char[], wchar[], or dchar[]) as a parameters, which I'm current testing first with the std.string.find() function. And after a lot of pain, I'm like 90% in getting this to work. But currently I'm still trying to work pass the "Literal String / Static Array" issue where I need to get this line "const int iLen = v.length;" to set correctly. So, if anyone can help point to a way to solve this, it would be great (also today my birthday, and having been working on this darn thing for months off and on...it would be a great gift if someone could solve ths last remaining issue ;) ). Output setting iLen to a static 6, would like it to be dynmanic: ---------------------------------------------------------------- C:\dmd>dmd findtest1.d C:\dmd\bin\..\..\dm\bin\link.exe findtest1,,,user32+kernel32/noi; C:\dmd>findtest1 ti.toString=char[], typeid(T)=char[5], string literal falling thru! ti.toString=char[], typeid(T)=char[2], string literal falling thru! char[] sx1="23456", char[] sx2="34", find()=1 ti.toString=char[], typeid(T)=char[6], char[] section called! ti.toString=void[], typeid(T)=void[], void[] section called! char[] sx1="234567", char[] sx2="56", find()=3 ti.toString=wchar[], typeid(T)=wchar[6], wchar[] section called! ti.toString=void[], typeid(T)=void[], void[] section called! char[] sx1="234567", char[] sx2="56", find()=3 ti.toString=dchar[], typeid(T)=dchar[6], dchar[] called! ti.toString=void[], typeid(T)=void[], void[] section called! char[] sx1="234567", char[] sx2="56", find()=3 ti.toString=char[], typeid(T)=char[3], string literal falling thru! ti.toString=char, typeid(T)=char, char section called! char[] sx1="abc", char[] sx2="b", find()=1 ti.toString=char, typeid(T)=char, char section called! ti.toString=char, typeid(T)=char, char section called! char[] sx1="c", char[] sx2="c", find()=0 ti.toString=wchar[], typeid(T)=wchar[6], wchar[] section called! ti.toString=wchar[], typeid(T)=wchar[2], string literal falling thru! char[] sx1="123456", char[] sx2="4 5 ", find()=-1 ti.toString=char[], typeid(T)=char[], char[] section called! ti.toString=wchar[], typeid(T)=wchar[2], string literal falling thru! char[] sx1="2345", char[] sx2="4 5 ", find()=-1 ti.toString=wchar[], typeid(T)=wchar[], wchar[] section called! ti.toString=wchar[], typeid(T)=wchar[], wchar[] section called! char[] sx1="123", char[] sx2="123", find()=0 C:\dmd> Thanks in advance for any help given, David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
Jul 15 2006
In article <e9b555$19es$1 digitaldaemon.com>, David L. Davis says...I'm trying to build a module of templated std.string functions that allows any character (char, wchar, or dchar) or string (void[], char[], wchar[], or dchar[]) as a parameters, ...see www.csc.kth.se/~ol/array.d for an implementation of find that I believe works like you want. I am typing this from a mobile phone so I cant comment on your code... regards, Oskar
Jul 15 2006
In article <e9bfs2$1mo8$1 digitaldaemon.com>, Oskar Linde says...In article <e9b555$19es$1 digitaldaemon.com>, David L. Davis says...Oskar thanks! I looked over your code...and WOW! I can barely follow / understand half of it with all those alias and such. But my eyes did fall on a "T.sizeof" in your code, which helped me solve my issue! This is the fix I put in, it's not the sweetest piece of code...but it works. :) Thanks again for replying, David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.htmlI'm trying to build a module of templated std.string functions that allows any character (char, wchar, or dchar) or string (void[], char[], wchar[], or dchar[]) as a parameters, ...see www.csc.kth.se/~ol/array.d for an implementation of find that I believe works like you want. I am typing this from a mobile phone so I cant comment on your code... regards, Oskar
Jul 15 2006
Oskar Linde Wrote:see www.csc.kth.se/~ol/array.d for an implementation of find that I believe works like you want.That stuff is extremely useful for any project. Thanks! -Peter
Jul 01 2007
I thought for completeness, I'd post the full working example code. Just in case someone might find it useful now, or in the future. Output: ------------------------- C:\dmd>dmd findtest1.d C:\dmd\bin\..\..\dm\bin\link.exe findtest1,,,user32+kernel32/noi; C:\dmd>findtest1 ti.toString=char[], typeid(T)=char[5], char[] section called! ti.toString=char[], typeid(T)=char[2], char[] section called! char[] sx1="23456", char[] sx2="34", find()=1 ti.toString=char[], typeid(T)=char[6], char[] section called! ti.toString=void[], typeid(T)=void[], void[] section called! char[] sx1="234567", char[] sx2="56", find()=3 ti.toString=wchar[], typeid(T)=wchar[6], wchar[] section called! ti.toString=void[], typeid(T)=void[], void[] section called! char[] sx1="234567", char[] sx2="56", find()=3 ti.toString=dchar[], typeid(T)=dchar[6], dchar[] called! ti.toString=void[], typeid(T)=void[], void[] section called! char[] sx1="234567", char[] sx2="56", find()=3 ti.toString=char[], typeid(T)=char[3], char[] section called! ti.toString=char, typeid(T)=char, char section called! char[] sx1="abc", char[] sx2="b", find()=1 ti.toString=char, typeid(T)=char, char section called! ti.toString=char, typeid(T)=char, char section called! char[] sx1="c", char[] sx2="c", find()=0 ti.toString=wchar[], typeid(T)=wchar[6], wchar[] section called! ti.toString=wchar[], typeid(T)=wchar[2], wchar[] section called! char[] sx1="123456", char[] sx2="45", find()=3 ti.toString=char[], typeid(T)=char[], char[] section called! ti.toString=wchar[], typeid(T)=wchar[2], wchar[] section called! char[] sx1="2345", char[] sx2="45", find()=2 ti.toString=wchar[], typeid(T)=wchar[], wchar[] section called! ti.toString=wchar[], typeid(T)=wchar[], wchar[] section called! char[] sx1="123", char[] sx2="123", find()=0 C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
Jul 15 2006