Namespace
Varianti

Date and time utilities

Da cppreference.com.
< cpp


 
 
Utilità libreria
Tipo di supporto (basic types, RTTI, type traits)
Gestione della memoria dinamica
La gestione degli errori
Programma di utilità
Funzioni variadic
Data e ora
Funzione oggetti
initializer_list(C++11)
bitset
hash(C++11)
Gli operatori relazionali
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Coppie e tuple
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
Swap, in avanti e spostare
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
Data e ora utilità
 
C + + include il supporto per due tipi di manipolazione del tempo:
Original:
C++ includes support for two types of time manipulation:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • La biblioteca chrono, un insieme flessibile di tipi che tengono traccia del tempo con vari gradi di precisione (ad esempio std::chrono::time_point).
    Original:
    The chrono library, a flexible collection of types that track time with varying degrees of precision (e.g. std::chrono::time_point).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • C-biblioteca in stile data e l'ora (ad esempio std::time)
    Original:
    C-style date and time library (e.g. std::time)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

Indice

[modifica] NJ libreria

La biblioteca chrono definisce tre tipi principali (durata, orologi, e punti di tempo), nonché le funzioni di utilità e typedef comuni.
Original:
The chrono library defines three main types (durations, clocks, and time points) as well as utility functions and common typedefs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Durata

Una durata consiste in un arco di tempo, definito come un certo numero di segni di graduazione di qualche unità di tempo. Per esempio, "42 secondi" potrebbe essere rappresentato da una durata composta da 42 zecche di un 1-seconda unità di tempo.
Original:
A duration consists of a span of time, defined as some number of ticks of some time unit. For example, "42 seconds" could be represented by a duration consisting of 42 ticks of a 1-second time unit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <chrono>
Defined in namespace std::chrono
(C++11)
un intervallo di tempo
Original:
a time interval
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe template) [edit]

[modifica] Orologi

Un orologio consiste di un punto di partenza (o epoca) e un tasso di zecca. Ad esempio, un orologio può avere un epoca al 1 ° gennaio 1970 e tick ogni secondo. C + + definisce tre tipi di clock:
Original:
A clock consists of a starting point (or epoch) and a tick rate. For example, a clock may have an epoch of January 1, 1970 and tick every second. C++ defines three clock types:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <chrono>
Defined in namespace std::chrono
orologio da parete dal livello di sistema orologio in tempo reale
Original:
wall clock time from the system-wide realtime clock
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe) [edit]
orologio monotona che non verrà mai modificato
Original:
monotonic clock that will never be adjusted
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe) [edit]
l'orologio con il più breve periodo di zecca disponibili
Original:
the clock with the shortest tick period available
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe) [edit]

[modifica] Ora punto

Un punto di tempo è un periodo di tempo che è passato da quando l'epoca di orologio specifico.
Original:
A time point is a duration of time that has passed since the epoch of specific clock.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <chrono>
Defined in namespace std::chrono
a point in time
(classe template) [edit]

[modifica] C-stile di data e ora biblioteca

Ci sono anche le C-stile funzioni di data e ora, come std::time_t, std::difftime e CLOCKS_PER_SEC.
Original:
Also provided are the C-style date and time functions, such as std::time_t, std::difftime, and CLOCKS_PER_SEC.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Esempio

In questo esempio vengono visualizzate informazioni sul tempo di esecuzione di una chiamata di funzione:
Original:
This example displays information about the execution time of a function call:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <chrono>
#include <ctime>
 
int fibonacci(int n)
{
    if (n < 3) return 1;
    return fibonacci(n-1) + fibonacci(n-2);
}
 
int main()
{
    std::chrono::time_point<std::chrono::system_clock> start, end;
    start = std::chrono::system_clock::now();
    int result = fibonacci(42);
    end = std::chrono::system_clock::now();
 
    int elapsed_seconds = std::chrono::duration_cast<std::chrono::seconds>
                             (end-start).count();
    std::time_t end_time = std::chrono::system_clock::to_time_t(end);
 
    std::cout << "finished computation at " << std::ctime(&end_time)
              << "elapsed time: " << elapsed_seconds << "s\n";
}

Possible output:

finished computation at Sat Jun 16 20:42:57 2012
elapsed time: 3s