]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/chrono/example/rounding.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / chrono / example / rounding.cpp
1 // french.cpp ----------------------------------------------------------//
2
3 // Copyright 2010 Howard Hinnant
4 // Copyright 2011 Vicente J. Botet Escriba
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
7
8 // Adapted to Boost from the original Hawards's code
9
10 #include <iostream>
11 //#include <boost/chrono/chrono_io.hpp>
12 #include <boost/chrono/floor.hpp>
13 #include <boost/chrono/round.hpp>
14 #include <boost/chrono/ceil.hpp>
15
16 int main()
17 {
18 boost::chrono::milliseconds ms(2500);
19 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
20 std::cout << boost::chrono::floor<boost::chrono::seconds>(ms).count()
21 << " seconds\n";
22 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
23 std::cout << boost::chrono::round<boost::chrono::seconds>(ms).count()
24 << " seconds\n";
25 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
26 std::cout << boost::chrono::ceil<boost::chrono::seconds>(ms).count()
27 << " seconds\n";
28 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
29 ms = boost::chrono::milliseconds(2516);
30 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
31 typedef boost::chrono::duration<long, boost::ratio<1, 30> > frame_rate;
32 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
33 std::cout << boost::chrono::floor<frame_rate>(ms).count()
34 << " [1/30] seconds\n";
35 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
36 std::cout << boost::chrono::round<frame_rate>(ms).count()
37 << " [1/30] seconds\n";
38 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
39 std::cout << boost::chrono::ceil<frame_rate>(ms).count()
40 << " [1/30] seconds\n";
41 std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
42
43 return 0;
44 }