I have a variable of type Blah
.
I want to cast it to char[sizeof(blah)]
, without copying.
I need the type cast to be strong enough to instantiate a template that expects char[N]
.
I've tried many things, but i can't quite get it.
I want something like this to work correctly:
class Blah {
int a;
};
template <typename T>
void foo (T& a)
{
//Not an array
}
template <int N>
void foo (char(&a)[N])
{
//an array!
}
Blah b;
foo(b); //not an array
foo((char[sizeofBlah])b); //hopefully treated as an array