Hi dudes, i have the following code snippets:
namespace X86X64
{
struct IMM8 {};
}
namespace X86
{
using namespace X86X64;
struct RM8 {};
template <class _Traits>
struct MOV_Instruction
{
typedef typename _Traits::RM8 RM8;
void mov(const RM8& rm, const IMM8& imm)
{}
};
}
namespace X64
{
using namespace X86X64;
struct RM8 {};
struct RM64 {};
struct Traits
{
typedef RM8 RM8;
};
struct MOV_Instruction : public X86::MOV_Instruction<Traits>
{
using X86::MOV_Instruction<Traits>::mov;
void mov(const RM64& rm, const IMM8& imm)
{}
};
}
When i use no traits, i get an error, that the compiler cannot find any operator converting an X64::RM8 to X86::RM8, when instantiating MOV_Instruction.
The namespaces X86 and X64 must have their own seperate RM8 types with different underlying base types.
I wanna only use an:
using namespace X86 | X64
MOV_Instruction i;
i.mov(RM8(), IMM8());
and want the compiler to select the right RM8 type depending on the used namespace and Koenig lookup. Is their a better way to do this without a traits to rebind or resolve the right type?
I could make X86::RM8 and X64::RM8 the same type, but i don't wanna strive for that.
Thanks Martin