Re: Computer programmers' habits in electronics



On Thu, 22 Dec 2005 00:18:01 GMT, the renowned "Mike Young"
<boat042-spam@xxxxxxxxx> wrote:

>"Spehro Pefhany" <speffSNIP@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>news:77mjq1122eq9r4ho7f784ahpfp5l9l4htl@xxxxxxxxxx
>> Something like this? (ugh)
>>
>> #include <string.h>
>>
>> rev2(char * istring, int start, int fin)
>
>No. Something like this:
>
>#include <algorithm>
>
>void ReverseString(const char * pStr, size_t len = 0);
>void ReverseString(const char * pStr, size_t len)
>{
> if (!pStr) return;
> std::reverse(pStr, pStr + (len ? len : strlen(pStr)));
>}

Isn't that kinda cheating?

Hm... not so different from my one (aside from no reentrancy, of
course):


template<typename _RandomAccessIterator>
void
__reverse(_RandomAccessIterator __first, _RandomAccessIterator
__last,
random_access_iterator_tag)
{
while (__first < __last)
std::iter_swap(__first++, --__last);
}




Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@xxxxxxxxxxxx Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
.