Skip to content

Instantly share code, notes, and snippets.

@EricWF
Created July 4, 2017 23:26
Show Gist options
  • Save EricWF/f3540556d8ff08efe73edfb271c37bfb to your computer and use it in GitHub Desktop.
Save EricWF/f3540556d8ff08efe73edfb271c37bfb to your computer and use it in GitHub Desktop.
class A {
class DecodingState;
class B;
};
template <class> struct ReturnTypeHelperImp;
template <class S, class R> struct ReturnTypeHelperImp<R(S::*)()> {
using type = R;
};
template <class T> using ReturnTypeHelper = typename ReturnTypeHelperImp<T>::type;
class A::DecodingState {
void Enter();
protected:
template <class S> ReturnTypeHelper<decltype(&S::Enter)> SetState();
};
class A::B : DecodingState {
void Step();
};
void A::B::Step() { SetState<DecodingState>(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment