title: C preprocessor macros: check if token was declared
body: <p>This is for the <strong>C</strong> preprocessor experts:</p>
  
  <p>How can I declare an <code>enum</code> with a list of some identifiers and later during the switch-statement check if an identifier was included in the list?</p>
  
  <p>Example of what I need:</p>
  
  <pre><code>typedef enum { e1, e2, e3, e4, e5, e6 } e;
  
  e x;
  switch (x) {
  #if DECLARED_IN_ENUM (e1)
    case e1 : ...
  #endif
    /* etc. */
  }
  </code></pre>
  
  <p>I thought of using a Boost sequence and expanding it into a comma separated list in the enum, but how can I check later if the sequence contains a certain token?</p>
  
  <p><strong>EDIT</strong>: What I was able to do with Boost is:</p>
  
  <pre><code>#define e1 e1
  #define e2 e2
  #define e3 e3
  #define e4 e4
  #define e5 e5
  #define e6 e6
  #define E (e1)(e2)(e3)(e4)(e5)(e6)
  
  typedef enum { BOOST_PP_SEQ_ENUM(E) } e;
  
  e x;
  switch (x) {
  #if defined (e1)
    case e1 : ...
  #endif
    /* etc. */
  }
  </code></pre>
  
  <p>That is not very beautiful, and I would prefer something like:</p>
  
  <pre><code>#define E (e1)(e2)(e3)(e4)(e5)(e6)
  
  typedef enum { BOOST_PP_SEQ_ENUM(E) } e;
  
  e x;
  switch (x) {
  #if BOOST_PP_SEQ_CONTAINS (e1,E)
    case e1 : ...
  #endif
    /* etc. */
  }
  </code></pre>
  
  <p>but how could <code>BOOST_PP_SEQ_CONTAINS</code> be implemented?</p>