|
Boost : |
Subject: Re: [boost] [wave] preprocessor directives in output
From: Eric Niebler (eniebler_at_[hidden])
Date: 2014-01-21 14:16:35
(John, please don't top-post on the Boost mailing list. See the Boost
Discussion Policy at http://www.boost.org/community/policy.html)
On 1/21/2014 8:25 AM, Fletcher, John P wrote:
> On 21 January 2014 16:13, Eric Niebler wrote:
>> On 1/20/2014 11:27 PM, pmenso57_at_[hidden] wrote:
>>> Provided the code was only in an #if block used for pre-generation (or the code is *only* used for pre-gen), you could have wave produce that. E.g. use an object-like macro to get a non-macro-operator hash mark:
>>>
>>>
>>> #if PREGENERATING_HEADERS
>>> #define HASH #
>>> HASH if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
>>> vector(vector&& rhs)
>>> : vec(std::forward<vector_n>(rhs.vec)) {} HASH endif #endif
>>
>> Clever, but sadly the code is not only used for pregeneration. It's possible to compile Fusion with the "don't use preprocessed headers"
>> flag, in which case this header gets used directly.
>>
>> <sigh>
>
> Eric
>
> Could that second use case use a different copy of the code?
I figured this out. Using Paul's trick, I can do this:
#define FUSION_HASH
#if defined(__WAVE__) && \
defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
FUSION_HASH if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
(defined(__WAVE__) && \
defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
vector(vector&& rhs)
: vec(std::forward<vector_n>(rhs.vec)) {}
// more code that uses rvalue references
#endif
#if defined(__WAVE__) && \
defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
FUSION_HASH endif
#endif
#undef FUSION_HASH
Ugly as sin, but it seems to give the desired results.
-- Eric Niebler ericniebler.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk