[Nfd-dev] Question about std::chrono::duration conversion to/from time::duration
Junxiao Shi
shijunxiao at email.arizona.edu
Thu Nov 13 15:17:41 PST 2014
Hi Alex
We can:
- declare time::duration<Rep, Period> as a new class that inherits from
boost::chrono::duration<Rep, Period>
- in time::duration<Rep, Period>, provide an implicit conversion
function to std::chrono::duration<Rep2, Period2>, and use enable_if to
restrict the equivalence of Rep-Rep2 and Period-Period2
- in time::duration<Rep, Period>, provide an implicit constructor from
std::chrono::duration<Rep2, Period2>, and use enable_if to restrict the
equivalence of Rep-Rep2 and Period-Period2
The alternate is:
- typedef std::chrono::duration as time::duration
- implement operator<<(std::ostream&, time::duration) overloads that
prints the duration by internally converting to boost::chrono::duration
Yours, Junxiao
On Thu, Nov 13, 2014 at 3:25 PM, Alex Afanasyev <
alexander.afanasyev at ucla.edu> wrote:
>
> > On Nov 13, 2014, at 1:58 PM, Junxiao Shi <shijunxiao at email.arizona.edu>
> wrote:
> >
> > Dear folks
> >
> > Whether ndn::time is using boost::chrono or std::chrono shall be an
> implementation detail.
> > I think we should provide implicit conversion operators between
> ndn::time::duration<Rep,Period> and std::chrono::duration<Rep,Period>, when
> Rep is the same and Period is equivalent.
>
> Is there a way to do it without us creating our own class? I don’t seem
> to find a simple way for that. I really don’t want us to create duration
> class and implement everything that is implemented in std/boost::chrono
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/nfd-dev/attachments/20141113/4055d04c/attachment.html>
More information about the Nfd-dev
mailing list