I have a CRTP hierarchy, where the child defines a type to be used by the Parent, but that type has a callback in to the Parent:
template<template<class> class CALLBACK>
class Option1
{
};
template<class SUB>
class Parent
{
using ThisClass = Parent<SUB>;
typename SUB::template Sender<ThisClass> _osm;
};
class Child : public Parent<Child>
{
using Sender = Option1;
};
int main()
{
Child rm;
}
I thought I could use template template parameters to solve this but I still get compiler errors:
<source>:15:28: error: no member named 'Sender' in 'Child'
Is it possible to achieve this?
You can't do it directly because
SUBinParentis an incomplete type, but you can use type traits technique and putSendertype into a separate helper struct:This works because
GetSenderdoesn't need a completeSub.