vendredi 3 juillet 2015

static const int in CUDA for a templated code

I have the following code snippet:

class Mesh{
  public:
    static const int DIM = 3;
    // several more static constants here
}

template <class M>
Coords{
  public:
    int c[M::DIM];
    // some more members using static constants of M here
}

And I would instantiate some coords with:

Coords<Mesh> coords;

Now this basically works good for me.

BUT I run into enormous problems when I try to compile this for CUDA, since it does not allow static members... The only workaround I can think of is to use preprocessor constants by #define, but then I can no longer templatize Coords.

Is there a way to solve my problem while still keeping the templatization?

Aucun commentaire:

Enregistrer un commentaire