Alternative implementation for BOOST_PP_VARIADIC_SIZE

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
40 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Alternative implementation for BOOST_PP_VARIADIC_SIZE

Gennadiy Rozental-2
Hi,

Current implementation of subject macro have a very serious shortcoming - it
does not work for empty __VA_ARGS__. After googling around a bit for some ideas
I came up with the following alternative:

#include <boost/preprocessor/arithmetic/mul.hpp>
#include <boost/preprocessor/arithmetic/sub.hpp>
#include <boost/preprocessor/punctuation/comma.hpp>

#define MY_VA_ARG_N( \
     _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
    _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
    _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
    _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
    _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
    _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
    _61,_62,_63,  N, ...) N

#define MY_VA_RSEQ_N() \
    63,62,61,60,                   \
    59,58,57,56,55,54,53,52,51,50, \
    49,48,47,46,45,44,43,42,41,40, \
    39,38,37,36,35,34,33,32,31,30, \
    29,28,27,26,25,24,23,22,21,20, \
    19,18,17,16,15,14,13,12,11,10, \
     9, 8, 7, 6, 5, 4, 3, 2, 1, 0

#define MY_DO_VA_NARG2(...) MY_VA_ARG_N __VA_ARGS__
#define MY_DO_VA_NARG(...) MY_DO_VA_NARG2(( __VA_ARGS__ ))

// this version produces incorrect value (1) for empty __VA_ARGS__
#define MY_VA_NARG_(...) MY_DO_VA_NARG(__VA_ARGS__, MY_VA_RSEQ_N())

// this version fixes it
#define MY_VA_NARG(...)  BOOST_PP_SUB( BOOST_PP_MUL( MY_VA_NARG_( __VA_ARGS__ ),
2 ), MY_VA_NARG_( BOOST_PP_COMMA __VA_ARGS__ () ) )

This version work for zero sized __VA_ARGS__ and also works for MSVC-9,10 ,
gcc-4.1 gcc 3.2 (did not test with other compilers).

Does it make sense to improve trunk version?

Regards,
Gennadiy


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

lcaminiti
On Thu, Nov 10, 2011 at 6:43 PM, Gennadiy Rozental <[hidden email]> wrote:
> Hi,
>
> Current implementation of subject macro have a very serious shortcoming - it
> does not work for empty __VA_ARGS__. After googling around a bit for some ideas
> I came up with the following alternative:

A while back there was a discussion about the
possibility/impossibility to handle empty macro parameters using
variadics:

http://lists.boost.org/Archives/boost/2011/02/177321.php

(Make sure to address the concerns expressed by Paul in the replies to
the above thread.)

> #include <boost/preprocessor/arithmetic/mul.hpp>
> #include <boost/preprocessor/arithmetic/sub.hpp>
> #include <boost/preprocessor/punctuation/comma.hpp>
>
> #define MY_VA_ARG_N( \
>     _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
>    _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
>    _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
>    _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
>    _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
>    _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
>    _61,_62,_63,  N, ...) N
>
> #define MY_VA_RSEQ_N() \
>    63,62,61,60,                   \
>    59,58,57,56,55,54,53,52,51,50, \
>    49,48,47,46,45,44,43,42,41,40, \
>    39,38,37,36,35,34,33,32,31,30, \
>    29,28,27,26,25,24,23,22,21,20, \
>    19,18,17,16,15,14,13,12,11,10, \
>     9, 8, 7, 6, 5, 4, 3, 2, 1, 0
>
> #define MY_DO_VA_NARG2(...) MY_VA_ARG_N __VA_ARGS__
> #define MY_DO_VA_NARG(...) MY_DO_VA_NARG2(( __VA_ARGS__ ))
>
> // this version produces incorrect value (1) for empty __VA_ARGS__
> #define MY_VA_NARG_(...) MY_DO_VA_NARG(__VA_ARGS__, MY_VA_RSEQ_N())
>
> // this version fixes it
> #define MY_VA_NARG(...)  BOOST_PP_SUB( BOOST_PP_MUL( MY_VA_NARG_( __VA_ARGS__ ),
> 2 ), MY_VA_NARG_( BOOST_PP_COMMA __VA_ARGS__ () ) )
>
> This version work for zero sized __VA_ARGS__ and also works for MSVC-9,10 ,
> gcc-4.1 gcc 3.2 (did not test with other compilers).
>
> Does it make sense to improve trunk version?

