Notes on software development (Windows) and computer system administration.

2005-08-30

Overuse of std::transform

Using std::transform on a simple, NULL-terminated string. This is a horrible perversion of what was simple -- if unattractive -- code:

template <typename t=""> T* ToLower (T* psz)
{
if (!psz)
return 0;

size_t size;

if (sizeof(T) == 1)
size = strlen((char *)psz);
else
size = wcslen((wchar_t *)psz);

std::transform(psz, psz + size, psz, tolower);

return psz;
}