I have the following struct:
struct A {
std::string data;
bool flag;
};
I want users of my class to be able to use it like a string in most cases. This means the ==
operator, iterators, []
indexing, etc. I'd have to write a bunch delegating methods for that. But instead I could do this:
struct A : std::string {
using std::string::string; // Bring in all constructors.
bool flag;
};
Does this have any downsides?