M
Matt Taylor
I'm trying to write an x86 assembler in C++ for use in a debugger. What I'd
like do is to use template specialization to prevent invalid combinations
from compiling. Thus one could not accidentally add a 16-bit register and an
8-bit register since there is no encoding for this on the x86 architecture.
My trouble has stemmed from the fact that enumerators are only integers and
can be freely cast into other enumerators, and I was using them to attempt
type safety. I declared REG8, REG16, and REG32 enumerated types, but the
compiler will implicitly cast between them. So, my question is: is there any
way to create 3 distinct types that I can use in template specialization to
enforce assembler operand restrictions at compile-time?
-Matt
like do is to use template specialization to prevent invalid combinations
from compiling. Thus one could not accidentally add a 16-bit register and an
8-bit register since there is no encoding for this on the x86 architecture.
My trouble has stemmed from the fact that enumerators are only integers and
can be freely cast into other enumerators, and I was using them to attempt
type safety. I declared REG8, REG16, and REG32 enumerated types, but the
compiler will implicitly cast between them. So, my question is: is there any
way to create 3 distinct types that I can use in template specialization to
enforce assembler operand restrictions at compile-time?
-Matt