Re: [Boost-bugs] [Boost C++ Libraries] #13372: Boost Preprocessing: compiler error: macro "BOOST_PP_VARIADIC_ELEM_2" requires 4 arguments, but only 2 given

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #13372: Boost Preprocessing: compiler error: macro "BOOST_PP_VARIADIC_ELEM_2" requires 4 arguments, but only 2 given
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-01-27 09:10:21


#13372: Boost Preprocessing: compiler error: macro "BOOST_PP_VARIADIC_ELEM_2"
requires 4 arguments, but only 2 given
------------------------------------+---------------------------
  Reporter: Dmitrii B <d4qcdes@…> | Owner: No-Maintainer
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: preprocessor
   Version: Boost 1.64.0 | Severity: Problem
Resolution: | Keywords:
------------------------------------+---------------------------

Comment (by Dmitry B <d4qcdes@…>):

 It seems that the reason is

 {{{
 BOOST_PP_TUPLE_ELEM(2, (El1))
 }}}
 doesn't compile with an error

 {{{
 error: macro "BOOST_PP_VARIADIC_ELEM_2" requires 4 arguments, but only 2
 given
 }}}
 in the same time
 {{{
 BOOST_PP_TUPLE_ELEM(2, (El1,))
 }}}
 compiles

 so, I have simplified the repro a bit:
 {{{
 #include <boost/preprocessor.hpp>

 #define TUPLE_WITH_ONE_ELEMENT_WITHOUT_COMMA_AT_THE_END (a)
 #define TUPLE_WITH_ONE_ELEMENT_WITH_COMMA_AT_THE_END (a,)

 #define DEFINE_VARIABLE(tupleWithVariable)
 \
     BOOST_PP_IF(0,
 \
         BOOST_PP_TUPLE_ELEM(2, tupleWithVariable),
 \
         BOOST_PP_TUPLE_ELEM(0, tupleWithVariable)
 \
     )

 int DEFINE_VARIABLE(TUPLE_WITH_ONE_ELEMENT_WITHOUT_COMMA_AT_THE_END); //
 doesn't compile
 int DEFINE_VARIABLE(TUPLE_WITH_ONE_ELEMENT_WITH_COMMA_AT_THE_END);

 int main() {
         return 0;
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13372#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2018-01-27 09:14:36 UTC