dimanche 29 novembre 2015

C++ auto type deduction

I'm trying to do automatic type deduction but it should only work if the inputs are fields.

I have declared a function like this:

template<class C> C gettype();

And I use it like this:

template<class L, class R, int F = CField<L,R>::is>
struct AddType {
    typedef decltype (gettype<L>() + gettype<R>()) type;
};

but I get a plethora of errors:

  1. that getType cannot be used as a parameter.
  2. that the compiler expects a ';' at the call to decltype. and that I need type specifiers.

etc.

Am I missing a lib or am I thinking about this all wrong?

thanks in advance!

Aucun commentaire:

Enregistrer un commentaire