const usage with reintepret cast

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

I have a query. This might be basic but it will be nice if someone can 
explain why it doesnt work

I presumed that in the below code (which is in global scope) byte0 will be 
a const and i could use it as a template parameter. But the moment i try 
to use it as a template parameter i get an error like "non-constant 
`byte0' cannot be used as template argument"

const unsigned data =  0x41424344;
const unsigned char byte0 = reinterpret_cast<const unsigned 
char*>(&data)[0];

I get the error when i try to use it in some template like:

template<std::size_t s>
struct ab{
};

template<>
struct ab<byte0> {       //complains about the byte0 use here!!
};

Thanks in advance
---------------------------------------------------------------------------------------------------------
Warm Regards,
Suresh.T



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux