We are going to implement two different custom string classes: lc_string and ci_string. The first class constructs lower case strings from any string input. The other class does not transform any string, but it can do case-insensitive string comparison:
- Let's include the few necessary headers first and then declare that we use the std namespace by default:
#include <iostream> #include <algorithm> #include <string> using namespace std;
- Then we reimplement the std::tolower function, which is already defined in <cctype>. The already existing function is fine, but it is not constexpr. Some string functions are constexpr since C++17, however, and we want to be able to make use of that with our own custom string trait class. ...