Ticket #11834: main.cpp

File main.cpp, 970 bytes (added by banslug2001@…, 7 years ago)

main.cpp

Line 
1//
2// main.cpp
3// Boost_Test_1
4//
5// Created by Arthur B Coleman on 12/7/15.
6// Copyright © 2015 Arthur Coleman. All rights reserved.
7//
8
9#include <boost/chrono/chrono.hpp>
10#include <boost/type_traits.hpp>
11
12#include <iostream>
13
14using namespace boost::chrono;
15
16
17void explore_limits()
18{
19 typedef duration<long long, boost::ratio_multiply<boost::ratio<24*3652425,10000>,
20 hours::period>::type> Years;
21#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
22 steady_clock::time_point t1( Years(250));
23 steady_clock::time_point t2(-Years(250));
24#else
25 system_clock::time_point t1( Years(250));
26 system_clock::time_point t2(-Years(250));
27#endif
28 // nanosecond resolution is likely to overflow. "up cast" to microseconds.
29 // The "up cast" trades precision for range.
30 microseconds d = time_point_cast<microseconds>(t1) - time_point_cast<microseconds>(t2);
31 std::cout << d.count() << " microseconds\n";
32}
33
34
35int main()
36{
37 explore_limits();
38 return 0;
39}