C++ - The right way of type rebinding-resolving?
<p>i have the following code snippets:</p>

<pre><code>namespace X86X64
{
   struct IMM8 {};
}

namespace X86
{
    using namespace X86X64;

    struct RM8 {};

    template &lt;class _Traits&gt;
    struct MOV_Instruction
    {
        typedef typename _Traits::RM8 RM8;

        void mov(const RM8&amp; rm, const IMM8&amp; imm)
        {}
    };
}

namespace X64
{
  using namespace X86X64;

  struct RM8 {};
  struct RM64 {};

  struct Traits
  {
    typedef RM8 RM8;
  };

  struct MOV_Instruction : public X86::MOV_Instruction&lt;Traits&gt;
  {
     using X86::MOV_Instruction&lt;Traits&gt;::mov;

     void mov(const RM64&amp; rm, const IMM8&amp; imm)
     {}
  };
}
</code></pre>

<p>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.</p>

<p>The namespaces X86 and X64 must have their own seperate RM8 types with different underlying base types.</p>

<p>I wanna only use an:</p>

<pre><code>using namespace X86 | X64

MOV_Instruction i;
i.mov(RM8(), IMM8());
</code></pre>

<p>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?</p>

<p>I could make X86::RM8 and X64::RM8 the same type, but i don't wanna strive for that.</p>

<p>Thanks
Martin</p>
