With template classes and template bases it becomes complicated to nominate the types, I often add private typedefs such as Base
and This
for use later:
template<typename T>
class A : public B<Something<T>> {
private:
typedef B<Something<T>> Base;
typedef A<T> This;
public:
// .......
Q: is there a way to "get" This
without defining it? This would seem like a very unambigous requirement, but maybe it's not.
I'm asking for C++17, but useful to know for later dialects as well.
In case you need a use-case, I am using This
in a construct like the following (which is itself a workaround for something else):
private:
auto somethingComplicated() const {
return std::make_tuple(.........);
}
decltype(std::declval<This>().somethingComplicated()) field = somethingComplicated();