HTH,
--Lorenzo

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Gennadiy Rozental-2
Lorenzo Caminiti <lorcaminiti <at> gmail.com> writes:

> On Thu, Nov 10, 2011 at 6:43 PM, Gennadiy Rozental <rogeeff <at> gmail.com>>
> Hi,
> >
> > Current implementation of subject macro have a very serious shortcoming -
> > it does not work for empty __VA_ARGS__. After googling around a bit for
> > some ideas I came up with the following alternative:
>
> A while back there was a discussion about the
> possibility/impossibility to handle empty macro parameters using
> variadics:
>
> http://lists.boost.org/Archives/boost/2011/02/177321.php
>
> (Make sure to address the concerns expressed by Paul in the replies to
> the above thread.)

Frankly, I do not have time to read through the whole discussion. I am not a
language lawyer, but for what it worth my version works on all compilers I
have tried and looks to be perfectly legal (to me). I do know about one
limitation. It's where __VA_ARGS__ ends with macro function which produces
comma when evaluated. It's very rare case though and even if it's possible
to implement solution that deals with it (look here:
https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ),
I find the complication does not worth the trouble.

If Edward or Paul care to comment it might be easier for them to point to any
shortcomings in my solution (if any).

Regards,
Gennadiy


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
In reply to this post by Gennadiy Rozental-2
On 11/10/2011 6:43 PM, Gennadiy Rozental wrote:

> Hi,
>
> Current implementation of subject macro have a very serious shortcoming - it
> does not work for empty __VA_ARGS__. After googling around a bit for some ideas
> I came up with the following alternative:
>
> #include<boost/preprocessor/arithmetic/mul.hpp>
> #include<boost/preprocessor/arithmetic/sub.hpp>
> #include<boost/preprocessor/punctuation/comma.hpp>
>
> #define MY_VA_ARG_N( \
>       _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
>      _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
>      _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
>      _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
>      _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
>      _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
>      _61,_62,_63,  N, ...) N
>
> #define MY_VA_RSEQ_N() \
>      63,62,61,60,                   \
>      59,58,57,56,55,54,53,52,51,50, \
>      49,48,47,46,45,44,43,42,41,40, \
>      39,38,37,36,35,34,33,32,31,30, \
>      29,28,27,26,25,24,23,22,21,20, \
>      19,18,17,16,15,14,13,12,11,10, \
>       9, 8, 7, 6, 5, 4, 3, 2, 1, 0
>
> #define MY_DO_VA_NARG2(...) MY_VA_ARG_N __VA_ARGS__
> #define MY_DO_VA_NARG(...) MY_DO_VA_NARG2(( __VA_ARGS__ ))
>
> // this version produces incorrect value (1) for empty __VA_ARGS__
> #define MY_VA_NARG_(...) MY_DO_VA_NARG(__VA_ARGS__, MY_VA_RSEQ_N())
>
> // this version fixes it
> #define MY_VA_NARG(...)  BOOST_PP_SUB( BOOST_PP_MUL( MY_VA_NARG_( __VA_ARGS__ ),
> 2 ), MY_VA_NARG_( BOOST_PP_COMMA __VA_ARGS__ () ) )
>
> This version work for zero sized __VA_ARGS__ and also works for MSVC-9,10 ,
> gcc-4.1 gcc 3.2 (did not test with other compilers).
>
> Does it make sense to improve trunk version?

