nedtries icon indicating copy to clipboard operation
nedtries copied to clipboard

Feature request: support for nested incomplete type

Open 191919 opened this issue 13 years ago • 2 comments

and, sometimes code like this are not standard-complaint, but it is very useful.

class A { trie_map<int, A>::iterator begin(); };

It is supported in std::map and boost::unordered_map (before 1.48.0), but not std::tr1::unordered_map.

Thank you.

191919 avatar Feb 19 '12 07:02 191919

What you're really looking for is a proper C++ trie container. The hack job in nedtries simply can't cope with the above, nor indeed with many such things. Of course, your non-standard usage above is non-standard for good reason - how can the compiler know how big the iterator storage is without knowing what class A is? One could add support for undefined non-dependent types, but that's added compiler complexity. And probably you don't want to store hanging iterators anyway as some implementations (Dinkum's) keep a list of all extant iterators, so memory consumption grows large.

BTW the way traditionally you make the above work legally is to declare class baseA with a protected constructor, then have class A inherit from it. You can then declare storage for iterator trie_map<type, baseA>::iterator but use a casting access function to cast that to trie_map<type, A>::iterator &&. This gets around the chicken and egg problem.

Niall

ned14 avatar Feb 19 '12 15:02 ned14

Sorry, meant trie_map<type, baseA>::iterator and trip_map<type, A>::iterator && respectively.

ned14 avatar Feb 19 '12 15:02 ned14