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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <chrono> 10 11 // duration 12 13 // static constexpr duration zero(); // noexcept after C++17 14 15 #include <chrono> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "../../rep.h" 20 21 template <class D> test()22void test() 23 { 24 LIBCPP_ASSERT_NOEXCEPT(std::chrono::duration_values<typename D::rep>::zero()); 25 #if TEST_STD_VER > 17 26 ASSERT_NOEXCEPT( std::chrono::duration_values<typename D::rep>::zero()); 27 #endif 28 { 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 >= 11 34 { 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 #endif 40 } 41 main(int,char **)42int main(int, char**) 43 { 44 test<std::chrono::duration<int> >(); 45 test<std::chrono::duration<Rep> >(); 46 47 return 0; 48 } 49