Chapter 2. Case-Insensitive Strings—Part 1
Difficulty: 7
So you want a case-insensitive string class? Your mission, should you choose to accept it, is to write one.
This Item is composed of three related points.
What does “case-insensitive” mean?
Write a
ci_string
class that is identical to the standardstd::string
class but that is case-insensitive in the same way as the commonly provided extensionstricmp()
.[1] Aci_string
should be usable as follows:ci_string s( "AbCdE" ); // case insensitive // assert( s == "abcde" ); assert( s == "ABCDE" ); // still case-preserving, of course // assert( strcmp( s.c_str(), "AbCdE" ) == 0 ); assert( strcmp( s.c_str(), "abcde" ) != 0 );
Is making case sensitivity a property of the object a good idea?
Solution
The ...
Get Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.