Boost logo

Boost :

Subject: Re: [boost] Is there a thin array wrapper/proxy lying around somewhere?
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2013-11-25 16:47:33


On Mon, 25 Nov 2013 07:44:22 -0800, Steven Watanabe <watanabesj_at_[hidden]>
wrote:

> AMDG
>
> On 11/25/2013 01:22 AM, Mostafa wrote:
>>
>> Because it does not meet the stated requirements. For one, it doesn't
>> have operator+, two, it doesn't have the necessary implicit
>> conversion-to-pointer operator, three regular arrays can't be assigned
>> to, etc ...
>>
>> To be more clear, what is desired is a type that mimics all (well, I can
>> live with almost all [1]) the functionality of a regular array, no more,
>> no less.
>>
>> [1] Initialization with array initializor list might be impossible to do
>> in C++03.
>>
>
> If you want something that behaves exactly like an
> array, why can't you use an array?

<The previous posting was sent in error.>

typedef int Arr3[3];

struct Foo
{
    Foo(int p1, Arr3 & p2, long p3) : m1(p1), m2(p2), m3(p3) {}

    int m1;
    Arr3 m2;
    long m3;
};

1) The ctor for Foo is auto-generated.
2) The member variables of Foo are user inputs to the codegen.
3) Obviously Foo's current ctor won't compile because arrays are not copy
constructible.

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?

Mostafa


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