This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Errors when typdef'ing hash_map::iterator


On 4/18/07, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
On 16/04/07, Matt Fischer <mattfischer84@gmail.com> wrote:
> Hi all.  I've run into a problem using the hash_map extension class in
> libstdc++, and I'm evidently not well-versed enough in templates to
> determine what the root cause is.  Essentially the problem I'm seeing
> arises when I attempt to make a typedef of a hash_map iterator which
> references a forward-declared class.

That's not allowed when Foo is not complete, and neither is the
map<int, Foo>  (but it doesn't fail unless you turn on concept-checks
with -D_GLIBCXX_CONCEPT_CHECKS)

Unless explicitly stated otherwise (as with e.g. std::tr1::shared_ptr)
all types used as template arguments to templates in the standard
library must be complete.  Although hash_map isn't in the standard it
seems to have the same requirement, and so fails with the error you're
seeing.

Jon

Ah, I was wondering if this might not be the case.  So the fact that
std::map works with incomplete types is really an example of undefined
behavior, and presumably the code I'm porting is written that way
because in VC++'s library implementation that just so happens to be
true for hash_map as well.  Thank you for your help.

--Matt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]