Boost logo

Boost Users :

From: globeordi_at_[hidden]
Date: 2003-01-08 07:49:44


Hello all,

Just perhaps a silly question but who knows ?
I have a small class that encapsulates a char[] type such as:

template <const unsigned int n>
struct C_Array
{
  enum {
    size = n
  };

  typedef char (&Array)[size];
  typedef const char (&ConstArray)[size];

  C_Array()
  {
    memset(&v[0], 0, 30); v[0] = '6'; v[1] = '7'; v[2] = '8'; v[3] = '9';
  }

  char v[n];
  int toto;

  char & operator[](const unsigned int i) { return v[i]; }
  const char & operator[](const unsigned int i) const { return v[i]; }
  operator Array () { return v; }
  operator ConstArray () const { return v; }
};

Thanks to the operator Array, the objects of this class can be converted to
references to arrays and the following pseudo-code works fine as expected:

C_Array<30> obj;
cout << boost::is_convertible<obj, char[]>::value << endl;

But what I want to get is the actual size of the converted array. In the
example the size is 30.

It is not very important (workaround exists), just curious to see how it can be
done without telling to compiler more information.

Best regards

Joseph Canedo

 


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net