
On Tue, Jun 14, 2011 at 8:23 AM, Michael Goldshteyn <mgoldshteyn@comcast.net
wrote:
What is the correct way of getting several character arrays into a variant:
// This doesn't work typedef boost::variant<int,char[256],char[8192]> MyType;
And it is odd looking. IIRC the problem is that those two array types decay to char*. // This does, but seems like a lot of work
template <int len> struct MyChar { char val_[len]; };
typedef boost::variant<int,MyChar<256>,MyChar<8192> > MyType;
What is the best way to do this?
This variant<int, boost::array<char, 256>, boost::array<char, 8192> > is what you've got above minus some wheel-reinventing, but IIRC the variant always carries enough storage around with it to store the largest type in its argument list (see make_storage)... so you won't save space with this, if that is your intention. Troy