]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // boost/chrono/round.hpp ------------------------------------------------------------// |
2 | ||
3 | // (C) Copyright Howard Hinnant | |
4 | // Copyright 2011 Vicente J. Botet Escriba | |
5 | ||
6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | // See http://www.boost.org/libs/chrono for documentation. | |
10 | ||
11 | #ifndef BOOST_CHRONO_FLOOR_HPP | |
12 | #define BOOST_CHRONO_FLOOR_HPP | |
13 | ||
14 | #include <boost/chrono/duration.hpp> | |
15 | ||
16 | namespace boost | |
17 | { | |
18 | namespace chrono | |
19 | { | |
20 | ||
21 | /** | |
22 | * rounds down | |
23 | */ | |
24 | template <class To, class Rep, class Period> | |
25 | To floor(const duration<Rep, Period>& d) | |
26 | { | |
27 | To t = duration_cast<To>(d); | |
28 | if (t>d) --t; | |
29 | return t; | |
30 | } | |
31 | ||
32 | ||
33 | } // namespace chrono | |
34 | } // namespace boost | |
35 | ||
36 | #endif |