C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Constructing C++ standard stuctures from equivalent types

From: Chris Gary <cgary512_at_[hidden]>
Date: Thu, 26 Oct 2023 20:12:46 -0600
Aren't you really looking for an intrusive container?
Sounds like you want to go the other way and call it a std::map.
Outside of explicit name coupling (things that want an std::map by name),
or dealing with allocator design issues, this defeats the purpose of the
container.
std::map might be an AVL tree, an RB tree, or something more exotic. Even
between AVL and RB trees, the requirements vary depending on who
implemented the thing.

On Thu, Oct 26, 2023 at 7:24 PM Smith, Jim via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Yes, I do mean the nodes of a data structure, for example, left or right
> node of a binary tree.
>
> So for example, if I wanted std::map to use my tree structure
> implementation certain features would be expected in my implementation that
> would allow std::map to use it, like a way to iterate over the nodes using
> accessible members and so on. That's what I meant by expected features.
>
> This would allow customization and additional features to be added by the
> developer and still use the standard library interface in code.
>
>
> -- James S.
>
>
> ------- Original Message -------
> On Monday, September 18th, 2023 at 2:28 PM, Jason McKesson via
> Std-Proposals <std-proposals_at_[hidden]> wrote:
>
>
> > On Mon, Sep 18, 2023 at 1:52 PM Smith, Jim via Std-Proposals
> > std-proposals_at_[hidden] wrote:
> >
> > > Hi All,
> > >
> > > I would like to simply pass my data structure to its std c++
> equivalent and have it construct from the given item or node.
> > >
> > > For example:
> > >
> > > auto& m = get_my_map();
> > > ...
> > >
> > > // Using type deduction here for m instead of passing to template
> would be
> > > std::map<int, std::string> m_map(m->node);
> > >
> > > so I'm proposing a constructor for the standard data structures that
> will take a node type from a given structure and use it to construct itself
> using existing nodes and expected features of the node type.
> > >
> > > Only the range constructors appear to be similar.
> >
> >
> > It is unclear to me what exactly you mean here. When you say "node
> > type", do you mean the actual `std::map::node_type` type? Or do you
> > mean "node type" in the vernacular sense of the term (some kind of
> > data structure with pointers to the other "nodes" in a graph of some
> > kind)?
> >
> > If it's the former, your request doesn't really make sense. The only
> > "expected features" of a `node_type` object are the ability to modify
> > both the key and value of the stored object and the ability to inject
> > it into a compatible container. There is no iteration functionality
> > that would allow it to get any "existing nodes" from a `node_type`.
> >
> > And if it's the latter, then you need to be more specific as to what
> > the "expected features" of this interface are intended to be.
> > --
> > Std-Proposals mailing list
> > Std-Proposals_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-10-27 02:12:59