std::chrono::duration<Rep,Period>:: max
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
static
constexpr
duration max
(
)
;
|
(C++20 이전) | |
|
static
constexpr
duration max
(
)
noexcept
;
|
(C++20 이후) | |
가능한 가장 큰 값을 가진 duration을 반환합니다.
지속 시간의 표현
rep
이 최대 길이의 지속 시간을 반환하기 위해 다른 구현이 필요한 경우,
std::chrono::duration_values
를 특수화하여 원하는 값을 반환하도록 할 수 있습니다.
목차 |
매개변수
(없음)
반환값
duration ( std:: chrono :: duration_values < rep > :: max ( ) )
예제
#include <chrono> #include <cstdint> #include <iomanip> #include <iostream> int main() { constexpr uint64_t chrono_years_max = std::chrono::years::max().count(); constexpr uint64_t chrono_seconds_max = std::chrono::seconds::max().count(); constexpr uint64_t age_of_universe_in_years{13'787'000'000}; // Λ-CDM ≈ k₁/H₀ = k₂/42 constexpr uint64_t seconds_per_year{365'25 * 24 * 36}; // 365¼ × 24 × 60 × 60 constexpr uint64_t age_of_universe_in_seconds{age_of_universe_in_years * seconds_per_year}; std::cout << std::scientific << std::setprecision(2) << "우주의 나이는 약 " << static_cast<double>(age_of_universe_in_years) << "년 또는 " << static_cast<double>(age_of_universe_in_seconds) << "초입니다.\n\n" << "chrono::years::max() = " << chrono_years_max << ", sizeof(chrono::years) = " << sizeof(std::chrono::years) << " 바이트.\n" "chrono::years " << (age_of_universe_in_years <= chrono_years_max ? "가능" : "불가능") << " 우주의 나이를 연도 단위로 저장할 수 있습니다.\n\n" << "chrono::seconds::max() = " << chrono_seconds_max << ", sizeof(chrono::seconds) = " << sizeof(std::chrono::seconds) << " 바이트.\n" "chrono::seconds " << (age_of_universe_in_seconds <= chrono_seconds_max ? "가능" : "불가능") << " 우주의 나이를 초 단위로 저장할 수 있습니다.\n"; }
가능한 출력:
우주의 나이는 약 1.38e+10년 또는 4.35e+17초입니다. chrono::years::max() = 2147483647, sizeof(chrono::years) = 4 바이트. chrono::years 불가능 우주의 나이를 연도 단위로 저장할 수 있습니다. chrono::seconds::max() = 9223372036854775807, sizeof(chrono::seconds) = 8 바이트. chrono::seconds 가능 우주의 나이를 초 단위로 저장할 수 있습니다.
참고 항목
|
[static]
|
특수 duration 값 zero를 반환합니다
(public static member function) |
|
[static]
|
특수 duration 값 min을 반환합니다
(public static member function) |