Re-introduced the casting operators with a note explaining why we need this.

This commit is contained in:
Martijn Otto 2016-09-05 10:11:31 +02:00
parent c1b88fd42b
commit afb04a8f30
2 changed files with 38 additions and 0 deletions

View File

@ -218,6 +218,25 @@ public:
// postfix
stream << ")";
}
/**
* Cast to array.
*
* @note: This function may look silly and unnecessary. We are, after all, already
* an array. The whole reason we still have this function is that it is virtual
* and if we do not declare a cast to array on a pointer to base (i.e. Field)
* will return an empty field instead of the expected array.
*
* Yes, clang gets this wrong and gives incorrect warnings here. See
* https://llvm.org/bugs/show_bug.cgi?id=28263 for more information
*
* @return Ourselves
*/
virtual operator const Array& () const override
{
// this already is an array, so no cast is necessary
return *this;
}
};
/**

View File

@ -242,6 +242,25 @@ public:
// postfix
stream << ")";
}
/**
* Cast to table.
*
* @note: This function may look silly and unnecessary. We are, after all, already
* a table. The whole reason we still have this function is that it is virtual
* and if we do not declare a cast to table on a pointer to base (i.e. Field)
* will return an empty field instead of the expected table.
*
* Yes, clang gets this wrong and gives incorrect warnings here. See
* https://llvm.org/bugs/show_bug.cgi?id=28263 for more information
*
* @return Ourselves
*/
virtual operator const Table& () const override
{
// this already is a table, so no cast is necessary
return *this;
}
};
/**