If I have e.g.:
template <class T>
class MyOptional { /*...*/ };
I know that I can define a specialization e.g. for T = bool
which will have a different (separate) implementation:
template <> class MyOptional<bool> { /*...*/ };
But is it possible to say that this T=bool
specialization equals to another type (e.g. MyOptBool
)?
Something like this:
class MyOptBool { /*...*/ };
using Optional<bool> = MyOptBool; /* impossible but looking for similar functionality */
The only think I have found is using inheritance:
class MyOptBool { /*...*/ };
template <> class MyOptional<bool> : public MyOptBool {
using MyOptBool::MyOptBool;
};
1st question: Is there any more elegant solution? (just for curiosity + I have some conversion issues, etc.).
2nd question: Is the "workaround" using inheritance for declaring two classes equal commonly used (in some important libraries, etc.)?