Boost logo

Boost :

Subject: Re: [boost] Is there a thin array wrapper/proxy lying around somewhere?
From: Jonathan Wakely (jwakely.boost_at_[hidden])
Date: 2013-11-25 18:01:49


On 25 November 2013 21:47, Mostafa wrote:
>
> I can't think of any TMP trick that would work around the array
> initialization issue. So the next best thing is to fake an array type. I
> think this is achievable. Do you see any alternatives?

So you want something that behaves exactly like an array except when
it doesn't. You're going to have to be a bit more precise about what
exactly you want.

In C++11 you can do this:

typedef int Arr3[3];

struct Foo
{
   Foo(int p1, std::initializer_list<int> p2, long p3) : m1(p1), m3(p3)
   { std::copy(p2.begin(), p2.end(), m2); }

   int m1;
   Arr3 m2;
   long m3;
};

Another option is just to provide a wrapper around std::array that
offers the implicit conversion to pointer.

If these aren't suitable then again, you need to be more precise about
what exactly you want, so far you're expecting answers to quite vague
questions.


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