#include <boost/chrono/typeof/boost/chrono/chrono.hpp>
#include <boost/type_traits.hpp>
#include <iostream>
using namespace boost::chrono;
template <class Rep, class Period>
void print_duration(std::ostream& os, duration<Rep, Period> d)
{
os << d.count() << " * " << Period::num << '/' << Period::den << " seconds\n";
}
namespace my_ns {
template <class Clock, class Duration1, class Duration2>
inline
typename boost::common_type<time_point<Clock, Duration1>,
time_point<Clock, Duration2> >::type
min BOOST_PREVENT_MACRO_SUBSTITUTION (time_point<Clock, Duration1> t1, time_point<Clock, Duration2> t2)
{
return t2 < t1 ? t2 : t1;
}
}
void test_min()
{
#if 1
typedef time_point<system_clock,
boost::common_type<system_clock::duration, seconds>::type> T1;
typedef time_point<system_clock,
boost::common_type<system_clock::duration, nanoseconds>::type> T2;
typedef boost::common_type<T1, T2>::type T3;
T1 t1 = system_clock::now() + seconds(3);
T2 t2 = system_clock::now() + nanoseconds(3);
T3 t3 = (my_ns::min)(t1, t2);
#else#endif
print_duration(std::cout, t1 - t3);
print_duration(std::cout, t2 - t3);
}
int main()
{
test_min();
return 0;
}