summaryrefslogtreecommitdiff
path: root/examples/cxx/parser/performance/time.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-12-18 18:48:46 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-02-25 13:45:48 +0300
commit5e527213a2430bb3018e5eebd909aef294edf9b5 (patch)
tree94de33c82080b53d9a9e300170f6d221d89078f4 /examples/cxx/parser/performance/time.hxx
parent7420f85ea19b0562ffdd8123442f32bc8bac1267 (diff)
Switch to build2
Diffstat (limited to 'examples/cxx/parser/performance/time.hxx')
-rw-r--r--examples/cxx/parser/performance/time.hxx110
1 files changed, 0 insertions, 110 deletions
diff --git a/examples/cxx/parser/performance/time.hxx b/examples/cxx/parser/performance/time.hxx
deleted file mode 100644
index 3b2f040..0000000
--- a/examples/cxx/parser/performance/time.hxx
+++ /dev/null
@@ -1,110 +0,0 @@
-// file : examples/cxx/parser/performance/time.hxx
-// copyright : not copyrighted - public domain
-
-#ifndef TIME_HXX
-#define TIME_HXX
-
-#include <iosfwd> // std::ostream&
-
-namespace os
-{
- class time
- {
- public:
- class failed {};
-
- // Create a time object representing the current time.
- //
- time ();
-
- time (unsigned long long nsec)
- {
- sec_ = static_cast<unsigned long> (nsec / 1000000000ULL);
- nsec_ = static_cast<unsigned long> (nsec % 1000000000ULL);
- }
-
- time (unsigned long sec, unsigned long nsec)
- {
- sec_ = sec;
- nsec_ = nsec;
- }
-
- public:
- unsigned long
- sec () const
- {
- return sec_;
- }
-
- unsigned long
- nsec () const
- {
- return nsec_;
- }
-
- public:
- class overflow {};
- class underflow {};
-
- time
- operator+= (time const& b)
- {
- unsigned long long tmp = 0ULL + nsec_ + b.nsec_;
-
- sec_ += static_cast<unsigned long> (b.sec_ + tmp / 1000000000ULL);
- nsec_ = static_cast<unsigned long> (tmp % 1000000000ULL);
-
- return *this;
- }
-
- time
- operator-= (time const& b)
- {
- if (*this < b)
- throw underflow ();
-
- sec_ -= b.sec_;
-
- if (nsec_ < b.nsec_)
- {
- --sec_;
- nsec_ += 1000000000ULL - b.nsec_;
- }
- else
- nsec_ -= b.nsec_;
-
- return *this;
- }
-
- friend time
- operator+ (time const& a, time const& b)
- {
- time r (a);
- r += b;
- return r;
- }
-
- friend time
- operator- (time const& a, time const& b)
- {
- time r (a);
- r -= b;
- return r;
- }
-
- friend bool
- operator < (time const& a, time const& b)
- {
- return (a.sec_ < b.sec_) || (a.sec_ == b.sec_ && a.nsec_ < b.nsec_);
- }
-
- private:
- unsigned long sec_;
- unsigned long nsec_;
- };
-
- std::ostream&
- operator<< (std::ostream&, time const&);
-}
-
-#endif // TIME_HXX