]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/chrono/test/duration/typedefs_pass.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / chrono / test / duration / typedefs_pass.cpp
CommitLineData
7c673cae
FG
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// Adaptation to Boost of the libcxx
10// Copyright 2010 Vicente J. Botet Escriba
11// Distributed under the Boost Software License, Version 1.0.
12// See http://www.boost.org/LICENSE_1_0.txt
13
14
15#include <boost/chrono/duration.hpp>
16#include <boost/type_traits.hpp>
17#include <limits>
18
19#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
20#define NOTHING ""
21#endif
22
23template <typename D, int ExpectedDigits, typename ExpectedPeriod>
24void check_duration()
25{
26 typedef typename D::rep Rep;
27 typedef typename D::period Period;
28 BOOST_CHRONO_STATIC_ASSERT(boost::is_signed<Rep>::value, NOTHING, ());
29 BOOST_CHRONO_STATIC_ASSERT(boost::is_integral<Rep>::value, NOTHING, ());
30 BOOST_CHRONO_STATIC_ASSERT(std::numeric_limits<Rep>::digits >= ExpectedDigits, NOTHING, ());
31 BOOST_CHRONO_STATIC_ASSERT((boost::is_same<Period, ExpectedPeriod >::value), NOTHING, ());
32}
33
34void test()
35{
36 check_duration<boost::chrono::hours, 22, boost::ratio<3600> >();
37 check_duration<boost::chrono::minutes, 28, boost::ratio<60> >();
38 check_duration<boost::chrono::seconds, 34, boost::ratio<1> >();
39 check_duration<boost::chrono::milliseconds, 44, boost::milli >();
40 check_duration<boost::chrono::microseconds, 54, boost::micro >();
41 check_duration<boost::chrono::nanoseconds, 63, boost::nano >();
42}