Macro não expandida com chamada direta, mas expandida com indireta

Eu tenho as seguintes macros

#include <boost/preprocessor.hpp>

#define DB_FIELD(...) BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)

#define DB_TOFIELD(type,name) \
  private:\
  type name##_;\
  public:\
  const type& get_##name(){return name##_;}\
  void set_##name(const type& val) { name##_ = val; }

#define GEN_ENUM_FIELD(r,data,elem) BOOST_PP_CAT(FIELD_,BOOST_PP_SEQ_ELEM(1,elem)),

#define DECLARE(type, name) DB_TOFIELD(type, name)

#define GEN_FIELD_DECL(r, data, elem) DECLARE(BOOST_PP_SEQ_ELEM(0,elem),BOOST_PP_SEQ_ELEM(1,elem))

#define DB_TABLE(name, ...) class name : public DataBaseTable {\
  public:\
  constexpr static const char *get_table_name() { return #name; }\
  BOOST_PP_LIST_FOR_EACH(GEN_FIELD_DECL,, BOOST_PP_VARIADIC_TO_LIST(__VA_ARGS__)) \
  enum Fields{ \
  BOOST_PP_LIST_FOR_EACH(GEN_ENUM_FIELD,, BOOST_PP_VARIADIC_TO_LIST(__VA_ARGS__))\
  FIELD_COUNT\
  };\
  };

Agora o seguinte código:

DB_TABLE(Test2,
  DB_FIELD(int, foo),
  DB_FIELD(int, bar)
)

Gera:

class Test2 : public DataBaseTable {
public:
  constexpr static const char *get_table_name() { return "Test2"; }
private:
  int foo_;
public:
  const int &get_foo() { return foo_; }
  void set_foo(const int &val) { foo_ = val; }
private:
  int bar_;
public:
  const int &get_bar() { return bar_; }
  void set_bar(const int &val) { bar_ = val; }
  enum Fields { FIELD_foo, FIELD_bar, FIELD_COUNT };
};

Que é tão feio quanto eu escrevi, mas minha preocupação épor que preciso desse nível de indireção (DECLARAR) na macro GEN_FIELD_DECL ? A chamada direta paraDB_TOFIELD

#define GEN_FIELD_DECL(r, data, elem) DB_TOFIELD(BOOST_PP_SEQ_ELEM(0,elem),BOOST_PP_SEQ_ELEM(1,elem))

produz lixo:

class Test2 : public DataBaseTable {
public:
  constexpr static const char *get_table_name() { return "Test2"; }
private:
  int foo _;
public:
  const int &get_BOOST_PP_SEQ_ELEM(1, (int)(foo))() { return foo _; }
  void set_BOOST_PP_SEQ_ELEM(1, (int)(foo))(const int &val) { foo _ = val; }
private:
  int bar _;
public:
  const int &get_BOOST_PP_SEQ_ELEM(1, (int)(bar))() { return bar _; }
  void set_BOOST_PP_SEQ_ELEM(1, (int)(bar))(const int &val) { bar _ = val; }
  enum Fields { FIELD_foo, FIELD_bar, FIELD_COUNT };
};

O mesmo comportamento é reproduzido nos clang 3.7.1 e gcc 5.3

questionAnswers(1)

yourAnswerToTheQuestion