[Insight-developers] select1st is not portable - I need some help, please (Solaris, CC)

Attila Nagy nagy.attila at yahoo.com
Mon Mar 29 05:34:08 EDT 2010


Hi all,

to put a long story short, in recent OpensSolaris builds, Su^H^H Oracle has incorporated Apache's stdlib implementation into the OS itself (it is included in /usr/lib, whereas stlport, for example, is distributed with the compiler collection), and I am trying to build Slicer's toolchain, and Slicer itself with this lib. There are various reasons for it (one being this: http://www.itk.org/mailman/private/insight-developers/2009-August/013223.html , I'll fire up a wiki page on this a bit later, if anyone is interested.)
Now to the problem:
I learned over the past weekend, that hash_map is not portable, it has never been part of any C++ standard. It happens to be accepted by the GNU community, and even Sun's Cstd and stlport implementation happen to contain this header, that comes from SGI's implentation. On the other hand Apache's strict implementation does not contain this. Hence I get build errors, with Studio12.1 (CC5.10) (Slicer uses ITK 3-16 at the moment)

"/ufsbckp/head-64-slicer/apache/Slicer3-lib/Insight/Code/Common/itk_hash_map.h", line 134: Error: select1st is not a member of std.

and then a bunch of other errors/warnings because of this.

By inserting the following code into itk_hash_map.h (I found it here: 
http://stackoverflow.com/questions/2504562/is-it-safe-to-define-has-traditional-stl-to-enable-stl-functionality )

template <typename PairT>
 struct select1st : public std::unary_function<PairT, typename PairT::first_type>
{
    typename PairT::first_type operator()(const PairT& a) { return a.first; }
};

this compiles fine (even without a warning, and with gcc too).

But a bit later I get:

"/ufsbckp/head-64-slicer/apache/Slicer3-lib/Insight/Code/Common/itk_hashtable.h", line 569: Error: Non-const function select1st<std::pair<const unsigned long, unsigned long>>::operator()(const std::pair<const unsigned long, unsigned long>&) called for const object.
"/ufsbckp/head-64-slicer/apache/Slicer3-lib/Insight/Code/Common/itk_hash_map.h", line 211:     Where: While instantiating "itk::hashtable<std::pair<const unsigned long, unsigned long>, unsigned long, itk::hash<unsigned long>, select1st<std::pair<const unsigned long, unsigned long>>, std::equal_to<unsigned long>, std::allocator<char>>::find(const unsigned long&) const".
"/ufsbckp/head-64-slicer/apache/Slicer3-lib/Insight/Code/Common/itk_hash_map.h", line 211:     Where: Instantiated from itk::hash_map<unsigned long, unsigned long, itk::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<char>>::find(const unsigned long&) const.
"/ufsbckp/head-64-slicer/apache/Slicer3-lib/Insight/Code/Common/itkEquivalencyTable.cxx", line 106:     Where: Instantiated from non-template code.
1 Error(s) detected.

...and I'm at loss here.
Could somebody please take a look at it?

Thanks very much,
Attila

ps: VTK compiles fine (a few files needed the <ios> header), by the way, and this is so far the only error in ITK with Apache stdlib.


      


More information about the Insight-developers mailing list