[xsd-users] idref get() either comment or implementation wrong

Oliver Schneider xsd-users at oli-obk.de
Tue Aug 12 05:09:20 EDT 2014


Hi Boris,

when using xse:refType together with idref the dynamic_cast in get()
will return 0 if the object returned by get_() cannot be cast to
ref_type and if the pointer was null.
The comment says @return A constant pointer to the referenced object or
0 if the object is not found.
So either the comment needs to be updated, or you need to to do
something along the lines of :

if (get_()) {
    return &dynamic_cast<const ref_type&>(*get_()); // throws
std::bad_cast if the cast is not possible
} else {
    return nullptr;
}

greetings

/oliver



More information about the xsd-users mailing list