templated find() working with static arrays, seeking help on.

David L. Davis SpottedTiger at yahoo.com
Sat Jul 15 14:04:04 PDT 2006


In article <e9bfs2$1mo8$1 at digitaldaemon.com>, Oskar Linde says...
>
>In article <e9b555$19es$1 at 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

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. :)

# static if (!is(T == char) && !is(T == wchar) && !is(T == dchar) )
# {
#     // Set iLen for a char[x] static array
#     const int iLen = T.sizeof; //v.length; <-need to use this value
#
#     // Set iLenW for a wchar[x] static array
#     static if (T.sizeof > 2)
#         const int iLenW = T.sizeof / 2;
#     else
#         const int iLenW = 0;
#
#     // Set iLenW for a dchar[x] static array
#     static if (T.sizeof > 4)
#         const int iLenD = T.sizeof / 4;
#     else
#         const int iLenD = 0;
# }
# else
# {
#     const int iLen  = 0;
#     const int iLenW = 0;
#     const int iLenD = 0; 
# }

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.html



More information about the Digitalmars-d-learn mailing list