vendredi 24 avril 2015

Move semantics from one type to another

Is it possible to have a struct A with a move constructor for itself and some constructor which can move from other types (e.g struct B ) but with having a template deduction going on such that the type B is not hardcoded directly as another move constructor:

 struct A{
      A()= default;
      A(A&&a){ /* A's move constructor */ }

      template<typename T>
      A(T&&t){ 
        /* (not a move constructor! by std.) 
        move from some template deducted type 
        (meta programming to check if we can move the type) */
      } 


}

struct B{};

How does one achieve this?

Aucun commentaire:

Enregistrer un commentaire