Boost logo

Boost Users :

Subject: [Boost-users] [Preprocessor] How to work around empty sequence?
From: Adam Badura (abadura_at_[hidden])
Date: 2013-02-13 05:41:26


I was using sequences happily until I realized that quite often I will have
an empty collection. Yet empty sequences are not supported.
 
So I switched to lists. But they are syntactically so much worse! You have
to add that BOOST_PP_NIL. You have to take care of proper nesting of
elements. Much less readable and editable in my opinion.
 
This made me consider going back to sequences after all and requiring user
to provide some kind of special symbol for empty sequence or end eery
sequence with a fixed item so that I will now it is end and not a real
item. In my opinion the extra effort would still be less than with the
lists while overall "user experience" would be better. (At the expense of
complicating my own code - but I'm ready to accept that.)
 
Does anyone of you ever did something like that? Guidelines? Ideas? How do
sequence function deal with empty sequences? If I would pass to
BOOST_PP_SEQ_ENUM a result of BOOST_PP_SEQ_POP_FRONT on a single-element
sequence would it work fine (enumerate nothing)? Or it is not guaranteed?



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