[xsd-users] Polymorphic problems.
Boris Kolpackov
boris at codesynthesis.com
Tue Dec 2 10:59:06 EST 2008
Hi Bill,
Bill Pringlemeir <bpringle at sympatico.ca> writes:
> Not really. It means that the map will construct a tree to find the
> non-identical pointers quickly. If the std::map only uses the
> 'before' functionality, then how does find() know when it has found an
> identical value versus one that is !before() or after?
When (!before (x, y) && !before (y, x)), x == y.
> The following test case demonstrates the problem. This fails on
> various versions of gcc. However for the type-serializer-map.[th]xx
> to fail, the platform must have typeid() that return different
> pointers.
>
> [...]
>
> std::map<char *, std::string> theMap;
>
> struct type_id_comparator
> {
> bool
> operator() (const char* x, const char* y) const
> {
> return x < y;
> }
> };
This is not how type-serializer-map works. To make it emulate
type-serializer-map, this code needs to be changed like so:
struct type_id_comparator
{
bool
operator() (const char* x, const char* y) const
{
return strcmp (x, y) < 0;
}
};
std::map<char *, std::string, type_id_comparator> theMap;
That is, we need to use strcmp() instead of comparing pointers
as well as pass type_id_comparator as the third template argument
to std::map.
I tested this program with both g++ on GNU/Linux and XL C++ 7.0
on AIX. In both cases it prints "We have a match." twice.
This means that std::map in XL C++ works as expected and the
problem is somewhere else. Would it be possible for you to
come up with a test case that demonstrates the problem on AIX
with XL C++? Something that recreates your shared object
structure but uses dummy schemas?
Thanks,
Boris
More information about the xsd-users
mailing list