On Wed, Nov 11, 2015 at 6:03 PM, Xidorn Quan <[email protected]> wrote:
> On Wed, Nov 11, 2015 at 5:59 PM, Cameron McCormack <[email protected]> wrote:
>> L. David Baron:
>>> I'm in favor of making it a struct -- but if it becomes a template,
>>> won't the functions that accept it have to become templates,
>>> generating multiple copies of the code where we currently have only
>>> a single copy?
>>
>> You’d hope that the compiler would fold together all the versions of the
>> template that took the same sized enum.  (You could always have a small
>> inline function that casts to uint8_t and have a common implementation
>> that works on the untyped values.)
>
> I hope compilers do that for us, but I have no idea whether it is that case.

Confirmed from a gcc developer that compilers are unlikely to do that
for us because that could cause problems in several cases (e.g. if
there is a static variable declared inside the function body).

So if we want to do this, we would have to add an inline template
function for each of those functions to do the type conversion. It
could be painful, but probably not too much.

- Xidorn
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to