Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
std::chrono::duration< Rep, Period > Class Template Reference

Forward declaration of duration class template. More...

Public Types

using period = Period
 The period type representing the tick period in seconds.
 
using rep = Rep
 The arithmetic type representing the number of ticks.
 

Public Member Functions

constexpr duration () noexcept(is_nothrow_default_constructible_v< rep >)
 Default constructor Initializes the duration with a zero tick count.
 
template<typename Rep2, typename Period2, arene::base::constraints< enable_if_t< is_convertible_v< Rep2 const &, rep > >, enable_if_t< chrono_detail::check_conversion_overflow< Period2, period >::value >, enable_if_t< treat_as_floating_point_v< rep >||(ratio_divide< Period2, period >::den==1 &&!treat_as_floating_point_v< Rep2 >)>>
constexpr duration (duration< Rep2, Period2 > const &other) noexcept(noexcept(duration_cast< duration >(std::declval< duration< Rep2, Period2 > const & >()).count()) &&//is_nothrow_constructible_v< rep, >)
 Constructor from another duration type.
 
template<typename Rep2, arene::base::constraints< enable_if_t< is_convertible_v< Rep2 const &, rep > >, enable_if_t< treat_as_floating_point_v< rep >||!treat_as_floating_point_v< Rep2 > > > = nullptr>
constexpr duration (Rep2 const &rep_in) noexcept(is_nothrow_copy_constructible_v< rep > &&is_nothrow_constructible_v< rep, Rep2 const & >)
 Constructor from a representation value.
 
constexpr auto count () const noexcept(is_nothrow_copy_constructible_v< rep >) -> rep
 Returns the tick count.
 
constexpr auto operator%= (duration const &rhs) noexcept(noexcept(declval< rep & >() %=rhs.count())) -> duration &
 Compound modulo assignment operator with duration.
 
constexpr auto operator%= (rep const &rhs) noexcept(noexcept(declval< rep & >() %=rhs)) -> duration &
 Compound modulo assignment operator with scalar.
 
constexpr auto operator*= (rep const &rhs) noexcept(noexcept(declval< rep & >() *=rhs)) -> duration &
 Compound multiplication assignment operator.
 
constexpr auto operator+ () const noexcept(is_nothrow_copy_constructible_v< duration >) -> duration
 Unary plus operator.
 
constexpr auto operator++ () noexcept(noexcept(++declval< rep & >())) -> duration &
 Pre-increment operator.
 
constexpr auto operator++ (int) noexcept(is_nothrow_copy_constructible_v< duration > &&noexcept(++declval< rep & >())) -> duration
 Post-increment operator.
 
constexpr auto operator+= (duration const &rhs) noexcept(noexcept(declval< rep & >()+=rhs.count())) -> duration &
 Compound addition assignment operator.
 
constexpr auto operator- () const noexcept(is_nothrow_constructible_v< duration, rep >) -> duration
 Unary minus operator.
 
constexpr auto operator-- () noexcept(noexcept(--declval< rep & >())) -> duration &
 Pre-decrement operator.
 
constexpr auto operator-- (int) noexcept(is_nothrow_copy_constructible_v< duration > &&noexcept(--declval< rep & >())) -> duration
 Post-decrement operator.
 
constexpr auto operator-= (duration const &rhs) noexcept(noexcept(declval< rep & >() -=rhs.count())) -> duration &
 Compound subtraction assignment operator.
 
constexpr auto operator/= (rep const &rhs) noexcept(noexcept(declval< rep & >()/=rhs)) -> duration &
 Compound division assignment operator.
 

Static Public Member Functions

static constexpr auto max () noexcept(noexcept(duration(duration_values< rep >::max()))) -> duration
 Get a maximally positive duration.
 
static constexpr auto min () noexcept(noexcept(duration(duration_values< rep >::min()))) -> duration
 Get a minimally positive duration (for signed representations, a maximally negative duration)
 
static constexpr auto zero () noexcept(noexcept(duration(duration_values< rep >::zero()))) -> duration
 Get a duration of length zero, corresponding to no time passing.
 

Detailed Description

template<typename Rep, typename Period>
class std::chrono::duration< Rep, Period >

Forward declaration of duration class template.

A time interval represented as a count of ticks of a given period.

The duration class template represents a time interval. It consists of a count of ticks of type Rep and a tick period, where the tick period is a compile-time rational fraction representing the number of seconds from one tick to the next.

Template Parameters
RepAn arithmetic type or a class emulating an arithmetic type, representing the type of the tick count. Must not be a specialization of duration.
PeriodA specialization of std::ratio, representing the tick period in seconds. Must be positive. Defaults to std::ratio<1> (1 second).

Member Typedef Documentation

◆ period

template<typename Rep, typename Period>
using std::chrono::duration< Rep, Period >::period = Period

The period type representing the tick period in seconds.

◆ rep

template<typename Rep, typename Period>
using std::chrono::duration< Rep, Period >::rep = Rep

The arithmetic type representing the number of ticks.

Constructor & Destructor Documentation

◆ duration() [1/3]

template<typename Rep, typename Period>
std::chrono::duration< Rep, Period >::duration ( )
inlineconstexprnoexcept

Default constructor Initializes the duration with a zero tick count.

◆ duration() [2/3]

template<typename Rep, typename Period>
template<typename Rep2, arene::base::constraints< enable_if_t< is_convertible_v< Rep2 const &, rep > >, enable_if_t< treat_as_floating_point_v< rep >||!treat_as_floating_point_v< Rep2 > > > = nullptr>
std::chrono::duration< Rep, Period >::duration ( Rep2 const & rep_in)
inlineexplicitconstexprnoexcept

Constructor from a representation value.

Template Parameters
Rep2The type of the input representation value, must be convertible to Rep
Parameters
rep_inThe tick count value to initialize the duration with

◆ duration() [3/3]

template<typename Rep, typename Period>
template<typename Rep2, typename Period2, arene::base::constraints< enable_if_t< is_convertible_v< Rep2 const &, rep > >, enable_if_t< chrono_detail::check_conversion_overflow< Period2, period >::value >, enable_if_t< treat_as_floating_point_v< rep >||(ratio_divide< Period2, period >::den==1 &&!treat_as_floating_point_v< Rep2 >)>>
std::chrono::duration< Rep, Period >::duration ( duration< Rep2, Period2 > const & other)
inlineconstexprnoexcept

Constructor from another duration type.

Template Parameters
Rep2The representation type of the source duration
Period2The period type of the source duration
Parameters
otherThe source duration to convert from

Note: The standard specifies that "This constructor shall not participate in overload resolution unless no overflow is induced in the conversion". It is unclear what overflow should be checked, and different standard library implementations take different approaches. This implementation aims for compatibility with the approaches taken by libc++ and libstdc++.

Member Function Documentation

◆ count()

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::count ( ) const -> rep
inlineconstexprnoexcept

Returns the tick count.

Returns
The tick count as a value of type rep

◆ max()

template<typename Rep, typename Period>
static constexpr auto std::chrono::duration< Rep, Period >::max ( ) -> duration
inlinestaticconstexprnoexcept

Get a maximally positive duration.

Returns
A maximal duration

◆ min()

template<typename Rep, typename Period>
static constexpr auto std::chrono::duration< Rep, Period >::min ( ) -> duration
inlinestaticconstexprnoexcept

Get a minimally positive duration (for signed representations, a maximally negative duration)

Returns
A minimal duration

◆ operator%=() [1/2]

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator%= ( duration< Rep, Period > const & rhs) -> duration&
inlineconstexprnoexcept

Compound modulo assignment operator with duration.

Parameters
rhsThe duration to compute modulo with
Returns
Reference to this duration after modulo operation

◆ operator%=() [2/2]

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator%= ( rep const & rhs) -> duration&
inlineconstexprnoexcept

Compound modulo assignment operator with scalar.

Parameters
rhsThe scalar to compute modulo with
Returns
Reference to this duration after modulo operation

◆ operator*=()

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator*= ( rep const & rhs) -> duration&
inlineconstexprnoexcept

Compound multiplication assignment operator.

Parameters
rhsThe scalar to multiply by
Returns
Reference to this duration after multiplication

◆ operator+()

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator+ ( ) const -> duration
inlineconstexprnoexcept

Unary plus operator.

Returns
A copy of this duration

◆ operator++() [1/2]

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator++ ( ) -> duration&
inlineconstexprnoexcept

Pre-increment operator.

Returns
Reference to this duration after incrementing

◆ operator++() [2/2]

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator++ ( int ) -> duration
inlineconstexprnoexcept

Post-increment operator.

Returns
Copy of this duration before incrementing

◆ operator+=()

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator+= ( duration< Rep, Period > const & rhs) -> duration&
inlineconstexprnoexcept

Compound addition assignment operator.

Parameters
rhsThe duration to add
Returns
Reference to this duration after addition

◆ operator-()

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator- ( ) const -> duration
inlineconstexprnoexcept

Unary minus operator.

Returns
A duration with negated representation

◆ operator--() [1/2]

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator-- ( ) -> duration&
inlineconstexprnoexcept

Pre-decrement operator.

Returns
Reference to this duration after decrementing

◆ operator--() [2/2]

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator-- ( int ) -> duration
inlineconstexprnoexcept

Post-decrement operator.

Returns
Copy of this duration before decrementing

◆ operator-=()

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator-= ( duration< Rep, Period > const & rhs) -> duration&
inlineconstexprnoexcept

Compound subtraction assignment operator.

Parameters
rhsThe duration to subtract
Returns
Reference to this duration after subtraction

◆ operator/=()

template<typename Rep, typename Period>
auto std::chrono::duration< Rep, Period >::operator/= ( rep const & rhs) -> duration&
inlineconstexprnoexcept

Compound division assignment operator.

Parameters
rhsThe scalar to divide by
Returns
Reference to this duration after division

◆ zero()

template<typename Rep, typename Period>
static constexpr auto std::chrono::duration< Rep, Period >::zero ( ) -> duration
inlinestaticconstexprnoexcept

Get a duration of length zero, corresponding to no time passing.

Returns
A duration of length zero

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