C++ Logo

std-proposals

Advanced search

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

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Mon, 18 Sep 2023 14:28:46 -0400
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.

Received on 2023-09-18 18:28:57