I'm writing code for GPUs, so I can't use STL classes because methods need special annotations to run on the GPU. So, I'm reimplementing std::array
, with proper annotations (INLINE
) on its methods. The issue I have right now is my copy constructor calls the assignment operator on members:
template <typename T, Int n>
class Few {
T array_[n];
public:
INLINE Few(Few<T, n> const& rhs) {
for (Int i = 0; i < n; ++i) array_[i] = rhs.array_[i];
}
};
That works okay for simple T
, but there is a type for which this needs to call the copy constructor, not the assignment operator. How do I get the compiler to copy construct each element in the array ?
Aucun commentaire:
Enregistrer un commentaire