C++ Logo

std-proposals

Advanced search

Re: More general version of const_iterator

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 02 Mar 2020 15:17:45 -0800
On Monday, 2 March 2020 13:25:45 PST Marcin Jaczewski via Std-Proposals wrote:
> In my recent work I stumbled on problem that I need have two types
> that have same members but different `const`-nes of them:
>
> ```
> class C
> {
> X* a;
> X* b;
> Y* c;
> };
>
> class C_const
> {
> const X* a;
> const X* b;
> const Y* c;
> };
> ```

Note that this is pointer-to-const, not a const pointer.

Now, what do you suppose your const_inner proposal should do to:

struct C2
{
     std::unique_ptr<X> a;
};

struct C3
{
    std::vector<X> a;
};

struct C4
{
    std::vector<X>::iterator a;
};

struct C5
{
    std::unordered_map<X, Y> a;
};

struct C6
{
    std::aligned_union<8, X, Y>::type a;
}

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2020-03-02 17:20:31