Just for the fun of it, I thought I would implement my own any class. When I finished, everything worked except for
any a="Hello World!"
The reason it didn't work is the type of the string literal is const char[13], and assigning const char[13] to another of that type is illegal. So, I was wondering if there was any template metaprogramming magic that could convert from T[][]...[] (any number of []'s) to T**...*, where the number of asterisks is the same as the number of brackets. And yes, I could just specialize for T[] and explicitly convert it to T*, but then it doesn't work for the rare use of T[][], or even T[][][].
I looked at boost any for help whenever I was stuck, although it's a bit difficult to read because of all the extra stuff meant to give it compatibility.
Actually, I guess that could work.
1 2
template<class T>
any& operator=(T* value);
If T was something like int[][][][] it would implicitly convert it to a pointer to int[][][] which is assignable. Thanks!