Re: [Boost-bugs] [Boost C++ Libraries] #6989: BOOST_PP_SEQ_ELEM/BOOST_PP_IF behave differently on different compilers

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6989: BOOST_PP_SEQ_ELEM/BOOST_PP_IF behave differently on different compilers
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-17 03:07:15


#6989: BOOST_PP_SEQ_ELEM/BOOST_PP_IF behave differently on different compilers
-------------------------------+---------------------------
  Reporter: vanyacpp@… | Owner: no-maintainer
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: preprocessor
   Version: Boost 1.49.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+---------------------------

Comment (by eldiener):

 Gcc is correct and MSVC is wrong. The proper way to write such code is:

 {{{

 #define HANDLE_SIZE_EQ_1(seq)

 #define HANDLE_SIZE_EQ_2(seq) \
     BOOST_PP_SEQ_ELEM(1, seq)

 #define TEST_IF(seq) \
     BOOST_PP_IF(BOOST_PP_NOT_EQUAL(2, BOOST_PP_SEQ_SIZE(seq)), \
     HANDLE_SIZE_EQ_1, \
     HANDLE_SIZE_EQ_2) \
     (seq)

 TEST_IF((a))

 }}}

 The code will work on VC++ and gcc. This is not a bug in the preprocessor
 but in your code.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6989#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 : 2017-02-16 18:50:18 UTC