Reputation: 7809
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.
According to the documentation, CUDA 6.5 does not support static
members at all (Programming Guide, E.2.6.1. Data Members, no link available). CUDA 7.0 adds support for static const
members (http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#const-variables).
As long as I use CUDA 6.5, how could I replace the static const int
? #define
is probably not a good option, because templatization would no longer work as intended.
Upvotes: 1
Views: 383
Reputation: 1216
try with enums?
class Mesh{
public:
enum { DIM = 3 };
// several more constants declared as enums here
}
template <class M>
Coords{
public:
int c[M::DIM];
// some more members using enums of M here
}
Upvotes: 3