I will look at this but please look at my variadic macro data library in
the sandbox which attempts to solve this same problem.

When I announced the latest update to my library, nobody paid any
attention to it.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
In reply to this post by Gennadiy Rozental-2
On 11/10/2011 6:43 PM, Gennadiy Rozental wrote:

> Hi,
>
> Current implementation of subject macro have a very serious shortcoming - it
> does not work for empty __VA_ARGS__. After googling around a bit for some ideas
> I came up with the following alternative:
>
> #include<boost/preprocessor/arithmetic/mul.hpp>
> #include<boost/preprocessor/arithmetic/sub.hpp>
> #include<boost/preprocessor/punctuation/comma.hpp>
>
> #define MY_VA_ARG_N( \
>       _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
>      _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
>      _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
>      _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
>      _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
>      _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
>      _61,_62,_63,  N, ...) N
>
> #define MY_VA_RSEQ_N() \
>      63,62,61,60,                   \
>      59,58,57,56,55,54,53,52,51,50, \
>      49,48,47,46,45,44,43,42,41,40, \
>      39,38,37,36,35,34,33,32,31,30, \
>      29,28,27,26,25,24,23,22,21,20, \
>      19,18,17,16,15,14,13,12,11,10, \
>       9, 8, 7, 6, 5, 4, 3, 2, 1, 0
>
> #define MY_DO_VA_NARG2(...) MY_VA_ARG_N __VA_ARGS__
> #define MY_DO_VA_NARG(...) MY_DO_VA_NARG2(( __VA_ARGS__ ))
>
> // this version produces incorrect value (1) for empty __VA_ARGS__
> #define MY_VA_NARG_(...) MY_DO_VA_NARG(__VA_ARGS__, MY_VA_RSEQ_N())
>
> // this version fixes it
> #define MY_VA_NARG(...)  BOOST_PP_SUB( BOOST_PP_MUL( MY_VA_NARG_( __VA_ARGS__ ),
> 2 ), MY_VA_NARG_( BOOST_PP_COMMA __VA_ARGS__ () ) )
>
> This version work for zero sized __VA_ARGS__ and also works for MSVC-9,10 ,
> gcc-4.1 gcc 3.2 (did not test with other compilers).
>
> Does it make sense to improve trunk version?

This has the same limitation as the BOOST_VMD_IS_EMPTY(...) macro in my
own latest version of the variadic macro data library, which itself was
adapted from a solution Paul Mensonides showed on the Internet. It also
uses much the same technique, although I find Paul's solution more
elegant ( involves no PP arithmetic ). The limitation is that if the
variadic data ends with a function-like macro the '__VA_ARGS__ ()' could
cause function-like macro expansion.

Eddie


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
In reply to this post by Gennadiy Rozental-2
On 11/12/2011 6:52 AM, Gennadiy Rozental wrote:

> Lorenzo Caminiti<lorcaminiti<at>  gmail.com>  writes:
>> On Thu, Nov 10, 2011 at 6:43 PM, Gennadiy Rozental<rogeeff<at>  gmail.com>>
>> Hi,
>>>
>>> Current implementation of subject macro have a very serious shortcoming -
>>> it does not work for empty __VA_ARGS__. After googling around a bit for
>>> some ideas I came up with the following alternative:
>>
>> A while back there was a discussion about the
>> possibility/impossibility to handle empty macro parameters using
>> variadics:
>>
>> http://lists.boost.org/Archives/boost/2011/02/177321.php
>>
>> (Make sure to address the concerns expressed by Paul in the replies to
>> the above thread.)
>
> Frankly, I do not have time to read through the whole discussion. I am not a
> language lawyer, but for what it worth my version works on all compilers I
> have tried and looks to be perfectly legal (to me). I do know about one
> limitation. It's where __VA_ARGS__ ends with macro function which produces
> comma when evaluated. It's very rare case though and even if it's possible
> to implement solution that deals with it (look here:
> https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ),
> I find the complication does not worth the trouble.
>
> If Edward or Paul care to comment it might be easier for them to point to any
> shortcomings in my solution (if any).

