Topic: Re:newbie STL/AIX C++ question


Author: scherrey@proteus-tech.com (Benjamin Scherrey)
Date: 1995/06/02
Raw View
In message <3qlb4a$6bl@nntp.interaccess.com> -
hbarta@psycfrnd.interaccess.com (Henry Barta) writes:

:>void* const& key( A const& r)
:>    { return r.k;}
:>
:>map<void*, A, less<void*> > m;
:>
:>-----------
:>
:>Compiling the code results in the following diagnostic:
:>
:>"/v/XCB/XCB_INC/stl/tree.h", line 56.12: 1540-222: (S) \
:> "rb_tree<void*,pair<void*const,A>,select1st<pair<void*const,A>,void*>,less<void*> >::rb_tree_node" \
:> needs a constructor because class member "value_field" needs a constructor initializer.
:> "stl-map.C", line 25.1: 1540-207: (I) \
:>    The previous message applies to the definition of template \
:>    "map<void*,A,less<void*> >".

 I've run into issues with storing pointer types in the containers using
HP's STL code (look at previous messages by me in this conference for
details). It's pretty likely that you could be running into one of these
issues. Also, your key method is defined in a manner that I don't think will
work. Try something like this:

 const void* key( const A& r ) const { return r.k; }

 I don't have my STL ref handy but it also appears that you aren't using the
key method anyway in your container. Shouldn't it be defined something like
this:

 map< void*, A, key > m;

 Actually I'm completely unsure of the syntax for building a map instance.
Meanwhile, generally avoid containers of pointers and I would recommend that,
if you have to have pointers, don't use void pointers. Very dangerous stuff
that. Good luck!


//
// Benjamin Scherrey        Proteus Technologies, Inc.
// scherrey@proteus-tech.com       (404) 454-1013v 986-9876f
//