xentara-utils v2.1
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::tparam::Duration< Rep, Period > Struct Template Reference

A duration that can be used as a template parameter. More...

#include <xentara/utils/tparam/Duration.hpp>

Public Types

using rep = Rep
 The type representing the number of ticks.
 
using period = Period
 The period, as a ratio of seconds.
 

Public Member Functions

constexpr Duration (std::chrono::duration< Rep, Period > duration) noexcept
 Constructor that sets the duration.
 
template<typename OtherRep >
requires (std::is_convertible_v<const OtherRep &, Rep> && (std::chrono ::treat_as_floating_point_v<Rep> || !std::chrono ::treat_as_floating_point_v<OtherRep>))
constexpr Duration (std::chrono::duration< OtherRep, Period > duration) noexcept
 Constructor that converts from a duration with a different tick count type.
 
template<typename OtherRep , typename OtherPeriod >
requires std::is_convertible_v<const std::chrono::duration<OtherRep, OtherPeriod> &, const std::chrono::duration<Rep, Period>>
constexpr Duration (std::chrono::duration< OtherRep, OtherPeriod > duration) noexcept
 Constructor that converts from a different type of duration.
 
constexpr operator std::chrono::duration< Rep, Period > () const noexcept
 Conversion to an std::chrono::duration.
 
constexpr auto duration () const noexcept -> std::chrono::duration< Rep, Period >
 Conversion to an std::chrono::duration.
 
constexpr auto count () const noexcept -> Rep
 Returns the count of ticks.
 
constexpr auto operator== (const std::chrono::duration< Rep, Period > &rhs) const -> bool
 Comparison operator.
 
constexpr auto operator<=> (const std::chrono::duration< Rep, Period > &rhs) const -> std::strong_ordering
 Three-Way-Comparison operator.
 

Detailed Description

template<typename Rep, typename Period = std::ratio<1>>
struct xentara::utils::tparam::Duration< Rep, Period >

A duration that can be used as a template parameter.

This class behaves just like std::chrono::duration<Rep, Period>, but can be used as a template parameter.

Member Typedef Documentation

◆ period

template<typename Rep , typename Period = std::ratio<1>>
using xentara::utils::tparam::Duration< Rep, Period >::period = Period

The period, as a ratio of seconds.

◆ rep

template<typename Rep , typename Period = std::ratio<1>>
using xentara::utils::tparam::Duration< Rep, Period >::rep = Rep

The type representing the number of ticks.

Constructor & Destructor Documentation

◆ Duration() [1/3]

template<typename Rep , typename Period = std::ratio<1>>
constexpr xentara::utils::tparam::Duration< Rep, Period >::Duration ( std::chrono::duration< Rep, Period >  duration)
constexprnoexcept

Constructor that sets the duration.

◆ Duration() [2/3]

template<typename Rep , typename Period = std::ratio<1>>
template<typename OtherRep >
requires (std::is_convertible_v<const OtherRep &, Rep> && (std::chrono ::treat_as_floating_point_v<Rep> || !std::chrono ::treat_as_floating_point_v<OtherRep>))
constexpr xentara::utils::tparam::Duration< Rep, Period >::Duration ( std::chrono::duration< OtherRep, Period >  duration)
explicitconstexprnoexcept

Constructor that converts from a duration with a different tick count type.

◆ Duration() [3/3]

template<typename Rep , typename Period = std::ratio<1>>
template<typename OtherRep , typename OtherPeriod >
requires std::is_convertible_v<const std::chrono::duration<OtherRep, OtherPeriod> &, const std::chrono::duration<Rep, Period>>
constexpr xentara::utils::tparam::Duration< Rep, Period >::Duration ( std::chrono::duration< OtherRep, OtherPeriod >  duration)
constexprnoexcept

Constructor that converts from a different type of duration.

Member Function Documentation

◆ count()

template<typename Rep , typename Period = std::ratio<1>>
constexpr auto xentara::utils::tparam::Duration< Rep, Period >::count ( ) const -> Rep
constexprnoexcept

Returns the count of ticks.

◆ duration()

template<typename Rep , typename Period = std::ratio<1>>
constexpr auto xentara::utils::tparam::Duration< Rep, Period >::duration ( ) const -> std::chrono::duration<Rep, Period>
constexprnoexcept

Conversion to an std::chrono::duration.

◆ operator std::chrono::duration< Rep, Period >()

template<typename Rep , typename Period = std::ratio<1>>
constexpr xentara::utils::tparam::Duration< Rep, Period >::operator std::chrono::duration< Rep, Period > ( ) const
constexprnoexcept

Conversion to an std::chrono::duration.

◆ operator<=>()

template<typename Rep , typename Period = std::ratio<1>>
constexpr auto xentara::utils::tparam::Duration< Rep, Period >::operator<=> ( const std::chrono::duration< Rep, Period > &  rhs) const -> std::strong_ordering
constexpr

Three-Way-Comparison operator.

◆ operator==()

template<typename Rep , typename Period = std::ratio<1>>
constexpr auto xentara::utils::tparam::Duration< Rep, Period >::operator== ( const std::chrono::duration< Rep, Period > &  rhs) const -> bool
constexpr

Comparison operator.