<small id='GrK7Y'></small><noframes id='GrK7Y'>

      <tfoot id='GrK7Y'></tfoot>
        <bdo id='GrK7Y'></bdo><ul id='GrK7Y'></ul>
    1. <legend id='GrK7Y'><style id='GrK7Y'><dir id='GrK7Y'><q id='GrK7Y'></q></dir></style></legend>

      1. <i id='GrK7Y'><tr id='GrK7Y'><dt id='GrK7Y'><q id='GrK7Y'><span id='GrK7Y'><b id='GrK7Y'><form id='GrK7Y'><ins id='GrK7Y'></ins><ul id='GrK7Y'></ul><sub id='GrK7Y'></sub></form><legend id='GrK7Y'></legend><bdo id='GrK7Y'><pre id='GrK7Y'><center id='GrK7Y'></center></pre></bdo></b><th id='GrK7Y'></th></span></q></dt></tr></i><div id='GrK7Y'><tfoot id='GrK7Y'></tfoot><dl id='GrK7Y'><fieldset id='GrK7Y'></fieldset></dl></div>

        boost::date_time 和 std::chrono 之间的互操作性

        Interoperability between boost::date_time and std::chrono(boost::date_time 和 std::chrono 之间的互操作性)

          <tfoot id='uDx0N'></tfoot>

          <small id='uDx0N'></small><noframes id='uDx0N'>

          <i id='uDx0N'><tr id='uDx0N'><dt id='uDx0N'><q id='uDx0N'><span id='uDx0N'><b id='uDx0N'><form id='uDx0N'><ins id='uDx0N'></ins><ul id='uDx0N'></ul><sub id='uDx0N'></sub></form><legend id='uDx0N'></legend><bdo id='uDx0N'><pre id='uDx0N'><center id='uDx0N'></center></pre></bdo></b><th id='uDx0N'></th></span></q></dt></tr></i><div id='uDx0N'><tfoot id='uDx0N'></tfoot><dl id='uDx0N'><fieldset id='uDx0N'></fieldset></dl></div>
            <tbody id='uDx0N'></tbody>
            <bdo id='uDx0N'></bdo><ul id='uDx0N'></ul>
                  <legend id='uDx0N'><style id='uDx0N'><dir id='uDx0N'><q id='uDx0N'></q></dir></style></legend>

                  本文介绍了boost::date_time 和 std::chrono 之间的互操作性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  boost::date_time 和 std::chrono 的互操作性如何?

                  How interoperable are boost::date_time and std::chrono?

                  例如,有没有办法在 boost::posix_time::ptime 和 std::chrono::time_point 之间转换?

                  For example, is there a way to convert between boost::posix_time::ptime and std::chrono::time_point?

                  我尝试搜索有关此类转换的文档,但找不到任何文档.

                  I tried searching for documentation on such conversions but couldn't find any.

                  推荐答案

                  我在 boost 提交邮件列表中找到了这个:http://lists.boost.org/boost-commit/2009/04/15209.php

                  I found this on the boost commits mailing list: http://lists.boost.org/boost-commit/2009/04/15209.php

                  以下是相关函数:

                  template < class Clock, class Duration> 
                  struct convert_to<posix_time::ptime, chrono::time_point<Clock, Duration> > { 
                      inline static posix_time::ptime apply(const chrono::time_point<Clock, Duration>& from) 
                      { 
                          typedef chrono::time_point<Clock, Duration> time_point_t; 
                          typedef chrono::nanoseconds duration_t; 
                          typedef duration_t::rep rep_t; 
                          rep_t d = chrono::duration_cast<duration_t>(from.time_since_epoch()).count(); 
                          rep_t sec = d/1000000000; 
                          rep_t nsec = d%1000000000; 
                          return boost::posix_time::from_time_t(0)+ 
                          boost::posix_time::seconds(static_cast<long>(sec))+ 
                          #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS 
                          boost::posix_time::nanoseconds(nsec); 
                          #else 
                          boost::posix_time::microseconds((nsec+500)/1000); 
                          #endif 
                      } 
                  }; 
                  
                  template < class Clock, class Duration> 
                  struct convert_to<chrono::time_point<Clock, Duration>, posix_time::ptime> { 
                      inline static chrono::time_point<Clock, Duration> apply(const posix_time::ptime& from) 
                      { 
                          boost::posix_time::time_duration const time_since_epoch=from-boost::posix_time::from_time_t(0); 
                          chrono::time_point<Clock, Duration> t=chrono::system_clock::from_time_t(time_since_epoch.total_seconds()); 
                          long nsec=time_since_epoch.fractional_seconds()*(1000000000/time_since_epoch.ticks_per_second()); 
                          return t+chrono::nanoseconds(nsec); 
                  
                      } 
                  }; 
                  

                  我不确定它们何时会成为 Boost 版本的一部分.他们现在似乎不在升压后备箱中...

                  I'm not sure when they're going to become part of a boost release. They don't seem to be in boost trunk right now...

                  这篇关于boost::date_time 和 std::chrono 之间的互操作性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to limit the number of running instances in C++(C++中如何限制运行实例的数量)
                  Using boost::asio::async_read with stdin?(将 boost::asio::async_read 与 stdin 一起使用?)
                  How to find out what dependencies (i.e other Boost libraries) a particular Boost library requires?(如何找出特定 Boost 库需要哪些依赖项(即其他 Boost 库)?)
                  What#39;s the purpose of a leading quot;::quot; in a C++ method call(引导“::的目的是什么?在 C++ 方法调用中)
                  Boost Spirit x3: parse into structs(Boost Spirit x3:解析为结构体)
                  How boost auto-linking makes choice?(boost自动链接如何做出选择?)
                    <bdo id='fykSV'></bdo><ul id='fykSV'></ul>

                    <legend id='fykSV'><style id='fykSV'><dir id='fykSV'><q id='fykSV'></q></dir></style></legend>
                    <i id='fykSV'><tr id='fykSV'><dt id='fykSV'><q id='fykSV'><span id='fykSV'><b id='fykSV'><form id='fykSV'><ins id='fykSV'></ins><ul id='fykSV'></ul><sub id='fykSV'></sub></form><legend id='fykSV'></legend><bdo id='fykSV'><pre id='fykSV'><center id='fykSV'></center></pre></bdo></b><th id='fykSV'></th></span></q></dt></tr></i><div id='fykSV'><tfoot id='fykSV'></tfoot><dl id='fykSV'><fieldset id='fykSV'></fieldset></dl></div>

                    • <tfoot id='fykSV'></tfoot>
                    • <small id='fykSV'></small><noframes id='fykSV'>

                              <tbody id='fykSV'></tbody>