title: Field of struct as a template parameter
body: <p>I have a code in MSVC 2008:</p>
  
  <pre><code>template&lt; class T, class FieldType, FieldType T::*FieldPtr &gt;
  struct EqualBy {
      EqualBy( const FieldType &amp; value ) : m_filedValue( value ) {}
      bool operator()( const T &amp; r ) const {
          return m_filedValue == r.*FieldPtr;
      }
  private:
      const FieldType m_filedValue;
  };
  
  ...
  
  struct S {
      int field1;
      ...
  };
  typedef EqualBy&lt; S, int, &amp;S::field1 &gt; EqualByField1;
  
  ...
  
  typedef std::vector&lt; S &gt; SVect;
  SVect v;
  SVect::const_iterator found = std::find_if( v.begin(), v.end(), EqualByField1( 42 ) );
  </code></pre>
  
  <p>it works fine. But now I want to move the EqualByField1 typedef into the struct S. like this</p>
  
  <pre><code>struct S {
      int field1;
  ...
  
      typedef EqualBy&lt; S, int, &amp;S::field1 &gt; EqualByField1;
  };
  </code></pre>
  
  <p>to decrease the scope of this typedef and to "beautify" the caller code like this</p>
  
  <pre><code>SVect::const_iterator found = std::find_if( v.begin(), v.end(), S::EqualByField1( 42 ) );
  </code></pre>
  
  <p>but I got following errors</p>
  
  <blockquote>
    <p>error C2327: 'S::field1' : is not a type name, static, or enumerator<br>
    error C2065: 'field1' : undeclared identifier</p>
  </blockquote>
  
  <p>The question is: Is there any solution of this problem, except of to derive from S like that</p>
  
  <pre><code>struct SS : public S {
      typedef EqualBy&lt; S, int, &amp;S::field1 &gt; EqualByField1; // it works, but I do not want to derive :)
  };
  </code></pre>
  
  <p>Thanx. And sorry for my ugly english :)</p>