brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · a3f5350 Raw
49 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 9// <chrono>10 11// duration12 13// static constexpr duration zero(); // noexcept after C++1714 15#include <chrono>16#include <cassert>17 18#include "test_macros.h"19#include "../../rep.h"20 21template <class D>22void test()23{24    LIBCPP_ASSERT_NOEXCEPT(std::chrono::duration_values<typename D::rep>::zero());25#if TEST_STD_VER > 1726    ASSERT_NOEXCEPT(       std::chrono::duration_values<typename D::rep>::zero());27#endif28    {29    typedef typename D::rep DRep;30    DRep zero_rep = std::chrono::duration_values<DRep>::zero();31    assert(D::zero().count() == zero_rep);32    }33#if TEST_STD_VER >= 1134    {35    typedef typename D::rep DRep;36    constexpr DRep zero_rep = std::chrono::duration_values<DRep>::zero();37    static_assert(D::zero().count() == zero_rep, "");38    }39#endif40}41 42int main(int, char**)43{44    test<std::chrono::duration<int> >();45    test<std::chrono::duration<Rep> >();46 47  return 0;48}49