Home | History | Annotate | Download | only in time.duration.arithmetic
      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 // constexpr duration operator--(int);   // constexpr in C++17
     15 
     16 #include <chrono>
     17 #include <cassert>
     18 
     19 #include "test_macros.h"
     20 
     21 #if TEST_STD_VER > 14
     22 constexpr bool test_constexpr()
     23 {
     24     std::chrono::hours h1(3);
     25     std::chrono::hours h2 = h1--;
     26     return h1.count() == 2 && h2.count() == 3;
     27 }
     28 #endif
     29 
     30 
     31 int main()
     32 {
     33     {
     34     std::chrono::hours h1(3);
     35     std::chrono::hours h2 = h1--;
     36     assert(h1.count() == 2);
     37     assert(h2.count() == 3);
     38     }
     39 
     40 #if TEST_STD_VER > 14
     41     static_assert(test_constexpr(), "");
     42 #endif
     43 }
     44