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 min(); // noexcept after C++17
     15 
     16 #include <chrono>
     17 #include <limits>
     18 #include <cassert>
     19 
     20 #include "test_macros.h"
     21 #include "../../rep.h"
     22 
     23 template <class D>
     24 void test()
     25 {
     26     LIBCPP_ASSERT_NOEXCEPT(std::chrono::duration_values<typename D::rep>::min());
     27 #if TEST_STD_VER > 17
     28     ASSERT_NOEXCEPT(       std::chrono::duration_values<typename D::rep>::min());
     29 #endif
     30     {
     31     typedef typename D::rep Rep;
     32     Rep min_rep = std::chrono::duration_values<Rep>::min();
     33     assert(D::min().count() == min_rep);
     34     }
     35 #if TEST_STD_VER >= 11
     36     {
     37     typedef typename D::rep Rep;
     38     constexpr Rep min_rep = std::chrono::duration_values<Rep>::min();
     39     static_assert(D::min().count() == min_rep, "");
     40     }
     41 #endif
     42 }
     43 
     44 int main()
     45 {
     46     test<std::chrono::duration<int> >();
     47     test<std::chrono::duration<Rep> >();
     48 }
     49