Boost C++ Libraries: Ticket #11067: boost::gregorian::date_iterator missing postfix operators ++ and -- https://svn.boost.org/trac10/ticket/11067 <p> /* Consider the following (somewhat canonical) code snippet */ { </p> <blockquote> <p> std::vector&lt;boost::gregorian::date&gt; dates(count); auto dt_i = dates.begin(); boost::gregorian::month_iterator m_i(some_start_date, 1); </p> </blockquote> <blockquote> <p> while (dt_i != dts.end()) </p> <blockquote> <p> *dt_i++ = *m_i++; /* this will call prefix ++ operator on m_i </p> <blockquote> <p> leading to subtle bug */ </p> </blockquote> </blockquote> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11067 Trac 1.4.3 James E. King, III Wed, 27 Dec 2017 19:39:12 GMT owner, status changed https://svn.boost.org/trac10/ticket/11067#comment:1 https://svn.boost.org/trac10/ticket/11067#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">az_sw_dude</span> to <span class="trac-author">James E. King, III</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Test (unsure if return is correct; will move into unit test before submitting PR): </p> <pre class="wiki">#include &lt;boost/date_time/gregorian/gregorian.hpp&gt; int main() { boost::gregorian::date some_date(2007, 8, 9); boost::gregorian::month_iterator m_i(some_date, 1); boost::gregorian::greg_month m(1); m = *m_i++; return !(m == 8); } </pre><p> When building with gcc-7.2 and -Wall: </p> <pre class="wiki">gcc.compile.c++ ../../../bin.v2/libs/date_time/test/testdate_iterator.test/gcc-gnu-7/debug/threadapi-pthread/gregorian/testdate_iterator.o gregorian/testdate_iterator.cpp: In function ‘int main()’: gregorian/testdate_iterator.cpp:63:20: error: no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive] date chk = *m_i++; ~~~^~ gregorian/testdate_iterator.cpp:67:15: error: no ‘operator--(int)’ declared for postfix ‘--’ [-fpermissive] chk = *m_i--; ~~~^~ "g++" -O0 -fno-inline -Wall -g -fPIC -m64 -Wunused-local-typedefs -DBOOST_ALL_NO_LIB -DBOOST_ALL_NO_LIB=1 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_DATE_TIME_STATIC_LINK -DDATE_TIME_INLINE -I"../../.." -c -o "../../../bin.v2/libs/date_time/test/testdate_iterator.test/gcc-gnu-7/debug/threadapi-pthread/gregorian/testdate_iterator.o" "gregorian/testdate_iterator.cpp" </pre> Ticket James E. King, III Thu, 28 Dec 2017 13:35:12 GMT <link>https://svn.boost.org/trac10/ticket/11067#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11067#comment:2</guid> <description> <p> postfix operator implementation requires return-by-value, and in this case the get_offset and get_neg_offset methods are pure virtual, making that impossible in the current implementation. </p> </description> <category>Ticket</category> </item> </channel> </rss>