Reputation: 59
I'm fairly new to C++, so I'm not sure what I'm doing wrong.
This is my construct:
Struct
template<size_t N> struct Offsets
{
static const int length = N;
DWORD offsets[N];
};
And the property:
template <size_t N>
std::map<std::string, std::map<DWORD, Offsets<N>>> pointers;
This results in a
Compiler Error C1001.
Whats wrong with that?
Upvotes: 1
Views: 126
Reputation: 3185
You can't use a template on a variable. If you want to keep pointers flexible encapsule it in a template class or struct.
template< size_t N >
class PointerOffsetMap
{
...
public:
std::map<std::string, std::map<DWORD, Offsets<N>>> pointers;
}
just a very simple example, you should probably make pointers private and add some access functions to get a nice interface.
Upvotes: 1
Reputation: 409176
Variables can't be templated, they have to fully specified. So to declare your pointers
variable you must specify the N
.
Upvotes: 3