samedi 30 avril 2016

How to detect if operator[] applicable to Type?

I would like to write function template like

template< typename T >
void foo( T& obj ){
    obj[0] = xxxxxx;
}

where T must have operator[] applicable.
T may be array of any type, std::vector, std::array, or any other type. So, I cannot use T as superclass of all of them. I think it should be something like in std::type_traits style.

Aucun commentaire:

Enregistrer un commentaire