mercredi 21 novembre 2018

Is there a c++ trait to find the most restricted type between two types in C++?

I would like a type trait common

so that

common<int,int>::type              -> int
common<const int, int>::type       -> const int
common<int, int &>::type           -> int
common<int &, int &>::type         -> int &
common<int &, int const &>::type   -> int const &

that is the result type should be the more restricted of the two. Is there a trait in the C++11 std that can do this or do I have to roll my own?

Aucun commentaire:

Enregistrer un commentaire