Espaces de noms
Variantes
Affichages
Actions

std::chrono::duration::duration

De cppreference.com
< cpp‎ | chrono‎ | duration

 
 
 
 
std::chrono::duration
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
duration::duration
duration::operator=
duration::count
duration::zero
duration::min
duration::max
duration::operator+
duration::operator-
duration::operator++
duration::operator--
duration::operator+=
duration::operator-=
duration::operator*=
duration::operator/=
duration::operator%=
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
common_type
operator+
operator-
operator*
operator/
operator%
operator==
operator!=
operator<
operator<=
operator>
operator>=
duration_cast
Classes d'aide
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
treat_as_floating_point
duration_values
 
constexpr duration() = default;
(1)
duration(const duration&) = default;
(2)
template <class Rep2>
constexpr explicit duration(const Rep2& r);
(3)
template <class Rep2, class Period2>
constexpr duration(const duration<Rep2, Period2>& d);
(4)
Construit une nouvelle duration parmi plusieurs sources de données en option .
Original:
Constructs a new duration from one of several optional data sources.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Le constructeur par défaut est réglé par défaut .
Original:
The default constructor is defaulted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Le constructeur de copie est réglé par défaut (en fait une copie bit à bit du nombre de cycles) .
Original:
The copy constructor is defaulted (makes a bitwise copy of the tick count).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Construit une durée de tiques r. Notez que ce constructeur ne participe qu'à la résolution de surcharge si Rep2 (le type d'argument) est implicitement convertible en rep (le type de tiques cette durée) et
Original:
Constructs a duration with r ticks. Note that this constructor only participates in overload resolution if Rep2 (the argument type) is implicitly convertible to rep (the type of this duration's ticks) and
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
@ @ (Qui est, d'une durée d'un nombre de cycles entier ne peut pas être construit à partir d'une valeur à virgule flottante, mais une durée d'un nombre de cycles à virgule flottante peuvent être construits à partir d'une valeur entière)
Original:
@@(that is, a duration with an integer tick count cannot be constructed from a floating-point value, but a duration with a floating-point tick count can be constructed from an integer value)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Construit une durée en convertissant d à une période convenable et nombre de cycles, comme par std::chrono::duration_cast<duration>(d).count(). Afin d'empêcher la troncature lors de la conversion, ce constructeur ne participe qu'à la résolution de surcharge si:
Original:
Constructs a duration by converting d to an appropriate period and tick count, as if by std::chrono::duration_cast<duration>(d).count(). In order to prevent truncation during conversion, this constructor only participates in overload resolution if:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
@ @, Ou les deux:
Original:
@@ or both:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
@ (Qui est, soit la durée utilise virgule flottante tiques, ou Period2 est exactement divisible par période)
Original:
@@ (that is, either the duration uses floating-point ticks, or Period2 is exactly divisible by period)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Paramètres

r -
une nombre de cycles
Original:
a tick count
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
d -
une durée à copier
Original:
a duration to copy from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Exemple

Le code suivant montre plusieurs exemples (à la fois valides et non valides) de la façon de construire durées:
Original:
The following code shows several examples (both valid and invalid) of how to construct durations:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <chrono>
int main()
{
    std::chrono::hours h(1); // one hour
    std::chrono::milliseconds ms{3}; // 3 milliseconds
    std::chrono::duration<int, std::kilo> ks(3); // 3000 seconds
 
    // error: treat_as_floating_point<int>::value == false,
    // This duration allows whole tick counts only
//  std::chrono::duration<int, std::kilo> d3(3.5);
 
    // 30Hz clock using fractional ticks
    std::chrono::duration<double, std::ratio<1, 30>> hz30(3.5);
 
    // 3000 microseconds constructed from 3 milliseconds
    std::chrono::microseconds us = ms;
    // error: 1/1000000 is not divisible by 1/1000
//  std::chrono::milliseconds ms2 = us
}


[modifier] Voir aussi

affecte le contenu
Original:
assigns the contents
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]