Boost C++ Libraries: Ticket #10992: Chrono IO state savers inconsistent with Boost.IO state savers https://svn.boost.org/trac10/ticket/10992 <p> The constructors of Boost.IO state savers taking the second new_value argument set the state to the new_value immediately and restore the previous state upon destruction. OTOH, the Boost.Chrono IO state savers do something different (and arguably unintuitive): they don't alter the state upon construction at all and restore the state to new_value rather than the previous state upon destruction. The behaviour should be aligned with that of Boost.IO to avoid confusion and make it more useful. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10992 Trac 1.4.3 viboes Mon, 16 Feb 2015 15:10:39 GMT <link>https://svn.boost.org/trac10/ticket/10992#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10992#comment:1</guid> <description> <p> Please, could you be more explicit? </p> <p> Are you referring to </p> <pre class="wiki"> struct duration_style_io_saver { //! the type of the state to restore typedef std::ios_base state_type; //! the type of aspect to save typedef duration_style aspect_type; /** * Explicit construction from an i/o stream. * * Store a reference to the i/o stream and the value of the associated @c duration_style. */ explicit duration_style_io_saver(state_type &amp;s) : s_save_(s) { a_save_ = get_duration_style(s_save_); } /** * Construction from an i/o stream and a @c duration_style to restore. * * Stores a reference to the i/o stream and the value @c duration_style to restore given as parameter. */ duration_style_io_saver(state_type &amp;s, aspect_type new_value) : s_save_(s), a_save_(new_value) { } /** * Destructor. * * Restores the i/o stream with the duration_style to be restored. */ ~duration_style_io_saver() { this-&gt;restore(); } /** * Restores the i/o stream with the duration_style to be restored. */ void restore() { set_duration_style(s_save_, a_save_); } private: duration_style_io_saver&amp; operator=(duration_style_io_saver const&amp; rhs) ; state_type&amp; s_save_; aspect_type a_save_; }; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 16 Feb 2015 15:12:51 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/10992#comment:2 https://svn.boost.org/trac10/ticket/10992#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket rkawulak Mon, 16 Feb 2015 22:59:52 GMT <link>https://svn.boost.org/trac10/ticket/10992#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10992#comment:3</guid> <description> <p> Yes. The second constructor should be implemented the following way to be consistent with IO state saver semantics (see for example <a class="ext-link" href="https://github.com/boostorg/io/blob/93932c0d55241c6d06a05b0270ca0d4a95a2f133/include/boost/io/ios_state.hpp#L119"><span class="icon">​</span>basic_ios_iostate_saver</a>): </p> <pre class="wiki">duration_style_io_saver(state_type &amp;s, aspect_type new_value) : s_save_(s), a_save_(get_duration_style(s)) { set_duration_style(s, new_value); } </pre><p> The same for all the remaining Chrono IO state savers. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 16 Feb 2015 23:27:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10992#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10992#comment:4</guid> <description> <p> Thanks for catching this point. I missed it completly. I should stop adding code that I don't test. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 16 Feb 2015 23:29:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10992#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10992#comment:5</guid> <description> <p> Have you find other cases? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>rkawulak</dc:creator> <pubDate>Tue, 17 Feb 2015 00:01:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10992#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10992#comment:6</guid> <description> <p> IIRC, all IO state savers in Chrono library are implemented this way. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 17 Feb 2015 00:25:31 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/10992#comment:7 https://svn.boost.org/trac10/ticket/10992#comment:7 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.58.0</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/chrono/commit/d08ef2352a68a8b616c7e14cf30066204907f019"><span class="icon">​</span>https://github.com/boostorg/chrono/commit/d08ef2352a68a8b616c7e14cf30066204907f019</a> </p> Ticket rkawulak Fri, 27 Feb 2015 04:21:46 GMT <link>https://svn.boost.org/trac10/ticket/10992#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10992#comment:8</guid> <description> <p> Seems that not all documentation comments have been updated accordingly. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 27 Feb 2015 18:19:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10992#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10992#comment:9</guid> <description> <p> Ok, I will take a look. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 09 Mar 2015 07:26:02 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10992#comment:10 https://svn.boost.org/trac10/ticket/10992#comment:10 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/chrono/commit/ec29de7bf0ea3a83ee54f449438624f8c15c8139"><span class="icon">​</span>https://github.com/boostorg/chrono/commit/ec29de7bf0ea3a83ee54f449438624f8c15c8139</a> </p> Ticket