ceil.hpp 811 B

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