Home | History | Annotate | Download | only in time.duration.special
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <chrono>
     11 
     12 // duration
     13 
     14 // static constexpr duration zero(); // noexcept after C++17
     15 
     16 #include <chrono>
     17 #include <cassert>
     18 
     19 #include "test_macros.h"
     20 #include "../../rep.h"
     21 
     22 template <class D>
     23 void test()
     24 {
     25     LIBCPP_ASSERT_NOEXCEPT(std::chrono::duration_values<typename D::rep>::zero());
     26 #if TEST_STD_VER > 17
     27     ASSERT_NOEXCEPT(       std::chrono::duration_values<typename D::rep>::zero());
     28 #endif
     29     {
     30     typedef typename D::rep Rep;
     31     Rep zero_rep = std::chrono::duration_values<Rep>::zero();
     32     assert(D::zero().count() == zero_rep);
     33     }
     34 #if TEST_STD_VER >= 11
     35     {
     36     typedef typename D::rep Rep;
     37     constexpr Rep zero_rep = std::chrono::duration_values<Rep>::zero();
     38     static_assert(D::zero().count() == zero_rep, "");
     39     }
     40 #endif
     41 }
     42 
     43 int main()
     44 {
     45     test<std::chrono::duration<int> >();
     46     test<std::chrono::duration<Rep> >();
     47 }
     48