Spicy
Classes | Public Member Functions | List of all members
hilti::rt::Interval Class Reference

#include <interval.h>

Classes

struct  NanosecondTag
 
struct  SecondTag
 

Public Member Functions

 Interval (hilti::rt::integer::safe< int64_t > nsecs, NanosecondTag)
 
 Interval (double secs, SecondTag)
 
 Interval (const Interval &)=default
 
 Interval (Interval &&) noexcept=default
 
Intervaloperator= (const Interval &)=default
 
Intervaloperator= (Interval &&) noexcept=default
 
double seconds () const
 
int64_t nanoseconds () const
 
bool operator== (const Interval &other) const
 
bool operator!= (const Interval &other) const
 
bool operator< (const Interval &other) const
 
bool operator<= (const Interval &other) const
 
bool operator> (const Interval &other) const
 
bool operator>= (const Interval &other) const
 
Interval operator+ (const Interval &other) const
 
Interval operator- (const Interval &other) const
 
Interval operator* (hilti::rt::integer::safe< std::int64_t > i) const
 
Interval operator* (hilti::rt::integer::safe< std::uint64_t > i) const
 
Interval operator* (double i) const
 
 operator bool () const
 
 operator std::string () const
 

Detailed Description

Represents HILTI's interval type. Intervals are stored with nanoseconds resolution. Intervals can be either positive or negative.

Constructor & Destructor Documentation

◆ Interval() [1/2]

hilti::rt::Interval::Interval ( hilti::rt::integer::safe< int64_t >  nsecs,
NanosecondTag   
)
inlineexplicit

Constructs an interval from an signed integer value.

Parameters
nsecsinterval in nanoseconds.

◆ Interval() [2/2]

hilti::rt::Interval::Interval ( double  secs,
SecondTag   
)
inlineexplicit

Constructs an interval from a double value.

Parameters
secsinterval in seconds.
Exceptions
OutOfRangeif secs cannot be represented with the internal resolution

Member Function Documentation

◆ nanoseconds()

int64_t hilti::rt::Interval::nanoseconds ( ) const
inline

Returns interval as nanoseconds.

◆ operator bool()

hilti::rt::Interval::operator bool ( ) const
inlineexplicit

Returns true if the interval is non-zero.

◆ operator std::string()

hilti::rt::Interval::operator std::string ( ) const
inline

Returns a humand-readable representation of the interval.

◆ seconds()

double hilti::rt::Interval::seconds ( ) const
inline

Returns interval as seconds.


The documentation for this class was generated from the following file: