Boost logo

Boost :

Subject: Re: [boost] [preprocessor] pp-strings
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2011-06-28 03:27:42


On Mon, 27 Jun 2011 06:39:00 -0700, lcaminiti wrote:

> Paul Mensonides wrote:
>>
>> On Sun, 26 Jun 2011 11:00:16 -0400, Lorenzo Caminiti wrote:
>>
>>> Any comment on "pp comma-separated strings" support (of lack of
>>> thereof) in Boost.Preprocessor and/or CHAOS?
>>
>> Boost.Preprocessor represents the lowest common denominator in what can
>> be made portable across most C and C++ compilers. The main roadblock
>> to more significant improvement (nowadays) is VC++'s horrible
>> preprocessor.
>>
>> By "comma-separated strings" I assume you mean something like: a, b, c?
>> Boost.Preprocessor doesn't support them, of course. Chaos doesn't
>> support them in that form (generally speaking, data structures
>> containing open commas = bad design).
>>
>>
> I am sorry, I meant to say "*space* separated strings" (not commas).
> These are tokens like `a b c` where a character can be a-z, A-Z, 0-9, or
> _ and all characters must be separated from each other by one or more
> spaces. Concatenation can be used to parse these "space separated
> strings", for example (leaving aside reentrancy issues, etc):

Chaos supports such data structures. E.g.

#include <chaos/preprocessor/algorithm/reverse.h>
#include <chaos/preprocessor/generics/strip.h>
#include <chaos/preprocessor/string/core.h>

CHAOS_PP_REVERSE( (CHAOS_PP_STRING) a b c d e f )
// (CHAOS_PP_STRING) f e d c b a

CHAOS_PP_STRING_TO_UPPER(
  CHAOS_PP_STRIP(
    CHAOS_PP_REVERSE( (CHAOS_PP_STRING) a b c d e f )
  )
)
// F E D C B A

Regards,
Paul Mensonides


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk