C++ Logo

std-proposals

Advanced search

Re: std::tree

From: Magnus Fromreide <magfr_at_[hidden]>
Date: Sat, 6 Feb 2021 13:56:40 +0100
On Fri, Feb 05, 2021 at 01:41:39PM -0500, Brian Bi via Std-Proposals wrote:
> On Fri, Feb 5, 2021 at 1:33 PM Marcin Jaczewski via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> > pt., 5 lut 2021 o 19:17 Jason McKesson via Std-Proposals
> > <std-proposals_at_[hidden]> napisaƂ(a):
> > >
> > > On Fri, Feb 5, 2021 at 1:09 PM Magnus Fromreide via Std-Proposals
> > > <std-proposals_at_[hidden]> wrote:
> > > >
> >
> > If I understand correctly, the goal is to have set like class that has
> > a deterministically computed key,
> > but this key is not included in this class directly.
> >
>
> If I'm not mistaken, you can already do that:
>
> > > > struct something { ... type getSomeAspect(); ... };

> std::set<something, decltype([](const something& s1, const something& s2) {
> return s1.getSomeAspect() < s2.getSomeAspect(); })> S;
>
> In fact this is pretty similar to the OP's usage example for the proposed
> std::tree.

It looks similar but here key_type of the container is "something" rather than
"type".

> Seems like a more fleshed-out motivating example is needed.

Yes. It seems you are right.

/MF

Received on 2021-02-06 06:56:48