(no subject)

Feb 12, 2010 19:08

Herb Sutter, C++ guru and secretary and convener of the ISO C++ standards committee for over 10 years, has a cool page detailing a case insensitive string class on his web page - the same appears in his book Exceptional C++. It works well, and I use it in my libraries. Unfortunately, the Microsoft Visual C++ compilers generate a slew of warning messages relating to checked iterators when you try to use it.

If you google for how to remove them, everyone suggests disabling the messages entirely. But seriously, warning messages are your friends - ignore them at your peril. So yesterday, I thought I'd try to write a more surgical fix. Amazingly, I came up with something that actually works.

#ifdef _MSC_VER
namespace std {
template <> class _Char_traits_category_helper< ci_char_traits, true >
{
public:
typedef _Secure_char_traits_tag _Secure_char_traits;
};
} // namespace std
#endif // #ifdef _MSC_VER

Being pleasantly surprised, I thought I'd send Mr Sutter an email describing my adventures in this regard and he was enough of a gentleman to reply today saying he appreciated the note and was glad I found his material helpful.

Whether that's a polite way of saying "ew, well I guess you could..." I'm still not sure.
Previous post Next post
Up