Boost logo

Boost Users :

Subject: Re: [Boost-users] BOOST_PP_SEQ_ENUM troubles
From: Edward Diener (eldiener_at_[hidden])
Date: 2016-07-07 20:04:52


On 7/7/2016 6:05 PM, Cherotek Music wrote:
> Ah I got it to work with the following:
>
> #define SEQ_FORMATS BOOST_PP_VARIADIC_TO_SEQ(FORMATS)
> #define PASTE(l,r) l##r

BOOST_PP_CAT

> #define STRINGIZE(x) #x

BOOST_PP_STRINGIZE

> #define ARG_PAIR(x) {STRINGIZE(x), create<PASTE(x,File)>}
> #define NTH_ARG(z, n, data) ARG_PAIR(BOOST_PP_SEQ_ELEM(n, data))
> #define ARG_PAIRS BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(SEQ_FORMATS), NTH_ARG,
> SEQ_FORMATS)
>
> Thanks guys!

Great !

>
> On Thu, Jul 7, 2016 at 11:57 PM, Cherotek Music <cherotek_at_[hidden]
> <mailto:cherotek_at_[hidden]>> wrote:
>
> Thanks for the suggestion but I still can't get it to work :(
>
> #define SEQ_FORMATS BOOST_PP_VARIADIC_TO_SEQ(FORMATS)
> #define ARG_PAIR(x) {#x, create<x##File>}
> #define NTH_ARG(z, n, data) ARG_PAIR(BOOST_PP_SEQ_ELEM(n, data))
> #define ARG_PAIRS BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(SEQ_FORMATS),
> NTH_ARG, SEQ_FORMATS)
>
> gives the following error:
>
> test.h:14:63: error: pasting ")" and "File" does not give a valid
> preprocessing token
> #define NTH_ARG(z, n, data) ARG_PAIR(BOOST_PP_SEQ_ELEM(n, data))
> ^
> test.h:13:33: note: in definition of macro ‘ARG_PAIR’
> #define ARG_PAIR(x) {#x, create<x##File>}
>
> We're getting closer though
>
> On Thu, Jul 7, 2016 at 6:19 PM, Mathias Gaunard
> <mathias.gaunard_at_[hidden] <mailto:mathias.gaunard_at_[hidden]>>
> wrote:
>
> On 6 July 2016 at 22:27, Cherotek Music <cherotek_at_[hidden]
> <mailto:cherotek_at_[hidden]>> wrote:
>
> Hi,
> I'm trying to make a macro chain that expands something like
> this
>
> *A, B, C*
>
> into something like this
>
> *{"A", create<AFile>}, {"B", create<BFile>}, {"C",
> create<CFile>}*
>
> This is what I have come up with
>
> *#define FORMATS A, B, C // Add new formats here*
> *#define SEQ_FORMATS BOOST_PP_VARIADIC_TO_SEQ(FORMATS)*
> *#define ARG_PAIR(s, data, x) {#x, create<x##File>}*
> *#define SEQ_ARG_PAIRS BOOST_PP_SEQ_TRANSFORM(ARG_PAIR, ~,
> SEQ_FORMATS)*
> *#define ARG_PAIRS BOOST_PP_SEQ_ENUM(SEQ_ARG_PAIRS)*
>
>
> Use BOOST_PP_ENUM with BOOST_PP_SEQ_SIZE and BOOST_PP_SEQ_ELEM
> instead of BOOST_PP_SEQ_TRANSFORM+BOOST_PP_SEQ_ENUM.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden] <mailto:Boost-users_at_[hidden]>
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net