I have already commented in a direct reply to your OP. I don't see how
the link above gets around the function-like macro problem but I will
study it to see what is involved.



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
In reply to this post by Gennadiy Rozental-2
On 11/12/2011 6:52 AM, Gennadiy Rozental wrote:

> Lorenzo Caminiti<lorcaminiti<at>  gmail.com>  writes:
>> On Thu, Nov 10, 2011 at 6:43 PM, Gennadiy Rozental<rogeeff<at>  gmail.com>>
>> Hi,
>>>
>>> Current implementation of subject macro have a very serious shortcoming -
>>> it does not work for empty __VA_ARGS__. After googling around a bit for
>>> some ideas I came up with the following alternative:
>>
>> A while back there was a discussion about the
>> possibility/impossibility to handle empty macro parameters using
>> variadics:
>>
>> http://lists.boost.org/Archives/boost/2011/02/177321.php
>>
>> (Make sure to address the concerns expressed by Paul in the replies to
>> the above thread.)
>
> Frankly, I do not have time to read through the whole discussion. I am not a
> language lawyer, but for what it worth my version works on all compilers I
> have tried and looks to be perfectly legal (to me). I do know about one
> limitation. It's where __VA_ARGS__ ends with macro function which produces
> comma when evaluated. It's very rare case though and even if it's possible
> to implement solution that deals with it (look here:
> https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ),

No, this does not workaround the well-known problem when the variadic
macro data is a function-like macro. See my comment at the link above.

> I find the complication does not worth the trouble.
>
> If Edward or Paul care to comment it might be easier for them to point to any
> shortcomings in my solution (if any).


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Paul Mensonides
In reply to this post by Gennadiy Rozental-2
On Sat, 12 Nov 2011 11:52:33 +0000, Gennadiy Rozental wrote:

> Lorenzo Caminiti <lorcaminiti <at> gmail.com> writes:

> Frankly, I do not have time to read through the whole discussion. I am
> not a language lawyer, but for what it worth my version works on all
> compilers I have tried and looks to be perfectly legal (to me). I do
> know about one limitation. It's where __VA_ARGS__ ends with macro
> function which produces comma when evaluated. It's very rare case though
> and even if it's possible to implement solution that deals with it (look
> here:
> https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/
> ), I find the complication does not worth the trouble.
>
> If Edward or Paul care to comment it might be easier for them to point
> to any shortcomings in my solution (if any).

You cannot detect emptiness in the general case (even excluding
pathological input such as unbalanced parentheses).  This is simply a
fact.  You can attack the problem in a variety of different ways, but all
of them have limitations that restrict the domain on input.

Regardless, the scenario here is fundamentally wrong-headed.  A macro
argument may be empty, but that does not change the number of arguments.  
E.g.

#define A(...)

A()   // one argument (*not* zero arguments)
B(,)  // two arguments
C(,,) // three arguments

Moreover:

A( ) // one argument containing a space

The only to have a function-like macro that takes zero arguments is to
define the macro as nullary.

The bottom line here is that arguments to macros are sequences of
preprocessing tokens and whitespace separations which, according to > C99
and > C++11, may be an empty sequence.

Regards,
Paul Mensonides


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Gennadiy Rozental-2
Paul Mensonides <pmenso57 <at> comcast.net> writes:
> Regardless, the scenario here is fundamentally wrong-headed.  A macro
> argument may be empty, but that does not change the number of arguments.  
> E.g.
>
> #define A(...)
>
> A()   // one argument (*not* zero arguments)
> B(,)  // two arguments
> C(,,) // three arguments

This is all very theoretical. In practice I want for A() to indicate that it has
zero arguments and A(b) that it has one, even though former is just later with
empty b. Any other size logic would be very confusing.

