From: drisc...@cs.wisc.edu
Date: Wed, 26 Sep 2012 00:52:24 -0500
Local: Wed, Sep 26 2012 1:52 am
Subject: [Boost-users] Preprocessor sequence of "pairs"
I have a question about the use of the preprocessor library. I'll describe
my ultimate goal in a moment, but I've simplified my first problem to the following. Also, I know what I'm doing looks a lot at first glance like Fusion's ADAPT_STRUCT, but I took a quick look at that documentation and I don't think it matches. However, if you disagree with me and think it does, or can suggest a totally different solution, feel free to describe how. == My problem ==
I don't like C's struct syntax, so I'm trying to define my own.
What I want to do is something like the following:
#include <boost/preprocessor/seq/for_each.hpp>
#define DEFINE_FIELD(r, os, field_pair) [....]
#define DEFINE_STRUCT(struct_name, fields) \
DEFINE_STRUCT(mystruct, (int, x)(int, y)(double, z))
but this doesn't work, because the sequence is made up of pairs instead of
I can get it to work by double-parenthesizing the stuff in the sequence
#define DEFINE_FIELD_REAL(type, name) type name;
but this is less than optimal. Is there a way that I can do this easily,
== What I'm actually trying to do ==
What I'm actually doing is trying to write a macro that will define a
DEFINE_SERIALIZED_STRUCT(mystruct, (int, x)(int, y)(double, z))
(I didn't see a way to recover the field names from a Fusion-adapted
_______________________________________________
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||