Re: [Boost-bugs] [Boost C++ Libraries] #11631: boost chrono io v2 does not let you support custom clocks

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11631: boost chrono io v2 does not let you support custom clocks
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-09-10 17:47:11


#11631: boost chrono io v2 does not let you support custom clocks
--------------------------------------------------+----------------------
  Reporter: Sébastien Barthélémy <barthelemy@…> | Owner: viboes
      Type: Bugs | Status: assigned
 Milestone: Boost 1.60.0 | Component: chrono
   Version: Boost 1.58.0 | Severity: Problem
Resolution: | Keywords:
--------------------------------------------------+----------------------
Changes (by viboes):

 * milestone: To Be Determined => Boost 1.60.0

Comment:

 I think that I have found a way the user can customize the Clock string. I
 don't know however how it can customize it depending on a specific locale.

 The trick is to use an indirection


 {{{
       template <typename Clock>
       string_type get_epoch() const
       {
         return get_epoch_custom<CharT>(Clock(), *this);
       }
 }}}


 where get_epoch_custom just forwards again to the facet.


 {{{
     template <typename CharT, typename Clock, typename TPUFacet>
     std::basic_string<CharT> get_epoch_custom(Clock, TPUFacet& f)
     {
       return f.do_get_epoch(Clock());
     }
 }}}


 The user can specialize its onw Clock by overloading this customization
 function.


 {{{
 template <typename CharT, typename TPUFacet>
 std::basic_string<CharT> get_epoch_custom(MyMillenniumClock, TPUFacet&)
 {
   return boost::chrono::clock_string<MyMillenniumClock,CharT>::since();
 }
 }}}


 Committed in master branch
 https://github.com/boostorg/chrono/commit/533851116fa2c3870e05d878a9cc9c82c4b93fa1

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11631#comment:2>
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:19 UTC