Re: [Boost-bugs] [Boost C++ Libraries] #4400: BOOST_PP_SEQ_REPLACE fails in corner cases

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4400: BOOST_PP_SEQ_REPLACE fails in corner cases
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-24 17:49:41

#4400: BOOST_PP_SEQ_REPLACE fails in corner cases
  Reporter: Wolf Lammen <ookami1@…> | Owner: no-maintainer
      Type: Bugs | Status: new
 Milestone: Boost 1.44.0 | Component: preprocessor
   Version: Boost 1.44.0 | Severity: Problem
Resolution: | Keywords:

Comment (by ookami1@…):

 After having looked at your solution, here are my comments:

 Lets look at BOOST_PP_SEQ_REPLACE((a),0,b)

 I can tell from the list of replacements that you somewhere in the middle


 expecting it to return an empty replacement.

 Ok, we know both, BOOST_PP_SEQ_FIRST_N does the right thing by pure chance
 and returns an empty sequence. But given your formalistic stance,
 shouldn't usage of index 0 with BOOST_PP_SEQ_FIRST_N be banned as much as
 BOOST_PP_SEQ_REST_N is with an index == size of sequence? Don't you rely
 on undefined behavior as well?

 And your solution comes with a price: The number of replacements increases
 from 28 to 38 in the above simple case, goes up from 57 to 117 in a
 24-element sequence, such getting worse by the size. Another minor fault
 is the different spacing in the part before a replacement and after it:
 "(a) (a) (a) (b) (a)(a)(a)". This is less of a problem as long as you do
 just macro magic, but becomes essentiell once you stringize a sequence as
 I did.

 See, you and Mr Mensonides had difficulties in getting these things right,
 let alone an averaged programmer like me. If you ask me, I still prefer a
 change in interface and let BOOST_PP_SEQ_FIRST_N and BOOST_PP_SEQ_REST_N
 either return a sequence, if exists, or an empty string, in the range
 0..size of seq. This is the right result in all instances where you
 concatenate sequences, and it does not hurt elsewhere.

 cheers Wolf

Ticket URL: <>
Boost C++ Libraries <>
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