More tweaks to previous commit

Delete assignment operator of OffsetTo<> instead of Offset<>.

In simple ArrayOf<>::sanitize() assert that Type has assignment operator.
Ideally we should SFINAE this and fallback to calling Type::sanitize()
if assignment operator is not available.  But we don't have a case of
that in the codebase.
This commit is contained in:
Behdad Esfahbod 2019-04-15 16:43:34 -04:00
parent 699de689e9
commit 07776b6096
2 changed files with 13 additions and 7 deletions

View File

@ -86,8 +86,8 @@ typedef struct OffsetTable
const TableRecord& get_table (unsigned int i) const
{ return tables[i]; }
unsigned int get_table_tags (unsigned int start_offset,
unsigned int *table_count, /* IN/OUT */
hb_tag_t *table_tags /* OUT */) const
unsigned int *table_count, /* IN/OUT */
hb_tag_t *table_tags /* OUT */) const
{
if (table_count)
{

View File

@ -173,9 +173,6 @@ typedef Index NameID;
template <typename Type, bool has_null=true>
struct Offset : Type
{
HB_DELETE_COPY_ASSIGN (Offset);
Offset () = default;
Offset& operator = (typename Type::type i) { Type::operator= (i); return *this; }
typedef Type type;
@ -266,6 +263,9 @@ struct _hb_has_null<Type, true>
template <typename Type, typename OffsetType=HBUINT16, bool has_null=true>
struct OffsetTo : Offset<OffsetType, has_null>
{
HB_DELETE_COPY_ASSIGN (OffsetTo);
OffsetTo () = default;
OffsetTo& operator = (typename OffsetType::type i) { OffsetType::operator= (i); return *this; }
const Type& operator () (const void *base) const
@ -609,10 +609,16 @@ struct ArrayOf
* we do not need to call their sanitize() as we already did
* a bound check on the aggregate array size. We just include
* a small unreachable expression to make sure the structs
* pointed to do have a simple sanitize(), ie. they do not
* pointed to do have a simple sanitize() as well as an
* assignment opreator. This ensures that they do not
* reference other structs via offsets.
*/
(void) (false && arrayZ[0].sanitize (c));
if (false)
{
arrayZ[0].sanitize (c);
Type v;
v = arrayZ[0];
}
return_trace (true);
}