CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Thu, 31 Jul 2025 02:18:02 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/chrono/duration/
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 31 Jul 2025 02:18:02 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"7dfd-PhMI1HI6A+Nx+r0scoDLpZyfxDE"
Content-Encoding: gzip
A duration object expresses a time span by means of a count and a period.
Internally, the object stores the count as an object of member type rep (an alias of the first template parameter, Rep), which can be retrieved by calling member function count.
This count is expresed in terms of periods. The length of a period is integrated in the type (on compile time) by its second template parameter (Period), which is a ratio type that expresses the number (or fraction) of seconds that elapse in each period.
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<chrono>
classes
-
common_type (duration)C++11
-
common_type (time_point)C++11
-
durationC++11
-
duration_valuesC++11
-
high_resolution_clockC++11
-
steady_clockC++11
-
system_clockC++11
-
time_pointC++11
-
treat_as_floating_pointC++11
-
functions
-
duration_castC++11
-
time_point_castC++11
-
class typedefs
-
hoursC++11
-
microsecondsC++11
-
millisecondsC++11
-
minutesC++11
-
nanosecondsC++11
-
secondsC++11
-
duration
-
duration::~durationC++11
-
duration::durationC++11
-
duration operatorsC++11
member functions
-
duration::countC++11
-
static member functions
-
duration::maxC++11
-
duration::minC++11
-
duration::zeroC++11
-
class template
<chrono>
std::chrono::duration
template <class Rep, class Period = ratio<1> >class duration;
Duration
Internally, the object stores the count as an object of member type rep (an alias of the first template parameter, Rep), which can be retrieved by calling member function count.
This count is expresed in terms of periods. The length of a period is integrated in the type (on compile time) by its second template parameter (Period), which is a ratio type that expresses the number (or fraction) of seconds that elapse in each period.
Template parameters
Template instantiations
The following convenience typedefs of instantiations of duration are also defined in this namespace:type | Representation | Period |
---|---|---|
hours | signed integral type of at least 23 bits | ratio<3600,1> |
minutes | signed integral type of at least 29 bits | ratio<60,1> |
seconds | signed integral type of at least 35 bits | ratio<1,1> |
milliseconds | signed integral type of at least 45 bits | ratio<1,1000> |
microseconds | signed integral type of at least 55 bits | ratio<1,1000000> |
nanoseconds | signed integral type of at least 64 bits | ratio<1,1000000000> |
Member types
The following aliases are member types of duration. They are widely used as parameter and return types by member functions:member type | definition | notes |
---|---|---|
rep | The first template parameter (Rep) | Representation type used as the type for the internal count object. |
period | The second template parameter (Period) | The ratio type that represents a period in seconds. |
Member functions
- (constructor)
- Construct duration object (public member function)
- (destructor)
- Destroy duration (public member function)
- count
- Get count (public member function)
static member functions
- zero
- Zero value (public static member function)
- min
- Duration minimum value (public static member function)
- max
- Duration maximum value (public static member function)
Non-member functions
- operators
- Duration operators (function template)
See also
- time_point
- Time point (class template)
- duration_values
- Duration values (class template)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us