constexpr bool is_negative() const noexcept; // (1) C++20
概要
負の時間かを判定する。
戻り値
コンストラクタで設定された時間が負である場合にtrue
を返し、そうでなければfalse
を返す
例
#include <cassert>
#include <chrono>
namespace chrono = std::chrono;
using namespace std::chrono_literals;
int main()
{
chrono::hh_mm_ss time{-(15h + 30min + 20s)};
assert(time.is_negative() == true);
}
12
#include <cassert>
#include <chrono>
namespace chrono = std::chrono;
using namespace std::chrono_literals;
int main()
{
chrono::hh_mm_ss time{-(15h + 30min + 20s)};
assert(time.is_negative() == true);
}
出力
バージョン
言語
- C++20
処理系
- Clang: 10.0 ✅
- GCC: 11.1 ✅
- Visual C++: 2019 Update 3 ❌