A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/algorithm/../algorithm/../chrono/duration/duration.html below:

std::chrono::duration<Rep,Period>::duration - cppreference.com

constexpr duration() = default;

(1) (since C++11)

duration( const duration& ) = default;

(2) (since C++11)

template< class Rep2 >
constexpr explicit duration( const Rep2& r );

(3) (since C++11)

template< class Rep2, class Period2 >
constexpr duration( const duration<Rep2, Period2>& d );

(4) (since C++11)

Constructs a new duration from one of several optional data sources.

1) The default constructor.

2) The copy constructor.

3) Constructs a duration with r ticks.

4)

Constructs a duration by converting

d

to an appropriate period and tick count, as if by

std::chrono::duration_cast<duration>(d).count()

.

  1. ↑ 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.
  2. ↑ That is, either the duration uses floating-point ticks, or Period2 is exactly divisible by Period.
[edit] Parameters r - a tick count d - a duration to copy from [edit] Example

The following code shows several examples (both valid and invalid) of how to construct durations:

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior LWG 2094 C++11 for overload (4), std::ratio_divide<Period2, period>::num
might overflow when evaluating
std::ratio_divide<Period2, period>::den overload (4) does not
participate in overload
resolution in this case LWG 3050 C++11 convertibility constraint used non-const xvalue use const lvalues instead [edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4