Gennadiy


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Gennadiy Rozental-2
In reply to this post by Edward Diener-3
Edward Diener <eldiener <at> tropicsoft.com> writes:

> I will look at this but please look at my variadic macro data library in
> the sandbox which attempts to solve this same problem.

I do not see vmd_size.hpp. Where should I look?

> When I announced the latest update to my library, nobody paid any
> attention to it.

Everything comes when time is right ;).

Gennadiy


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Gennadiy Rozental-2
In reply to this post by Edward Diener-3
Edward Diener <eldiener <at> tropicsoft.com> writes:
> > https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ),
>
> No, this does not workaround the well-known problem when the variadic
> macro data is a function-like macro. See my comment at the link above.

I cannot find it. Do you mean on a Jens page? Can you summarize it here?

Gennadiy


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
On 11/13/2011 11:02 AM, Gennadiy Rozental wrote:
> Edward Diener<eldiener<at>  tropicsoft.com>  writes:
>>> https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ),
>>
>> No, this does not workaround the well-known problem when the variadic
>> macro data is a function-like macro. See my comment at the link above.
>
> I cannot find it. Do you mean on a Jens page? Can you summarize it here?

Look at my comment on the bottom of the web page above.



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
In reply to this post by Gennadiy Rozental-2
On 11/13/2011 10:50 AM, Gennadiy Rozental wrote:
> Edward Diener<eldiener<at>  tropicsoft.com>  writes:
>
>> I will look at this but please look at my variadic macro data library in
>> the sandbox which attempts to solve this same problem.
>
> I do not see vmd_size.hpp. Where should I look?

Look at BOOST_VMD_IS_EMPTY(...).

I did not attempt to use BOOST_VMD_IS_EMPTY(...) on
BOOST_VMD_DATA_SIZE(...) to return 0 for empty variadic data because of
the innate flaw in BOOST_VMD_IS_EMPTY, for which there is no workaround.
You can obviously use it as you wish, for your own macro testing the
size of variadic data. Also, for VC8, I could not implement a
BOOST_VMD_IS_EMPTY(...) taking variadic data and had to settle for a
BOOST_VMD_IS_EMPTY(param) instead.

I did use BOOST_VMD_IS_EMPTY on my new BOOST_VMD_ASSERT macros while
documenting the flaw in BOOST_VMD_IS_EMPTY.

>
>> When I announced the latest update to my library, nobody paid any
>> attention to it.
>
> Everything comes when time is right ;).

Eddie


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Gennadiy Rozental-2
In reply to this post by Edward Diener-3
Edward Diener <eldiener <at> tropicsoft.com> writes:

>
> On 11/13/2011 11:02 AM, Gennadiy Rozental wrote:
> > Edward Diener<eldiener<at>  tropicsoft.com>  writes:
> >>> https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ),
> >>
> >> No, this does not workaround the well-known problem when the variadic
> >> macro data is a function-like macro. See my comment at the link above.
> >
> > I cannot find it. Do you mean on a Jens page? Can you summarize it here?
>
> Look at my comment on the bottom of the web page above.

I see nothing there. Are you sure you actually post it?

Anyone else able to see Edward's comments?

Gennadiy


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
On 11/13/2011 12:51 PM, Gennadiy Rozental wrote:

> Edward Diener<eldiener<at>  tropicsoft.com>  writes:
>
>>
>> On 11/13/2011 11:02 AM, Gennadiy Rozental wrote:
>>> Edward Diener<eldiener<at>   tropicsoft.com>   writes:
>>>>> https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ),
>>>>
>>>> No, this does not workaround the well-known problem when the variadic
>>>> macro data is a function-like macro. See my comment at the link above.
>>>
>>> I cannot find it. Do you mean on a Jens page? Can you summarize it here?
>>
>> Look at my comment on the bottom of the web page above.
>
> I see nothing there. Are you sure you actually post it?
>
> Anyone else able to see Edward's comments?

