38 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++03, c++11, c++14, c++179// <chrono>10 11// constexpr bool is_pm(const hours& h) noexcept;12// Returns: 12h <= h && h <= 2313 14#include <chrono>15#include <cassert>16#include <utility>17 18#include "test_macros.h"19 20int main(int, char**)21{22 using hours = std::chrono::hours;23 ASSERT_SAME_TYPE(bool, decltype(std::chrono::is_pm(std::declval<hours>())));24 ASSERT_NOEXCEPT( std::chrono::is_pm(std::declval<hours>()));25 26 static_assert(!std::chrono::is_pm(hours( 0)), "");27 static_assert(!std::chrono::is_pm(hours(11)), "");28 static_assert( std::chrono::is_pm(hours(12)), "");29 static_assert( std::chrono::is_pm(hours(23)), "");30 31 for (int i = 0; i < 12; ++i)32 assert(!std::chrono::is_pm(hours(i)));33 for (int i = 12; i < 24; ++i)34 assert( std::chrono::is_pm(hours(i)));35 36 return 0;37}38