Due to the need to be able to reference unicode character groups in a header only implementation, I want to declare all the arrays first. Templates allow me to initialize static members in the header, but the code looks messy.
This is just two of the twenty or so groups:
struct CharacterClass
{
struct Value
{
int l;
int h;
};
};
template < int N >
struct Nd : public CharacterClass
{
static const Value v[];
};
template< int N >
const typename Nd< N >::Value Nd< N >::v[] = {
{ 0x00030 , 0x00039 }, { 0x00660 , 0x00669 }, { 0x006f0 , 0x006f9 }, { 0x007c0 , 0x007c9 }, { 0x00966 , 0x0096f },
{ 0x009e6 , 0x009ef }, { 0x00a66 , 0x00a6f }, { 0x00ae6 , 0x00aef }, { 0x00b66 , 0x00b6f }, { 0x00be6 , 0x00bef },
{ 0x00c66 , 0x00c6f }, { 0x00ce6 , 0x00cef }, { 0x00d66 , 0x00d6f }, { 0x00e50 , 0x00e59 }, { 0x00ed0 , 0x00ed9 },
{ 0x00f20 , 0x00f29 }, { 0x01040 , 0x01049 }, { 0x017e0 , 0x017e9 }, { 0x01810 , 0x01819 }, { 0x01946 , 0x0194f },
{ 0x019d0 , 0x019d9 }, { 0x01b50 , 0x01b59 }, { 0x0ff10 , 0x0ff19 }
};
template < int N >
struct Nl : public CharacterClass
{
static const Value v[];
};
template< int N >
const typename Nl< N >::Value Nl< N >::v[] = {
{ 0x016ee , 0x016f0 }, { 0x02160 , 0x02182 }, { 0x03007, 0x03007 }, { 0x03021 , 0x03029}, { 0x03038 , 0x0303a }
};
Q1: Is it possible to declare the array once in a base class without having to repeat it for each derived type?
Q2: How can I hide the dummy 'int N', so that I can later reference the structs without having to add the template parameter? ie. int x = Nd.v[10].l;
Q3: Is there a better way of doing this?