There is a comment number 7 which is mine at the bottom of
https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ .

Eddie


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Peter Dimov-5
Edward Diener wrote:
> There is a comment number 7 which is mine at the bottom of
> https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ .

I don't see it.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
On 11/13/2011 3:49 PM, Peter Dimov wrote:
> Edward Diener wrote:
>> There is a comment number 7 which is mine at the bottom of
>> https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ .
>
> I don't see it.

I do not know why that is the case. Is the last comment number 6 that
you see ? I know I added a comment and it shows up as 7 when I bring up
the page. My comment is:

"#define AMACRO(x) ()
IS_EMPTY(AMACRO) is true, where of course it should be false.

This is the flaw in your presentation and it is well-known. See Paul
Mensonides post at
http://boost.2283326.n4.nabble.com/problem-with-BOOST-PP-IS-EMPTY-macro-td2603454.html.

I give a better and less complicated version of IS_EMPTY in my variadic
data macro library in the Boost sandbox which is almost wholly based on
Paul Mensonides brilliant version ( I have to do some tweaks for VC8 )."

Eddie


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Gennadiy Rozental-2
Edward Diener <eldiener <at> tropicsoft.com> writes:

> the page. My comment is:
>
> "#define AMACRO(x) ()
> IS_EMPTY(AMACRO) is true, where of course it should be false.

Are you sure? My gcc (cygwin) says it false.

On the other hand if you define it like this:

#define AMACRO(x,y) anything here

if fails to build.

In any case, as I said previous, this is corner case we should just document,
but size should return zero when we actually did not pass any arguments to the
macro.

Gennadiy


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Edward Diener-3
On 11/13/2011 9:48 PM, Gennadiy Rozental wrote:
> Edward Diener<eldiener<at>  tropicsoft.com>  writes:
>
>> the page. My comment is:
>>
>> "#define AMACRO(x) ()
>> IS_EMPTY(AMACRO) is true, where of course it should be false.
>
> Are you sure? My gcc (cygwin) says it false.

I admit I do not understand how this can be. in the expansion to the
code on that page it sure looks to me like
'HAS_COMMA(_TRIGGER_PARENTHESIS_ __VA_ARGS__ (~))' will equate to 1 when
__VA_ARGS__ = AMACRO since 'AMACRO (~)' = '()', '_TRIGGER_PARENTHESIS_
()' = ',', and HAS_COMMA(,) = 1.

I will look at it in Wave, which I trust more than most anything as a
preprocessor.

>
> On the other hand if you define it like this:
>
> #define AMACRO(x,y) anything here
>
> if fails to build.
>
> In any case, as I said previous, this is corner case we should just document,
> but size should return zero when we actually did not pass any arguments to the
> macro.

I did document this corner case in my VMD but clearly it makes an
IS_EMPTY macro not 100% reliable, as it makes your solution not 100%
reliable. It is no use saying that you have a foolproof solution to size
returning 0, when it is clearly not foolproof. OTOH I personally am not
against having a solution that is not 100% reliable else I would not
have put out the latest version of VMD. But, although I can not speak
for him, I have a strong impression that Paul does not want such code in
Boost PP.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alternative implementation for BOOST_PP_VARIADIC_SIZE

Gennadiy Rozental-2
Edward Diener <eldiener <at> tropicsoft.com> writes:

> I did document this corner case in my VMD but clearly it makes an
> IS_EMPTY macro not 100% reliable, as it makes your solution not 100%
> reliable. It is no use saying that you have a foolproof solution to size
> returning 0, when it is clearly not foolproof. OTOH I personally am not
> against having a solution that is not 100% reliable else I would not
> have put out the latest version of VMD. But, although I can not speak
> for him, I have a strong impression that Paul does not want such code in
> Boost PP.

Variadic data library which does not say that A() has zero arguments is useless
IMO (all the corner cases aside, which we might never hit in practice). This is
the most important use case.

Gennadiy


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
12
Loading...