jeudi 26 octobre 2017

Type alias for function arguments in C++

I have a function like this:

template <typename P1, typename... Ps> constexpr auto pipe(P1 &&proc1,
  Ps &&...procs) -> Cont<Cont<
    Proc<typename RevProc<P1>::ArgType,
      typename RevProc<typename Last<Ps...>::Type>::RetType>>> {
  using T = typename RevProc<P1>::ArgType;
  using U = typename RevProc<P1>::RetType;
  using V = typename RevProc<typename Last<Ps...>::Type>::RetType;
  return [&] (Cont<Proc<T, V>> &&pass) {
    pipe(move(procs)...)([&] (Proc<U, V> &&proc2) {
      pipe(move(proc1), move(proc2))(move(pass));
    });
  };
}

As you may find out that the type declaration is duplicated. Is there any chance to give this function a signature like:

template <typename P1, typename... Ps> constexpr auto pipe(P1 &&proc1,
  Ps &&...procs) -> Cont<Cont<Proc<T, V>>>

and define T and V at some proper position?

Aucun commentaire:

Enregistrer un commentaire