Opened 10 years ago
Closed 7 years ago
#7560 closed Bugs (fixed)
[preprocessor] empty tuples are reported to have length equal to 1
Reported by: | Owned by: | No-Maintainer | |
---|---|---|---|
Milestone: | To Be Determined | Component: | preprocessor |
Version: | Boost 1.50.0 | Severity: | Problem |
Keywords: | tuple empty 0 length size | Cc: |
Description
BOOST_PP_TUPLE_SIZE(()) expands to 1 under gcc with c++0x support enabled
gcc --version gcc (GCC) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc.
Change History (8)
comment:1 by , 10 years ago
comment:3 by , 10 years ago
Replying to steven_watanabe:
() is indeed considered a one element tuple.
Thank you Steven, that does make a lot of sence. In this case I should perhaps look into sugesting modifications to make it more obvious on the documentation.
comment:4 by , 10 years ago
Severity: | Showstopper → Problem |
---|
Downgrading the severity from showstopper to problem, since it turns out to be a documentation problem only.
comment:5 by , 9 years ago
It exists in documentation: "Valid tuple sizes range from 1 to BOOST_PP_LIMIT_TUPLE." (http://www.boost.org/doc/libs/1_54_0/libs/preprocessor/doc/ref/tuple_elem.html)
But would be good to have it on the main tuple page as well, not only on tuple_elem page.
comment:6 by , 7 years ago
The documentation on the tuple data type has been updated in the 'develop' branch of the preprocessor library to explain that a tuple can never be empty and have a size of 0.
comment:8 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
First of all I must thank the effor all the developers have clearly put into developing the Preprocessor library. It really is an amazing work.
Back to the topic, now thinking about it, maybe () is indeed intended to be a 1-element tuple, following the fact, that an empty macro argument is still an argument since C99 and also C++11. That would ofcourse mean there is no such thing as an empty tuple as implemented by the Preprocessor library, but nonetheless, since there is no mention of such behavior on the documentation, one might be induced to understand, that an empty tuple is in fact well defined. Finaly, due to the fact this behaviour is dependent of one's subjective interpretation, as I see it this issue still configures a bug, at least a documentation one.
Should however the reported behavior be confirmed as not intended, JENS GUSTEDT proposes a solution to the "problem of detecting empty variadic macro arguments" here: http://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/, which I would be glad to implement as a patch, once the intended behavior is well clarified.