Boost logo

Boost :

Subject: [boost] Holding char arrays in boost variants, what is the correct way?
From: Michael Goldshteyn (mgoldshteyn_at_[hidden])
Date: 2011-06-14 11:23:13


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;

// 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?

Thanks,

Michael Goldshteyn


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk