Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70318 - in branches/release/boost/ratio: . detail detail/mpl mpl
From: vicente.botet_at_[hidden]
Date: 2011-03-21 13:14:26


Author: viboes
Date: 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
New Revision: 70318
URL: http://svn.boost.org/trac/boost/changeset/70318

Log:
Ratio: import from Trunk
Added:
   branches/release/boost/ratio/
   branches/release/boost/ratio/detail/
   branches/release/boost/ratio/detail/mpl/
   branches/release/boost/ratio/detail/mpl/abs.hpp (contents, props changed)
   branches/release/boost/ratio/detail/mpl/gcd.hpp (contents, props changed)
   branches/release/boost/ratio/detail/mpl/lcm.hpp (contents, props changed)
   branches/release/boost/ratio/detail/mpl/sign.hpp (contents, props changed)
   branches/release/boost/ratio/detail/overflow_helpers.hpp (contents, props changed)
   branches/release/boost/ratio/include.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/
   branches/release/boost/ratio/mpl/abs.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/arithmetic.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/comparison.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/divides.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/equal_to.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/gcd.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/greater.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/greater_equal.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/lcm.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/less.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/less_equal.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/minus.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/negate.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/not_equal_to.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/numeric_cast.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/plus.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/rational_c_tag.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/rational_constant.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/sign.hpp (contents, props changed)
   branches/release/boost/ratio/mpl/times.hpp (contents, props changed)
   branches/release/boost/ratio/ratio.hpp (contents, props changed)
   branches/release/boost/ratio/ratio_fwd.hpp (contents, props changed)
   branches/release/boost/ratio/ratio_io.hpp (contents, props changed)
   branches/release/boost/ratio/ratio_static_string.hpp (contents, props changed)

Added: branches/release/boost/ratio/detail/mpl/abs.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/detail/mpl/abs.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,89 @@
+////////////////////////////////////////////////////////////////////
+//
+// Copyright Vicente J. Botet Escriba 2010
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/mpl for documentation.
+//
+////////////////////////////////////////////////////////////////////
+#ifndef BOOST_MPL_ABS_HPP_INCLUDED
+#define BOOST_MPL_ABS_HPP_INCLUDED
+
+#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/aux_/na_spec.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/mpl/aux_/config/eti.hpp>
+#include <boost/mpl/aux_/config/integral.hpp>
+#include <boost/mpl/aux_/config/static_constant.hpp>
+
+#if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \
+ && !defined(BOOST_MPL_PREPROCESSING_MODE) \
+ && ( defined(BOOST_MSVC) \
+ || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \
+ )
+
+# define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2
+
+#endif
+
+namespace boost { namespace mpl {
+
+template< typename Tag > struct abs_impl;
+
+template< typename T > struct abs_tag
+{
+ typedef typename T::tag type;
+};
+
+template<
+ typename BOOST_MPL_AUX_NA_PARAM(N)
+ >
+struct abs
+ : abs_impl<
+ typename abs_tag<N>::type
+ >::template apply<N>::type
+{
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1, abs, (N))
+};
+
+BOOST_MPL_AUX_NA_SPEC(1, abs)
+
+template<
+ typename T
+ , T n1
+ >
+struct abs_c
+ : abs<integral_c<T,n1> >
+{
+};
+
+#if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
+namespace aux {
+template< typename T, T n > struct abs_wknd
+{
+ BOOST_STATIC_CONSTANT(T, value = (n < 0 ? -n : n));
+ typedef integral_c<T,value> type;
+};
+}
+#endif
+
+template<>
+struct abs_impl<integral_c_tag>
+{
+#if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
+ template< typename N > struct apply
+ : aux::abs_wknd< typename N::value_type, N::value >
+#else
+ template< typename N > struct apply
+ : integral_c< typename N::value_type, ((N::value < 0) ? (-N::value) : N::value ) >
+#endif
+ {
+ };
+};
+
+}}
+
+#endif // BOOST_MPL_ABS_HPP_INCLUDED

Added: branches/release/boost/ratio/detail/mpl/gcd.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/detail/mpl/gcd.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,99 @@
+////////////////////////////////////////////////////////////////////
+//
+// Copyright Vicente J. Botet Escriba 2010
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/mpl for documentation.
+//
+////////////////////////////////////////////////////////////////////
+#ifndef BOOST_MPL_GCD_HPP_INCLUDED
+#define BOOST_MPL_GCD_HPP_INCLUDED
+
+#include <boost/mpl/integral_c.hpp>
+#include <boost/ratio/detail/mpl/abs.hpp>
+#include <boost/mpl/aux_/largest_int.hpp>
+#include <boost/mpl/aux_/na_spec.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/mpl/aux_/config/eti.hpp>
+#include <boost/mpl/aux_/config/integral.hpp>
+#include <boost/mpl/aux_/config/static_constant.hpp>
+
+#if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \
+ && !defined(BOOST_MPL_PREPROCESSING_MODE) \
+ && ( defined(BOOST_MSVC) \
+ || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \
+ )
+
+# define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2
+
+#endif
+
+namespace boost { namespace mpl {
+
+template< typename Tag1, typename Tag2 > struct gcd_impl;
+
+template< typename T > struct gcd_tag
+{
+ typedef typename T::tag type;
+};
+
+template<
+ typename BOOST_MPL_AUX_NA_PARAM(N1)
+ , typename BOOST_MPL_AUX_NA_PARAM(N2)
+ >
+struct gcd
+ : gcd_impl<
+ typename gcd_tag<N1>::type
+ , typename gcd_tag<N2>::type
+ >::template apply<N1, N2>::type
+{
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(2, gcd, (N1, N2))
+};
+
+BOOST_MPL_AUX_NA_SPEC(2, gcd)
+
+template<
+ typename T
+ , T n1
+ , T n2
+ >
+struct gcd_c
+ : gcd<integral_c<T,n1>,integral_c<T,n2> >
+{
+};
+
+namespace aux {
+ template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 >
+ struct gcd_aux
+
+ : gcd_aux<T2, n2, n2==0,
+ typename aux::largest_int<T1, T2>::type,
+ //~ T1,
+ (n1 % n2), (n1 % n2)==0>
+ {};
+
+ template <typename T1, T1 n1, typename T2, T2 n2>
+ struct gcd_aux<T1, n1, false, T2, n2, true> : integral_c<T1, n1>
+ {};
+
+ template <typename T1, T1 n1, typename T2, T2 n2, bool C>
+ struct gcd_aux<T1, n1, true, T2, n2, C> : integral_c<T2, n2>
+ {};
+}
+
+template<>
+struct gcd_impl<integral_c_tag, integral_c_tag>
+{
+ template< typename N1, typename N2 > struct apply
+ : abs<aux::gcd_aux< typename N1::value_type, N1::value, N1::value==0,
+ typename N2::value_type, N2::value, N2::value==0 > >
+ {
+ };
+};
+
+}}
+
+#endif // BOOST_MPL_GCD_HPP_INCLUDED

Added: branches/release/boost/ratio/detail/mpl/lcm.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/detail/mpl/lcm.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,99 @@
+////////////////////////////////////////////////////////////////////
+//
+// Copyright Vicente J. Botet Escriba 2010
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/mpl for documentation.
+//
+////////////////////////////////////////////////////////////////////
+#ifndef BOOST_MPL_LCM_HPP_INCLUDED
+#define BOOST_MPL_LCM_HPP_INCLUDED
+
+#include <boost/mpl/integral_c.hpp>
+#include <boost/ratio/detail/mpl/abs.hpp>
+#include <boost/mpl/aux_/largest_int.hpp>
+#include <boost/mpl/aux_/na_spec.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/mpl/aux_/config/eti.hpp>
+#include <boost/mpl/aux_/config/integral.hpp>
+#include <boost/mpl/aux_/config/static_constant.hpp>
+
+#if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \
+ && !defined(BOOST_MPL_PREPROCESSING_MODE) \
+ && ( defined(BOOST_MSVC) \
+ || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \
+ )
+
+# define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2
+
+#endif
+
+namespace boost { namespace mpl {
+
+template< typename Tag1, typename Tag2 > struct lcm_impl;
+
+template< typename T > struct lcm_tag
+{
+ typedef typename T::tag type;
+};
+
+template<
+ typename BOOST_MPL_AUX_NA_PARAM(N1)
+ , typename BOOST_MPL_AUX_NA_PARAM(N2)
+ >
+struct lcm
+ : lcm_impl<
+ typename lcm_tag<N1>::type
+ , typename lcm_tag<N2>::type
+ >::template apply<N1, N2>::type
+{
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(2, lcm, (N1, N2))
+};
+
+BOOST_MPL_AUX_NA_SPEC(2, lcm)
+
+template<
+ typename T
+ , T n1
+ , T n2
+ >
+struct lcm_c
+ : lcm<integral_c<T,n1>,integral_c<T,n2> >
+{
+};
+
+
+namespace aux {
+ template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 >
+ struct lcm_aux
+
+ : abs<integral_c< typename aux::largest_int<T1, T2>::type,
+ ( n1 / gcd<integral_c<T1,n1>, integral_c<T2,n2> >::value * n2 )
+ > >
+ {};
+
+ template <typename T1, T1 n1, typename T2, T2 n2>
+ struct lcm_aux<T1, n1, false, T2, n2, true> : integral_c<T2, 0>
+ {};
+
+ template <typename T1, T1 n1, typename T2, T2 n2, bool C>
+ struct lcm_aux<T1, n1, true, T2, n2, C> : integral_c<T1, 0>
+ {};
+}
+
+template<>
+struct lcm_impl<integral_c_tag, integral_c_tag>
+{
+ template< typename N1, typename N2 > struct apply
+ : abs<aux::lcm_aux< typename N1::value_type, N1::value, N1::value==0,
+ typename N2::value_type, N2::value, N2::value==0 > >
+ {
+ };
+};
+
+}}
+
+#endif // BOOST_MPL_LCM_HPP_INCLUDED

Added: branches/release/boost/ratio/detail/mpl/sign.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/detail/mpl/sign.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,89 @@
+////////////////////////////////////////////////////////////////////
+//
+// Copyright Vicente J. Botet Escriba 2010
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/mpl for documentation.
+//
+////////////////////////////////////////////////////////////////////
+#ifndef BOOST_MPL_SIGN_HPP_INCLUDED
+#define BOOST_MPL_SIGN_HPP_INCLUDED
+
+#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/aux_/na_spec.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/mpl/aux_/config/eti.hpp>
+#include <boost/mpl/aux_/config/integral.hpp>
+#include <boost/mpl/aux_/config/static_constant.hpp>
+
+#if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \
+ && !defined(BOOST_MPL_PREPROCESSING_MODE) \
+ && ( defined(BOOST_MSVC) \
+ || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \
+ )
+
+# define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2
+
+#endif
+
+namespace boost { namespace mpl {
+
+template< typename Tag > struct sign_impl;
+
+template< typename T > struct sign_tag
+{
+ typedef typename T::tag type;
+};
+
+template<
+ typename BOOST_MPL_AUX_NA_PARAM(N)
+ >
+struct sign
+ : sign_impl<
+ typename sign_tag<N>::type
+ >::template apply<N>::type
+{
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1, sign, (N))
+};
+
+BOOST_MPL_AUX_NA_SPEC(1, sign)
+
+template<
+ typename T
+ , T n1
+ >
+struct sign_c
+ : sign<integral_c<T,n1> >
+{
+};
+
+#if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
+namespace aux {
+template< typename T, T n > struct sign_wknd
+{
+ BOOST_STATIC_CONSTANT(T, value = (n == 0 ? 0 : (n < 0 ? -1 : 1)));
+ typedef integral_c<T,value> type;
+};
+}
+#endif
+
+template<>
+struct sign_impl<integral_c_tag>
+{
+#if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
+ template< typename N > struct apply
+ : aux::sign_wknd< typename N::value_type, N::value >
+#else
+ template< typename N > struct apply
+ : integral_c< typename N::value_type, (N::value == 0 ? 0 : (N::value < 0 ? -1 : 1)) >
+#endif
+ {
+ };
+};
+
+}}
+
+#endif // BOOST_MPL_SIGN_HPP_INCLUDED

Added: branches/release/boost/ratio/detail/overflow_helpers.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/detail/overflow_helpers.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,373 @@
+// ratio.hpp ---------------------------------------------------------------//
+
+// Copyright 2008 Howard Hinnant
+// Copyright 2008 Beman Dawes
+// Copyright 2009 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+
+This code was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section
+20.4 Compile-time rational arithmetic [ratio], of the C++ committee working
+paper N2798.
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+ Much thanks to Andrei Alexandrescu,
+ Walter Brown,
+ Peter Dimov,
+ Jeff Garland,
+ Terry Golubiewski,
+ Daniel Krugler,
+ Anthony Williams.
+*/
+
+// The way overflow is managed for ratio_less is taken from llvm/libcxx/include/ratio
+
+#ifndef BOOST_RATIO_DETAIL_RATIO_OPERATIONS_HPP
+#define BOOST_RATIO_DETAIL_RATIO_OPERATIONS_HPP
+
+#include <boost/ratio/detail/mpl/abs.hpp>
+#include <boost/ratio/detail/mpl/sign.hpp>
+#include <cstdlib>
+#include <climits>
+#include <limits>
+#include <boost/cstdint.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/integer_traits.hpp>
+
+#if !defined(BOOST_NO_STATIC_ASSERT) || !defined(BOOST_RATIO_USES_MPL_ASSERT)
+#define BOOST_RATIO_OVERFLOW_IN_ADD "overflow in ratio add"
+#define BOOST_RATIO_OVERFLOW_IN_SUB "overflow in ratio sub"
+#define BOOST_RATIO_OVERFLOW_IN_MUL "overflow in ratio mul"
+#define BOOST_RATIO_OVERFLOW_IN_DIV "overflow in ratio div"
+#define BOOST_RATIO_NUMERATOR_IS_OUT_OF_RANGE "ratio numerator is out of range"
+#define BOOST_RATIO_DIVIDE_BY_0 "ratio divide by 0"
+#define BOOST_RATIO_DENOMINATOR_IS_OUT_OF_RANGE "ratio denominator is out of range"
+#endif
+
+#ifndef BOOST_NO_STATIC_ASSERT
+#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG)
+#elif defined(BOOST_RATIO_USES_STATIC_ASSERT)
+#include <boost/static_assert.hpp>
+#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND)
+#elif defined(BOOST_RATIO_USES_MPL_ASSERT)
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/bool.hpp>
+#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) \
+ BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES)
+#else
+//~ #elif defined(BOOST_RATIO_USES_ARRAY_ASSERT)
+#define BOOST_RATIO_CONCAT(A,B) A##B
+#define BOOST_RATIO_NAME(A,B) BOOST_RATIO_CONCAT(A,B)
+#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) static char BOOST_RATIO_NAME(__boost_ratio_test_,__LINE__)[(CND)?1:-1]
+//~ #define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES)
+#endif
+
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost
+{
+
+//----------------------------------------------------------------------------//
+// helpers //
+//----------------------------------------------------------------------------//
+
+namespace ratio_detail
+{
+
+ template <boost::intmax_t X, boost::intmax_t Y, boost::intmax_t = mpl::sign_c<boost::intmax_t, Y>::value>
+ class br_add;
+
+ template <boost::intmax_t X, boost::intmax_t Y>
+ class br_add<X, Y, 1>
+ {
+ static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
+ static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
+
+ BOOST_RATIO_STATIC_ASSERT(X <= max - Y , BOOST_RATIO_OVERFLOW_IN_ADD, ());
+ public:
+ static const boost::intmax_t value = X + Y;
+ };
+
+ template <boost::intmax_t X, boost::intmax_t Y>
+ class br_add<X, Y, 0>
+ {
+ public:
+ static const boost::intmax_t value = X;
+ };
+
+ template <boost::intmax_t X, boost::intmax_t Y>
+ class br_add<X, Y, -1>
+ {
+ static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
+ static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
+
+ BOOST_RATIO_STATIC_ASSERT(min - Y <= X, BOOST_RATIO_OVERFLOW_IN_ADD, ());
+ public:
+ static const boost::intmax_t value = X + Y;
+ };
+
+ template <boost::intmax_t X, boost::intmax_t Y, boost::intmax_t = mpl::sign_c<boost::intmax_t, Y>::value>
+ class br_sub;
+
+ template <boost::intmax_t X, boost::intmax_t Y>
+ class br_sub<X, Y, 1>
+ {
+ static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
+ static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
+
+ BOOST_RATIO_STATIC_ASSERT(min + Y <= X, BOOST_RATIO_OVERFLOW_IN_SUB, ());
+ public:
+ static const boost::intmax_t value = X - Y;
+ };
+
+ template <boost::intmax_t X, boost::intmax_t Y>
+ class br_sub<X, Y, 0>
+ {
+ public:
+ static const boost::intmax_t value = X;
+ };
+
+ template <boost::intmax_t X, boost::intmax_t Y>
+ class br_sub<X, Y, -1>
+ {
+ static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
+ static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
+
+ BOOST_RATIO_STATIC_ASSERT(X <= max + Y, BOOST_RATIO_OVERFLOW_IN_SUB, ());
+ public:
+ static const boost::intmax_t value = X - Y;
+ };
+
+ template <boost::intmax_t X, boost::intmax_t Y>
+ class br_mul
+ {
+ static const boost::intmax_t nan =
+ (BOOST_RATIO_INTMAX_C(1) << (sizeof(boost::intmax_t) * CHAR_BIT - 1));
+ static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
+ static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
+
+ static const boost::intmax_t a_x = mpl::abs_c<boost::intmax_t, X>::value;
+ static const boost::intmax_t a_y = mpl::abs_c<boost::intmax_t, Y>::value;
+
+ BOOST_RATIO_STATIC_ASSERT(X != nan, BOOST_RATIO_OVERFLOW_IN_MUL, ());
+ BOOST_RATIO_STATIC_ASSERT(Y != nan, BOOST_RATIO_OVERFLOW_IN_MUL, ());
+ BOOST_RATIO_STATIC_ASSERT(a_x <= max / a_y, BOOST_RATIO_OVERFLOW_IN_MUL, ());
+ public:
+ static const boost::intmax_t value = X * Y;
+ };
+
+ template <boost::intmax_t Y>
+ class br_mul<0, Y>
+ {
+ public:
+ static const boost::intmax_t value = 0;
+ };
+
+ template <boost::intmax_t X>
+ class br_mul<X, 0>
+ {
+ public:
+ static const boost::intmax_t value = 0;
+ };
+
+ template <>
+ class br_mul<0, 0>
+ {
+ public:
+ static const boost::intmax_t value = 0;
+ };
+
+ // Not actually used but left here in case needed in future maintenance
+ template <boost::intmax_t X, boost::intmax_t Y>
+ class br_div
+ {
+ static const boost::intmax_t nan = (1LL << (sizeof(boost::intmax_t) * CHAR_BIT - 1));
+ static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
+ static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
+
+ BOOST_RATIO_STATIC_ASSERT(X != nan, BOOST_RATIO_OVERFLOW_IN_DIV, ());
+ BOOST_RATIO_STATIC_ASSERT(Y != nan, BOOST_RATIO_OVERFLOW_IN_DIV, ());
+ BOOST_RATIO_STATIC_ASSERT(Y != 0, BOOST_RATIO_DIVIDE_BY_0, ());
+ public:
+ static const boost::intmax_t value = X / Y;
+ };
+
+ // ratio arithmetic
+ template <class R1, class R2> struct ratio_add;
+ template <class R1, class R2> struct ratio_subtract;
+ template <class R1, class R2> struct ratio_multiply;
+ template <class R1, class R2> struct ratio_divide;
+
+ template <class R1, class R2>
+ struct ratio_add
+ {
+ //The nested typedef type shall be a synonym for ratio<T1, T2>::type where T1 has the value R1::num *
+ //R2::den + R2::num * R1::den and T2 has the value R1::den * R2::den.
+ // As the preceding doesn't works because of overflow on boost::intmax_t we need something more elaborated.
+ private:
+ static const boost::intmax_t gcd_n1_n2 = mpl::gcd_c<boost::intmax_t, R1::num, R2::num>::value;
+ static const boost::intmax_t gcd_d1_d2 = mpl::gcd_c<boost::intmax_t, R1::den, R2::den>::value;
+ public:
+ // No need to normalize as ratio_multiply is already normalized
+ typedef typename ratio_multiply
+ <
+ ratio<gcd_n1_n2, R1::den / gcd_d1_d2>,
+ ratio
+ <
+ boost::ratio_detail::br_add
+ <
+ boost::ratio_detail::br_mul<R1::num / gcd_n1_n2, R2::den / gcd_d1_d2>::value,
+ boost::ratio_detail::br_mul<R2::num / gcd_n1_n2, R1::den / gcd_d1_d2>::value
+ >::value,
+ R2::den
+ >
+ >::type type;
+ };
+
+ template <class R1, class R2>
+ struct ratio_subtract
+ {
+ //The nested typedef type shall be a synonym for ratio<T1, T2>::type where T1 has the value
+ // R1::num *R2::den - R2::num * R1::den and T2 has the value R1::den * R2::den.
+ // As the preceding doesn't works because of overflow on boost::intmax_t we need something more elaborated.
+ private:
+ static const boost::intmax_t gcd_n1_n2 = mpl::gcd_c<boost::intmax_t, R1::num, R2::num>::value;
+ static const boost::intmax_t gcd_d1_d2 = mpl::gcd_c<boost::intmax_t, R1::den, R2::den>::value;
+ public:
+ // No need to normalize as ratio_multiply is already normalized
+ typedef typename ratio_multiply
+ <
+ ratio<gcd_n1_n2, R1::den / gcd_d1_d2>,
+ ratio
+ <
+ boost::ratio_detail::br_sub
+ <
+ boost::ratio_detail::br_mul<R1::num / gcd_n1_n2, R2::den / gcd_d1_d2>::value,
+ boost::ratio_detail::br_mul<R2::num / gcd_n1_n2, R1::den / gcd_d1_d2>::value
+ >::value,
+ R2::den
+ >
+ >::type type;
+ };
+
+ template <class R1, class R2>
+ struct ratio_multiply
+ {
+ // The nested typedef type shall be a synonym for ratio<R1::num * R2::den - R2::num * R1::den, R1::den * R2::den>::type.
+ // As the preceding doesn't works because of overflow on boost::intmax_t we need something more elaborated.
+ private:
+ static const boost::intmax_t gcd_n1_d2 = mpl::gcd_c<boost::intmax_t, R1::num, R2::den>::value;
+ static const boost::intmax_t gcd_d1_n2 = mpl::gcd_c<boost::intmax_t, R1::den, R2::num>::value;
+ public:
+ typedef typename ratio
+ <
+ boost::ratio_detail::br_mul<R1::num / gcd_n1_d2, R2::num / gcd_d1_n2>::value,
+ boost::ratio_detail::br_mul<R2::den / gcd_n1_d2, R1::den / gcd_d1_n2>::value
+ >::type type;
+ };
+
+ template <class R1, class R2>
+ struct ratio_divide
+ {
+ // The nested typedef type shall be a synonym for ratio<R1::num * R2::den, R2::num * R1::den>::type.
+ // As the preceding doesn't works because of overflow on boost::intmax_t we need something more elaborated.
+ private:
+ static const boost::intmax_t gcd_n1_n2 = mpl::gcd_c<boost::intmax_t, R1::num, R2::num>::value;
+ static const boost::intmax_t gcd_d1_d2 = mpl::gcd_c<boost::intmax_t, R1::den, R2::den>::value;
+ public:
+ typedef typename ratio
+ <
+ boost::ratio_detail::br_mul<R1::num / gcd_n1_n2, R2::den / gcd_d1_d2>::value,
+ boost::ratio_detail::br_mul<R2::num / gcd_n1_n2, R1::den / gcd_d1_d2>::value
+ >::type type;
+ };
+
+ template <class T>
+ struct is_ratio : public boost::false_type
+ {};
+ template <boost::intmax_t N, boost::intmax_t D>
+ struct is_ratio<ratio<N, D> > : public boost::true_type
+ {};
+
+ template <class R1, class R2,
+ boost::intmax_t Q1 = R1::num / R1::den, boost::intmax_t M1 = R1::num % R1::den,
+ boost::intmax_t Q2 = R2::num / R2::den, boost::intmax_t M2 = R2::num % R2::den>
+ struct ratio_less1
+ {
+ static const bool value = Q1 < Q2;
+ };
+
+ template <class R1, class R2, boost::intmax_t Q>
+ struct ratio_less1<R1, R2, Q, 0, Q, 0>
+ {
+ static const bool value = false;
+ };
+
+ template <class R1, class R2, boost::intmax_t Q, boost::intmax_t M2>
+ struct ratio_less1<R1, R2, Q, 0, Q, M2>
+ {
+ static const bool value = true;
+ };
+
+ template <class R1, class R2, boost::intmax_t Q, boost::intmax_t M1>
+ struct ratio_less1<R1, R2, Q, M1, Q, 0>
+ {
+ static const bool value = false;
+ };
+
+ template <class R1, class R2, boost::intmax_t Q, boost::intmax_t M1, boost::intmax_t M2>
+ struct ratio_less1<R1, R2, Q, M1, Q, M2>
+ {
+ static const bool value = ratio_less1<ratio<R2::den, M2>, ratio<R1::den, M1>
+ >::value;
+ };
+
+ template <
+ class R1,
+ class R2,
+ boost::intmax_t S1 = mpl::sign_c<boost::intmax_t, R1::num>::value,
+ boost::intmax_t S2 = mpl::sign_c<boost::intmax_t, R2::num>::value
+>
+ struct ratio_less
+ {
+ static const bool value = S1 < S2;
+ };
+
+ template <class R1, class R2>
+ struct ratio_less<R1, R2, 1LL, 1LL>
+ {
+ static const bool value = ratio_less1<R1, R2>::value;
+ };
+
+ template <class R1, class R2>
+ struct ratio_less<R1, R2, -1LL, -1LL>
+ {
+ static const bool value = ratio_less1<ratio<-R2::num, R2::den>,
+ ratio<-R1::num, R1::den> >::value;
+ };
+
+
+} // namespace ratio_detail
+
+} // namespace boost
+
+#endif // BOOST_RATIO_HPP

Added: branches/release/boost/ratio/include.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/include.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,15 @@
+// include.hpp ---------------------------------------------------------------//
+
+// Copyright 2011 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#ifndef BOOST_RATIO_INCLUDE_HPP
+#define BOOST_RATIO_INCLUDE_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/ratio_io.hpp>
+#include <boost/ratio/mpl/rational_constant.hpp>
+
+#endif // BOOST_RATIO_INCLUDE_HPP

Added: branches/release/boost/ratio/mpl/abs.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/abs.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// abs.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_ABS_HPP
+#define BOOST_RATIO_MPL_ABS_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/ratio/detail/mpl/abs.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct abs_impl< rational_c_tag >
+{
+ template< typename R > struct apply
+ : ratio_abs<R>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_ABS_HPP

Added: branches/release/boost/ratio/mpl/arithmetic.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/arithmetic.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,22 @@
+// arithmetic.hpp ---------------------------------------------------------------//
+
+// Copyright 2011 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+
+#ifndef BOOST_RATIO_MPL_ARITHMETIC_HPP
+#define BOOST_RATIO_MPL_ARITHMETIC_HPP
+
+#include <boost/ratio/mpl/plus.hpp>
+#include <boost/ratio/mpl/minus.hpp>
+#include <boost/ratio/mpl/times.hpp>
+#include <boost/ratio/mpl/divides.hpp>
+#include <boost/ratio/mpl/negate.hpp>
+#include <boost/ratio/mpl/abs.hpp>
+#include <boost/ratio/mpl/sign.hpp>
+#include <boost/ratio/mpl/gcd.hpp>
+#include <boost/ratio/mpl/lcm.hpp>
+
+#endif // BOOST_RATIO_MPL_ARITHMETIC_HPP

Added: branches/release/boost/ratio/mpl/comparison.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/comparison.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,19 @@
+// comparison.hpp ---------------------------------------------------------------//
+
+// Copyright 2011 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+
+#ifndef BOOST_RATIO_MPL_COMPARISON_HPP
+#define BOOST_RATIO_MPL_COMPARISON_HPP
+
+#include <boost/ratio/mpl/equal_to.hpp>
+#include <boost/ratio/mpl/not_equal_to.hpp>
+#include <boost/ratio/mpl/less.hpp>
+#include <boost/ratio/mpl/less_equal.hpp>
+#include <boost/ratio/mpl/greater.hpp>
+#include <boost/ratio/mpl/greater_equal.hpp>
+
+#endif // BOOST_RATIO_MPL_COMPARISON_HPP

Added: branches/release/boost/ratio/mpl/divides.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/divides.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// divides.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_DIVIDES_HPP
+#define BOOST_RATIO_MPL_DIVIDES_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/divides.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct divides_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_divide<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_DIVIDES_HPP

Added: branches/release/boost/ratio/mpl/equal_to.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/equal_to.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// equal_to.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_EQUAL_TO_HPP
+#define BOOST_RATIO_MPL_EQUAL_TO_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/equal_to.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct equal_to_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_equal<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_EQUAL_TO_HPP

Added: branches/release/boost/ratio/mpl/gcd.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/gcd.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// gcd.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_GCD_HPP
+#define BOOST_RATIO_MPL_GCD_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/ratio/detail/mpl/gcd.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct gcd_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_gcd<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_GCD_HPP

Added: branches/release/boost/ratio/mpl/greater.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/greater.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// greater.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_GREATER_HPP
+#define BOOST_RATIO_MPL_GREATER_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/greater.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct greater_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_greater<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_GREATER_HPP

Added: branches/release/boost/ratio/mpl/greater_equal.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/greater_equal.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// greater_equal.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_GREATER_EQUAL_HPP
+#define BOOST_RATIO_MPL_GREATER_EQUAL_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/greater_equal.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct greater_equal_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_greater_equal<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_GREATER_EQUAL_HPP

Added: branches/release/boost/ratio/mpl/lcm.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/lcm.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// lcm.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_LCM_HPP
+#define BOOST_RATIO_MPL_LCM_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/ratio/detail/mpl/lcm.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct lcm_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_lcm<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_LCM_HPP

Added: branches/release/boost/ratio/mpl/less.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/less.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// less.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_LESS_HPP
+#define BOOST_RATIO_MPL_LESS_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/less.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct less_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_less<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_LESS_HPP

Added: branches/release/boost/ratio/mpl/less_equal.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/less_equal.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// less_equal.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_LESS_EQUAL_HPP
+#define BOOST_RATIO_MPL_LESS_EQUAL_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/less_equal.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct less_equal_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_less_equal<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_LESS_EQUAL_HPP

Added: branches/release/boost/ratio/mpl/minus.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/minus.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// minus.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_MINUS_HPP
+#define BOOST_RATIO_MPL_MINUS_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/minus.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct minus_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_subtract<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_MINUS_HPP

Added: branches/release/boost/ratio/mpl/negate.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/negate.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// negate.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_NEGATE_HPP
+#define BOOST_RATIO_MPL_NEGATE_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/negate.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct negate_impl< rational_c_tag >
+{
+ template< typename R > struct apply
+ : ratio_negate<R>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_NEGATE_HPP

Added: branches/release/boost/ratio/mpl/not_equal_to.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/not_equal_to.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// not_equal_to.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_NOT_EQUAL_TO_HPP
+#define BOOST_RATIO_MPL_NOT_EQUAL_TO_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/not_equal_to.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct not_equal_to_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_not_equal<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_NOT_EQUAL_TO_HPP

Added: branches/release/boost/ratio/mpl/numeric_cast.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/numeric_cast.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,31 @@
+// numeric_cast.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_NUMERIC_CAST_HPP
+#define BOOST_RATIO_MPL_NUMERIC_CAST_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/ratio/mpl/rational_c_tag.hpp>
+#include <boost/mpl/numeric_cast.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<> struct numeric_cast< integral_c_tag,rational_c_tag >
+{
+ template< typename N > struct apply
+ : ratio< N::value, 1 >
+ {
+ };
+};
+
+}
+}
+
+#endif // BOOST_RATIO_MPL_NUMERIC_CAST_HPP

Added: branches/release/boost/ratio/mpl/plus.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/plus.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// plus.hpp
+//
+// (C) Copyright 2011Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_PLUS_HPP
+#define BOOST_RATIO_MPL_PLUS_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/plus.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct plus_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_add<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_PLUS_HPP

Added: branches/release/boost/ratio/mpl/rational_c_tag.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/rational_c_tag.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,25 @@
+// abs.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_RATIONAL_C_TAG_HPP
+#define BOOST_RATIO_MPL_RATIONAL_C_TAG_HPP
+
+#ifdef BOOST_RATIO_EXTENSIONS
+
+#include <boost/mpl/int.hpp>
+
+namespace boost {
+namespace mpl {
+
+struct rational_c_tag : int_<10> {};
+
+}
+}
+
+#endif // BOOST_RATIO_EXTENSIONS
+#endif // BOOST_RATIO_MPL_RATIONAL_C_TAG_HPP

Added: branches/release/boost/ratio/mpl/rational_constant.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/rational_constant.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,15 @@
+// rational_constant.hpp ---------------------------------------------------------------//
+// Copyright 2011 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+
+#ifndef BOOST_RATIO_MPL_RATIONAL_CONSTANT_HPP
+#define BOOST_RATIO_MPL_RATIONAL_CONSTANT_HPP
+
+#include <boost/ratio/mpl/rational_c_tag.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/ratio/mpl/arithmetic.hpp>
+#include <boost/ratio/mpl/comparison.hpp>
+
+#endif // BOOST_RATIO_HPP

Added: branches/release/boost/ratio/mpl/sign.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/sign.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// sign.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_SIGN_HPP
+#define BOOST_RATIO_MPL_SIGN_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/ratio/detail/mpl/sign.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct sign_impl< rational_c_tag >
+{
+ template< typename R > struct apply
+ : ratio_sign<R>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_SIGN_HPP

Added: branches/release/boost/ratio/mpl/times.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/mpl/times.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// times.hpp
+//
+// (C) Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+
+#ifndef BOOST_RATIO_MPL_TIMES_HPP
+#define BOOST_RATIO_MPL_TIMES_HPP
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/ratio/mpl/numeric_cast.hpp>
+#include <boost/mpl/times.hpp>
+
+namespace boost {
+namespace mpl {
+
+template<>
+struct times_impl< rational_c_tag,rational_c_tag >
+{
+ template< typename R1, typename R2 > struct apply
+ : ratio_multiply<R1, R2>
+ {
+ };
+};
+}
+}
+
+#endif // BOOST_RATIO_MPL_TIMES_HPP

Added: branches/release/boost/ratio/ratio.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/ratio.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,233 @@
+// ratio.hpp ---------------------------------------------------------------//
+
+// Copyright 2008 Howard Hinnant
+// Copyright 2008 Beman Dawes
+// Copyright 2009 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+
+This code was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section
+20.4 Compile-time rational arithmetic [ratio], of the C++ committee working
+paper N2798.
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+ Much thanks to Andrei Alexandrescu,
+ Walter Brown,
+ Peter Dimov,
+ Jeff Garland,
+ Terry Golubiewski,
+ Daniel Krugler,
+ Anthony Williams.
+*/
+
+// The way overflow is managed for ratio_less is taken from llvm/libcxx/include/ratio
+
+#ifndef BOOST_RATIO_RATIO_HPP
+#define BOOST_RATIO_RATIO_HPP
+
+#include <boost/config.hpp>
+#include <boost/ratio/detail/mpl/abs.hpp>
+#include <boost/ratio/detail/mpl/sign.hpp>
+#include <boost/ratio/detail/mpl/gcd.hpp>
+#include <boost/ratio/detail/mpl/lcm.hpp>
+#include <cstdlib>
+#include <climits>
+#include <limits>
+#include <boost/cstdint.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/integer_traits.hpp>
+#include <boost/ratio/ratio_fwd.hpp>
+#include <boost/ratio/detail/overflow_helpers.hpp>
+#ifdef BOOST_RATIO_EXTENSIONS
+#include <boost/rational.hpp>
+#include <boost/ratio/mpl/rational_c_tag.hpp>
+#endif
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost
+{
+
+
+//----------------------------------------------------------------------------//
+// //
+// 20.6.1 Class template ratio [ratio.ratio] //
+// //
+//----------------------------------------------------------------------------//
+
+template <boost::intmax_t N, boost::intmax_t D>
+class ratio
+{
+ static const boost::intmax_t ABS_N = mpl::abs_c<boost::intmax_t, N>::value;
+ static const boost::intmax_t ABS_D = mpl::abs_c<boost::intmax_t, D>::value;
+ BOOST_RATIO_STATIC_ASSERT(ABS_N >= 0, BOOST_RATIO_NUMERATOR_IS_OUT_OF_RANGE, ());
+ BOOST_RATIO_STATIC_ASSERT(ABS_D > 0, BOOST_RATIO_DENOMINATOR_IS_OUT_OF_RANGE, ());
+ BOOST_RATIO_STATIC_ASSERT(D != 0, BOOST_RATIO_DIVIDE_BY_0 , ());
+ static const boost::intmax_t SIGN_N = mpl::sign_c<boost::intmax_t,N>::value
+ * mpl::sign_c<boost::intmax_t,D>::value;
+ static const boost::intmax_t GCD = mpl::gcd_c<boost::intmax_t, ABS_N, ABS_D>::value;
+public:
+ BOOST_STATIC_CONSTEXPR boost::intmax_t num = SIGN_N * ABS_N / GCD;
+ BOOST_STATIC_CONSTEXPR boost::intmax_t den = ABS_D / GCD;
+
+#ifdef BOOST_RATIO_EXTENSIONS
+ typedef mpl::rational_c_tag tag;
+ typedef boost::rational<boost::intmax_t> value_type;
+ typedef boost::intmax_t num_type;
+ typedef boost::intmax_t den_type;
+ ratio()
+ {}
+ template <boost::intmax_t _N2, boost::intmax_t _D2>
+ ratio(const ratio<_N2, _D2>&,
+ typename enable_if_c
+ <
+ (ratio<_N2, _D2>::num == num &&
+ ratio<_N2, _D2>::den == den)
+ >::type* = 0)
+ {}
+
+ template <boost::intmax_t _N2, boost::intmax_t _D2>
+ typename enable_if_c
+ <
+ (ratio<_N2, _D2>::num == num &&
+ ratio<_N2, _D2>::den == den),
+ ratio&
+ >::type
+ operator=(const ratio<_N2, _D2>&) {return *this;}
+
+ static value_type value() {return value_type(num,den);}
+ value_type operator()() const {return value();}
+#endif
+ typedef ratio<num, den> type;
+};
+
+#if defined(BOOST_NO_CONSTEXPR)
+template <boost::intmax_t N, boost::intmax_t D>
+const boost::intmax_t ratio<N, D>::num;
+template <boost::intmax_t N, boost::intmax_t D>
+const boost::intmax_t ratio<N, D>::den;
+#endif
+
+//----------------------------------------------------------------------------//
+// //
+// 20.6.2 Arithmetic on ratio types [ratio.arithmetic] //
+// //
+//----------------------------------------------------------------------------//
+
+template <class R1, class R2>
+struct ratio_add
+: boost::ratio_detail::ratio_add<R1, R2>::type
+{
+};
+
+template <class R1, class R2>
+struct ratio_subtract
+: boost::ratio_detail::ratio_subtract<R1, R2>::type
+{
+};
+
+template <class R1, class R2>
+struct ratio_multiply
+: boost::ratio_detail::ratio_multiply<R1, R2>::type
+{
+};
+
+template <class R1, class R2>
+struct ratio_divide
+: boost::ratio_detail::ratio_divide<R1, R2>::type
+{
+};
+
+//----------------------------------------------------------------------------//
+// //
+// 20.6.3 Comparasion of ratio types [ratio.comparison] //
+// //
+//----------------------------------------------------------------------------//
+
+// ratio_equal
+
+template <class R1, class R2>
+struct ratio_equal
+ : public boost::integral_constant<bool,
+ (R1::num == R2::num && R1::den == R2::den)>
+{};
+
+template <class R1, class R2>
+struct ratio_not_equal
+ : public boost::integral_constant<bool, !ratio_equal<R1, R2>::value>
+{};
+
+// ratio_less
+
+template <class R1, class R2>
+struct ratio_less
+ : boost::integral_constant<bool, boost::ratio_detail::ratio_less<R1, R2>::value>
+{};
+
+template <class R1, class R2>
+struct ratio_less_equal
+ : boost::integral_constant<bool, !ratio_less<R2, R1>::value>
+{};
+
+template <class R1, class R2>
+struct ratio_greater
+ : boost::integral_constant<bool, ratio_less<R2, R1>::value>
+{};
+
+template <class R1, class R2>
+struct ratio_greater_equal
+ : boost::integral_constant<bool, !ratio_less<R1, R2>::value>
+{};
+
+template <class R1, class R2>
+struct ratio_gcd :
+ ratio<mpl::gcd_c<boost::intmax_t, R1::num, R2::num>::value,
+ mpl::lcm_c<boost::intmax_t, R1::den, R2::den>::value>::type
+{
+};
+
+#ifdef BOOST_RATIO_EXTENSIONS
+template <class R>
+struct ratio_negate
+ : ratio<-R::num, R::den>::type
+{
+};
+template <class R>
+struct ratio_abs
+ : ratio<mpl::abs_c<boost::intmax_t, R::num>::value, R::den>::type
+{
+};
+template <class R>
+struct ratio_sign
+ : mpl::sign_c<boost::intmax_t, R::num>
+{
+};
+template <class R1, class R2>
+struct ratio_lcm :
+ ratio<mpl::lcm_c<boost::intmax_t, R1::num, R2::num>::value,
+ mpl::gcd_c<boost::intmax_t, R1::den, R2::den>::value>::type
+{
+};
+#endif
+} // namespace boost
+
+
+#endif // BOOST_RATIO_RATIO_HPP

Added: branches/release/boost/ratio/ratio_fwd.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/ratio_fwd.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,89 @@
+// ratio_fwd.hpp ---------------------------------------------------------------//
+
+// Copyright 2008 Howard Hinnant
+// Copyright 2008 Beman Dawes
+// Copyright 2009 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+
+This code was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section
+20.4 Compile-time rational arithmetic [ratio], of the C++ committee working
+paper N2798.
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+ Much thanks to Andrei Alexandrescu,
+ Walter Brown,
+ Peter Dimov,
+ Jeff Garland,
+ Terry Golubiewski,
+ Daniel Krugler,
+ Anthony Williams.
+*/
+
+// The way overflow is managed for ratio_less is taken from llvm/libcxx/include/ratio
+
+#ifndef BOOST_RATIO_RATIO_FWD_HPP
+#define BOOST_RATIO_RATIO_FWD_HPP
+
+#include <boost/cstdint.hpp>
+#ifdef INTMAX_C
+#define BOOST_RATIO_INTMAX_C(a) INTMAX_C(a)
+#else
+#define BOOST_RATIO_INTMAX_C(a) a##LL
+#endif
+
+namespace boost
+{
+
+//----------------------------------------------------------------------------//
+// //
+// 20.6 Compile-time rational arithmetic [ratio] //
+// //
+//----------------------------------------------------------------------------//
+
+// ratio
+template <boost::intmax_t N, boost::intmax_t D = 1> class ratio;
+
+// ratio arithmetic
+template <class R1, class R2> struct ratio_add;
+template <class R1, class R2> struct ratio_subtract;
+template <class R1, class R2> struct ratio_multiply;
+template <class R1, class R2> struct ratio_divide;
+
+// ratio comparison
+template <class R1, class R2> struct ratio_equal;
+template <class R1, class R2> struct ratio_not_equal;
+template <class R1, class R2> struct ratio_less;
+template <class R1, class R2> struct ratio_less_equal;
+template <class R1, class R2> struct ratio_greater;
+template <class R1, class R2> struct ratio_greater_equal;
+
+// convenience SI typedefs
+typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000000)> atto;
+typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000)> femto;
+typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000)> pico;
+typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000)> nano;
+typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000)> micro;
+typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000)> milli;
+typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(100)> centi;
+typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(10)> deci;
+typedef ratio< BOOST_RATIO_INTMAX_C(10), BOOST_RATIO_INTMAX_C(1)> deca;
+typedef ratio< BOOST_RATIO_INTMAX_C(100), BOOST_RATIO_INTMAX_C(1)> hecto;
+typedef ratio< BOOST_RATIO_INTMAX_C(1000), BOOST_RATIO_INTMAX_C(1)> kilo;
+typedef ratio< BOOST_RATIO_INTMAX_C(1000000), BOOST_RATIO_INTMAX_C(1)> mega;
+typedef ratio< BOOST_RATIO_INTMAX_C(1000000000), BOOST_RATIO_INTMAX_C(1)> giga;
+typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000), BOOST_RATIO_INTMAX_C(1)> tera;
+typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000000), BOOST_RATIO_INTMAX_C(1)> peta;
+typedef ratio<BOOST_RATIO_INTMAX_C(1000000000000000000), BOOST_RATIO_INTMAX_C(1)> exa;
+
+} // namespace boost
+
+
+#endif // BOOST_RATIO_HPP

Added: branches/release/boost/ratio/ratio_io.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/ratio_io.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,793 @@
+// ratio_io
+//
+// (C) Copyright Howard Hinnant
+// (C) Copyright 2010 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+// This code was adapted by Vicente from Howard Hinnant's experimental work
+// on chrono i/o under lvm/libc++ to Boost
+
+#ifndef BOOST_RATIO_RATIO_IO_HPP
+#define BOOST_RATIO_RATIO_IO_HPP
+
+/*
+
+ ratio_io synopsis
+
+#include <ratio>
+#include <string>
+
+namespace boost
+{
+
+template <class Ratio, class CharT>
+struct ratio_string
+{
+ static basic_string<CharT> short_name();
+ static basic_string<CharT> long_name();
+};
+
+} // boost
+
+*/
+
+#include <boost/config.hpp>
+#include <boost/ratio/ratio.hpp>
+#include <string>
+#include <sstream>
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+#include <boost/ratio/ratio_static_string.hpp>
+#include <boost/static_string/static_string.hpp>
+#endif
+
+#if defined(BOOST_NO_UNICODE_LITERALS) || defined(BOOST_NO_CHAR16_T) || defined(BOOST_NO_CHAR32_T)
+//~ #define BOOST_RATIO_HAS_UNICODE_SUPPORT
+#else
+#define BOOST_RATIO_HAS_UNICODE_SUPPORT 1
+#endif
+
+namespace boost {
+
+template <class Ratio, class CharT>
+struct ratio_string
+{
+ static std::basic_string<CharT> short_name() {return long_name();}
+ static std::basic_string<CharT> long_name();
+};
+
+template <class Ratio, class CharT>
+std::basic_string<CharT>
+ratio_string<Ratio, CharT>::long_name()
+{
+ std::basic_ostringstream<CharT> os;
+ os << CharT('[') << Ratio::num << CharT('/')
+ << Ratio::den << CharT(']');
+ return os.str();
+}
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+namespace ratio_detail {
+template <class Ratio, class CharT>
+struct ratio_string_static
+{
+ static std::string short_name() {
+ return std::basic_string<CharT>(
+ static_string::c_str<
+ typename ratio_static_string<Ratio, CharT>::short_name
+ >::value);
+ }
+ static std::string long_name() {
+ return std::basic_string<CharT>(
+ static_string::c_str<
+ typename ratio_static_string<Ratio, CharT>::long_name
+ >::value);
+ }
+};
+}
+#endif
+// atto
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<atto, CharT> :
+ ratio_detail::ratio_string_static<atto,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<atto, char>
+{
+ static std::string short_name() {return std::string(1, 'a');}
+ static std::string long_name() {return std::string("atto");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<atto, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'a');}
+ static std::u16string long_name() {return std::u16string(u"atto");}
+};
+
+template <>
+struct ratio_string<atto, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'a');}
+ static std::u32string long_name() {return std::u32string(U"atto");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<atto, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'a');}
+ static std::wstring long_name() {return std::wstring(L"atto");}
+};
+#endif
+#endif
+
+// femto
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<femto, CharT> :
+ ratio_detail::ratio_string_static<femto,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<femto, char>
+{
+ static std::string short_name() {return std::string(1, 'f');}
+ static std::string long_name() {return std::string("femto");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<femto, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'f');}
+ static std::u16string long_name() {return std::u16string(u"femto");}
+};
+
+template <>
+struct ratio_string<femto, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'f');}
+ static std::u32string long_name() {return std::u32string(U"femto");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<femto, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'f');}
+ static std::wstring long_name() {return std::wstring(L"femto");}
+};
+#endif
+#endif
+
+// pico
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<pico, CharT> :
+ ratio_detail::ratio_string_static<pico,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<pico, char>
+{
+ static std::string short_name() {return std::string(1, 'p');}
+ static std::string long_name() {return std::string("pico");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<pico, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'p');}
+ static std::u16string long_name() {return std::u16string(u"pico");}
+};
+
+template <>
+struct ratio_string<pico, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'p');}
+ static std::u32string long_name() {return std::u32string(U"pico");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<pico, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'p');}
+ static std::wstring long_name() {return std::wstring(L"pico");}
+};
+#endif
+#endif
+
+// nano
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<nano, CharT> :
+ ratio_detail::ratio_string_static<nano,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<nano, char>
+{
+ static std::string short_name() {return std::string(1, 'n');}
+ static std::string long_name() {return std::string("nano");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<nano, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'n');}
+ static std::u16string long_name() {return std::u16string(u"nano");}
+};
+
+template <>
+struct ratio_string<nano, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'n');}
+ static std::u32string long_name() {return std::u32string(U"nano");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<nano, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'n');}
+ static std::wstring long_name() {return std::wstring(L"nano");}
+};
+#endif
+#endif
+
+// micro
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<micro, CharT> :
+ ratio_detail::ratio_string_static<micro,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<micro, char>
+{
+ static std::string short_name() {return std::string("\xC2\xB5");}
+ static std::string long_name() {return std::string("micro");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<micro, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'\xB5');}
+ static std::u16string long_name() {return std::u16string(u"micro");}
+};
+
+template <>
+struct ratio_string<micro, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'\xB5');}
+ static std::u32string long_name() {return std::u32string(U"micro");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<micro, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'\xB5');}
+ static std::wstring long_name() {return std::wstring(L"micro");}
+};
+#endif
+#endif
+
+// milli
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<milli, CharT> :
+ ratio_detail::ratio_string_static<milli,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<milli, char>
+{
+ static std::string short_name() {return std::string(1, 'm');}
+ static std::string long_name() {return std::string("milli");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<milli, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'm');}
+ static std::u16string long_name() {return std::u16string(u"milli");}
+};
+
+template <>
+struct ratio_string<milli, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'm');}
+ static std::u32string long_name() {return std::u32string(U"milli");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<milli, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'm');}
+ static std::wstring long_name() {return std::wstring(L"milli");}
+};
+#endif
+#endif
+
+// centi
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<centi, CharT> :
+ ratio_detail::ratio_string_static<centi,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<centi, char>
+{
+ static std::string short_name() {return std::string(1, 'c');}
+ static std::string long_name() {return std::string("centi");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<centi, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'c');}
+ static std::u16string long_name() {return std::u16string(u"centi");}
+};
+
+template <>
+struct ratio_string<centi, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'c');}
+ static std::u32string long_name() {return std::u32string(U"centi");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<centi, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'c');}
+ static std::wstring long_name() {return std::wstring(L"centi");}
+};
+#endif
+#endif
+
+// deci
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<deci, CharT> :
+ ratio_detail::ratio_string_static<deci,CharT>
+{};
+
+#else
+
+template <>
+struct ratio_string<deci, char>
+{
+ static std::string short_name() {return std::string(1, 'd');}
+ static std::string long_name() {return std::string("deci");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<deci, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'd');}
+ static std::u16string long_name() {return std::u16string(u"deci");}
+};
+
+template <>
+struct ratio_string<deci, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'd');}
+ static std::u32string long_name() {return std::u32string(U"deci");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<deci, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'd');}
+ static std::wstring long_name() {return std::wstring(L"deci");}
+};
+#endif
+#endif
+
+// deca
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<deca, CharT> :
+ ratio_detail::ratio_string_static<deca,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<deca, char>
+{
+ static std::string short_name() {return std::string("da");}
+ static std::string long_name() {return std::string("deca");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<deca, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(u"da");}
+ static std::u16string long_name() {return std::u16string(u"deca");}
+};
+
+template <>
+struct ratio_string<deca, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(U"da");}
+ static std::u32string long_name() {return std::u32string(U"deca");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<deca, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(L"da");}
+ static std::wstring long_name() {return std::wstring(L"deca");}
+};
+#endif
+#endif
+
+// hecto
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<hecto, CharT> :
+ ratio_detail::ratio_string_static<hecto,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<hecto, char>
+{
+ static std::string short_name() {return std::string(1, 'h');}
+ static std::string long_name() {return std::string("hecto");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<hecto, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'h');}
+ static std::u16string long_name() {return std::u16string(u"hecto");}
+};
+
+template <>
+struct ratio_string<hecto, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'h');}
+ static std::u32string long_name() {return std::u32string(U"hecto");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<hecto, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'h');}
+ static std::wstring long_name() {return std::wstring(L"hecto");}
+};
+#endif
+#endif
+
+// kilo
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<kilo, CharT> :
+ ratio_detail::ratio_string_static<kilo,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<kilo, char>
+{
+ static std::string short_name() {return std::string(1, 'k');}
+ static std::string long_name() {return std::string("kilo");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<kilo, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'k');}
+ static std::u16string long_name() {return std::u16string(u"kilo");}
+};
+
+template <>
+struct ratio_string<kilo, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'k');}
+ static std::u32string long_name() {return std::u32string(U"kilo");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<kilo, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'k');}
+ static std::wstring long_name() {return std::wstring(L"kilo");}
+};
+#endif
+#endif
+
+// mega
+
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<mega, CharT> :
+ ratio_detail::ratio_string_static<mega,CharT>
+{};
+
+#else
+
+template <>
+struct ratio_string<mega, char>
+{
+ static std::string short_name() {return std::string(1, 'M');}
+ static std::string long_name() {return std::string("mega");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<mega, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'M');}
+ static std::u16string long_name() {return std::u16string(u"mega");}
+};
+
+template <>
+struct ratio_string<mega, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'M');}
+ static std::u32string long_name() {return std::u32string(U"mega");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<mega, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'M');}
+ static std::wstring long_name() {return std::wstring(L"mega");}
+};
+#endif
+#endif
+
+// giga
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<giga, CharT> :
+ ratio_detail::ratio_string_static<giga,CharT>
+{};
+
+#else
+
+template <>
+struct ratio_string<giga, char>
+{
+ static std::string short_name() {return std::string(1, 'G');}
+ static std::string long_name() {return std::string("giga");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<giga, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'G');}
+ static std::u16string long_name() {return std::u16string(u"giga");}
+};
+
+template <>
+struct ratio_string<giga, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'G');}
+ static std::u32string long_name() {return std::u32string(U"giga");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<giga, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'G');}
+ static std::wstring long_name() {return std::wstring(L"giga");}
+};
+#endif
+#endif
+
+// tera
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<tera, CharT> :
+ ratio_detail::ratio_string_static<tera,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<tera, char>
+{
+ static std::string short_name() {return std::string(1, 'T');}
+ static std::string long_name() {return std::string("tera");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<tera, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'T');}
+ static std::u16string long_name() {return std::u16string(u"tera");}
+};
+
+template <>
+struct ratio_string<tera, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'T');}
+ static std::u32string long_name() {return std::u32string(U"tera");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<tera, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'T');}
+ static std::wstring long_name() {return std::wstring(L"tera");}
+};
+#endif
+#endif
+
+// peta
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<peta, CharT> :
+ ratio_detail::ratio_string_static<peta,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<peta, char>
+{
+ static std::string short_name() {return std::string(1, 'P');}
+ static std::string long_name() {return std::string("peta");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<peta, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'P');}
+ static std::u16string long_name() {return std::u16string(u"peta");}
+};
+
+template <>
+struct ratio_string<peta, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'P');}
+ static std::u32string long_name() {return std::u32string(U"peta");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<peta, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'P');}
+ static std::wstring long_name() {return std::wstring(L"peta");}
+};
+#endif
+#endif
+
+// exa
+#ifdef BOOST_RATIO_HAS_STATIC_STRING
+template <typename CharT>
+struct ratio_string<exa, CharT> :
+ ratio_detail::ratio_string_static<exa,CharT>
+{};
+
+#else
+template <>
+struct ratio_string<exa, char>
+{
+ static std::string short_name() {return std::string(1, 'E');}
+ static std::string long_name() {return std::string("exa");}
+};
+
+#if BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_string<exa, char16_t>
+{
+ static std::u16string short_name() {return std::u16string(1, u'E');}
+ static std::u16string long_name() {return std::u16string(u"exa");}
+};
+
+template <>
+struct ratio_string<exa, char32_t>
+{
+ static std::u32string short_name() {return std::u32string(1, U'E');}
+ static std::u32string long_name() {return std::u32string(U"exa");}
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_string<exa, wchar_t>
+{
+ static std::wstring short_name() {return std::wstring(1, L'E');}
+ static std::wstring long_name() {return std::wstring(L"exa");}
+};
+#endif
+#endif
+
+}
+
+#endif // BOOST_RATIO_RATIO_IO_HPP

Added: branches/release/boost/ratio/ratio_static_string.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/ratio/ratio_static_string.hpp 2011-03-21 13:14:23 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,631 @@
+// ratio_io
+//
+// (C) Copyright 2010 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+//
+// This code was adapted by Vicente from Howard Hinnant's experimental work
+// on chrono i/o under lvm/libc++ to Boost
+
+#ifndef BOOST_RATIO_RATIO_STATIC_STRING_HPP
+#define BOOST_RATIO_RATIO_STATIC_STRING_HPP
+
+/*
+
+ ratio_static_string synopsis
+
+#include <ratio>
+#include <string>
+
+namespace boost
+{
+
+template <class Ratio, class CharT>
+struct ratio_static_string
+{
+ typedef basic_str<CharT, ...> short_name;
+ typedef basic_str<CharT, ...> long_name;
+};
+
+} // boost
+
+*/
+
+#include <boost/config.hpp>
+#include <boost/ratio/ratio.hpp>
+#include <boost/static_string/basic_str.hpp>
+//#include <sstream>
+
+
+#if defined(BOOST_NO_UNICODE_LITERALS) || defined(BOOST_NO_CHAR16_T) || defined(BOOST_NO_CHAR32_T)
+//~ #define BOOST_RATIO_HAS_UNICODE_SUPPORT
+#else
+#define BOOST_RATIO_HAS_UNICODE_SUPPORT 1
+#endif
+
+namespace boost {
+
+template <class Ratio, class CharT>
+struct ratio_static_string;
+
+
+// atto
+
+template <>
+struct ratio_static_string<atto, char>
+{
+ typedef static_string::str_1<'a'>::type short_name;
+ typedef static_string::str_4<'a','t','t','o'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<atto, char16_t>
+{
+ typedef static_string::u16str_1<u'a'>::type short_name;
+ typedef static_string::u16str_4<u'a',u't',u't',u'o'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<atto, char32_t>
+{
+ typedef static_string::u32str_1<U'a'>::type short_name;
+ typedef static_string::u32str_4<U'a',U't',U't',U'o'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<atto, wchar_t>
+{
+ typedef static_string::wstr_1<L'a'>::type short_name;
+ typedef static_string::wstr_4<L'a',L't',L't',L'o'>::type long_name;
+};
+#endif
+
+// femto
+
+template <>
+struct ratio_static_string<femto, char>
+{
+ typedef static_string::str_1<'f'>::type short_name;
+ typedef static_string::str_5<'f','e','m','t','o'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<femto, char16_t>
+{
+ typedef static_string::u16str_1<u'f'>::type short_name;
+ typedef static_string::u16str_5<u'f',u'e',u'm',u't',u'o'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<femto, char32_t>
+{
+ typedef static_string::u32str_1<U'f'>::type short_name;
+ typedef static_string::u32str_5<U'f',U'e',U'm',U't',U'o'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<femto, wchar_t>
+{
+ typedef static_string::wstr_1<L'f'>::type short_name;
+ typedef static_string::wstr_5<L'f',L'e',L'm',L't',L'o'>::type long_name;
+};
+#endif
+
+// pico
+
+template <>
+struct ratio_static_string<pico, char>
+{
+ typedef static_string::str_1<'p'>::type short_name;
+ typedef static_string::str_4<'p','i','c','o'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<pico, char16_t>
+{
+ typedef static_string::u16str_1<u'p'>::type short_name;
+ typedef static_string::u16str_4<u'p',u'i',u'c',u'o'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<pico, char32_t>
+{
+ typedef static_string::u32str_1<U'p'>::type short_name;
+ typedef static_string::u32str_4<U'p',U'i',U'c',U'o'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<pico, wchar_t>
+{
+ typedef static_string::wstr_1<L'p'>::type short_name;
+ typedef static_string::wstr_4<L'p',L'i',L'c',L'o'>::type long_name;
+};
+#endif
+
+// nano
+
+template <>
+struct ratio_static_string<nano, char>
+{
+ typedef static_string::str_1<'n'>::type short_name;
+ typedef static_string::str_4<'n','a','n','o'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<nano, char16_t>
+{
+ typedef static_string::u16str_1<u'n'>::type short_name;
+ typedef static_string::u16str_4<u'n',u'a',u'n',u'o'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<nano, char32_t>
+{
+ typedef static_string::u32str_1<U'n'>::type short_name;
+ typedef static_string::u32str_4<U'n',U'a',U'n',U'o'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<nano, wchar_t>
+{
+ typedef static_string::wstr_1<L'n'>::type short_name;
+ typedef static_string::wstr_4<L'n',L'a',L'n',L'o'>::type long_name;
+};
+#endif
+
+// micro
+
+template <>
+struct ratio_static_string<micro, char>
+{
+ typedef static_string::str_2<'\xC2','\xB5'>::type short_name;
+ typedef static_string::str_5<'m','i','c','r','o'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<micro, char16_t>
+{
+ typedef static_string::u16str_1<u'\xB5'>::type short_name;
+ typedef static_string::u16str_5<u'm',u'i',u'c',u'r',u'o'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<micro, char32_t>
+{
+ typedef static_string::u32str_1<U'\xB5'>::type short_name;
+ typedef static_string::u32str_5<U'm',U'i',U'c',U'r',U'o'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<micro, wchar_t>
+{
+ typedef static_string::wstr_1<L'\xB5'>::type short_name;
+ typedef static_string::wstr_5<L'm',L'i',L'c',L'r',L'o'>::type long_name;
+};
+#endif
+
+// milli
+
+template <>
+struct ratio_static_string<milli, char>
+{
+ typedef static_string::str_1<'m'>::type short_name;
+ typedef static_string::str_5<'m','i','l','l','i'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<milli, char16_t>
+{
+ typedef static_string::u16str_1<u'm'>::type short_name;
+ typedef static_string::u16str_5<u'm',u'i',u'l',u'l',u'i'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<milli, char32_t>
+{
+ typedef static_string::u32str_1<U'm'>::type short_name;
+ typedef static_string::u32str_5<U'm',U'i',U'l',U'l',U'i'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<milli, wchar_t>
+{
+ typedef static_string::wstr_1<L'm'>::type short_name;
+ typedef static_string::wstr_5<L'm',L'i',L'l',L'l',L'i'>::type long_name;
+};
+#endif
+
+// centi
+
+template <>
+struct ratio_static_string<centi, char>
+{
+ typedef static_string::str_1<'c'>::type short_name;
+ typedef static_string::str_5<'c','e','n','t','i'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<centi, char16_t>
+{
+ typedef static_string::u16str_1<u'c'>::type short_name;
+ typedef static_string::u16str_5<u'c',u'e',u'n',u't',u'i'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<centi, char32_t>
+{
+ typedef static_string::u32str_1<U'c'>::type short_name;
+ typedef static_string::u32str_5<U'c',U'e',U'n',U't',U'i'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<centi, wchar_t>
+{
+ typedef static_string::wstr_1<L'c'>::type short_name;
+ typedef static_string::wstr_5<L'c',L'e',L'n',L't',L'i'>::type long_name;
+};
+#endif
+
+// deci
+
+template <>
+struct ratio_static_string<deci, char>
+{
+ typedef static_string::str_1<'d'>::type short_name;
+ typedef static_string::str_4<'d','e','c','i'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<deci, char16_t>
+{
+ typedef static_string::u16str_1<u'd'>::type short_name;
+ typedef static_string::u16str_4<u'd',u'e',u'c',u'i'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<deci, char32_t>
+{
+ typedef static_string::u32str_1<U'd'>::type short_name;
+ typedef static_string::u32str_4<U'd',U'e',U'c',U'i'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<deci, wchar_t>
+{
+ typedef static_string::wstr_1<L'd'>::type short_name;
+ typedef static_string::wstr_4<L'd',L'e',L'c',L'i'>::type long_name;
+};
+#endif
+
+// deca
+
+template <>
+struct ratio_static_string<deca, char>
+{
+ typedef static_string::str_2<'d','a'>::type short_name;
+ typedef static_string::str_4<'d','e','c','a'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<deca, char16_t>
+{
+ typedef static_string::u16str_2<u'd',u'a'>::type short_name;
+ typedef static_string::u16str_4<u'd',u'e',u'c',u'a'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<deca, char32_t>
+{
+ typedef static_string::u32str_2<U'd',U'a'>::type short_name;
+ typedef static_string::u32str_4<U'd',U'e',U'c',U'a'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<deca, wchar_t>
+{
+ typedef static_string::wstr_2<L'd',L'a'>::type short_name;
+ typedef static_string::wstr_4<L'd',L'e',L'c',L'a'>::type long_name;
+};
+#endif
+
+// hecto
+
+template <>
+struct ratio_static_string<hecto, char>
+{
+ typedef static_string::str_1<'h'>::type short_name;
+ typedef static_string::str_5<'h','e','c','t','o'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<hecto, char16_t>
+{
+ typedef static_string::u16str_1<u'h'>::type short_name;
+ typedef static_string::u16str_5<u'h',u'e',u'c',u't',u'o'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<hecto, char32_t>
+{
+ typedef static_string::u32str_1<U'h'>::type short_name;
+ typedef static_string::u32str_5<U'h',U'e',U'c',U't',U'o'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<hecto, wchar_t>
+{
+ typedef static_string::wstr_1<L'h'>::type short_name;
+ typedef static_string::wstr_5<L'h',L'e',L'c',L't',L'o'>::type long_name;
+};
+#endif
+
+// kilo
+
+template <>
+struct ratio_static_string<kilo, char>
+{
+ typedef static_string::str_1<'k'>::type short_name;
+ typedef static_string::str_4<'k','i','l','o'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<kilo, char16_t>
+{
+ typedef static_string::u16str_1<u'k'>::type short_name;
+ typedef static_string::u16str_4<u'k',u'i',u'l',u'o'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<kilo, char32_t>
+{
+ typedef static_string::u32str_1<U'k'>::type short_name;
+ typedef static_string::u32str_4<U'k',U'i',U'l',U'o'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<kilo, wchar_t>
+{
+ typedef static_string::wstr_1<L'k'>::type short_name;
+ typedef static_string::wstr_4<L'k',L'i',L'l',L'o'>::type long_name;
+};
+#endif
+
+// mega
+
+template <>
+struct ratio_static_string<mega, char>
+{
+ typedef static_string::str_1<'M'>::type short_name;
+ typedef static_string::str_4<'m','e','g','a'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<mega, char16_t>
+{
+ typedef static_string::u16str_1<u'M'>::type short_name;
+ typedef static_string::u16str_4<u'm',u'e',u'g',u'a'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<mega, char32_t>
+{
+ typedef static_string::u32str_1<U'M'>::type short_name;
+ typedef static_string::u32str_4<U'm',U'e',U'g',U'a'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<mega, wchar_t>
+{
+ typedef static_string::wstr_1<L'M'>::type short_name;
+ typedef static_string::wstr_4<L'm',L'e',L'g',L'a'>::type long_name;
+};
+#endif
+
+// giga
+
+template <>
+struct ratio_static_string<giga, char>
+{
+ typedef static_string::str_1<'G'>::type short_name;
+ typedef static_string::str_4<'g','i','g','a'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<giga, char16_t>
+{
+ typedef static_string::u16str_1<u'G'>::type short_name;
+ typedef static_string::u16str_4<u'g',u'i',u'g',u'a'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<giga, char32_t>
+{
+ typedef static_string::u32str_1<U'G'>::type short_name;
+ typedef static_string::u32str_4<U'g',U'i',U'g',U'a'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<giga, wchar_t>
+{
+ typedef static_string::wstr_1<L'G'>::type short_name;
+ typedef static_string::wstr_4<L'g',L'i',L'g',L'a'>::type long_name;
+};
+#endif
+
+// tera
+
+template <>
+struct ratio_static_string<tera, char>
+{
+ typedef static_string::str_1<'T'>::type short_name;
+ typedef static_string::str_4<'t','e','r','a'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<tera, char16_t>
+{
+ typedef static_string::u16str_1<u'T'>::type short_name;
+ typedef static_string::u16str_4<u't',u'e',u'r',u'a'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<tera, char32_t>
+{
+ typedef static_string::u32str_1<U'T'>::type short_name;
+ typedef static_string::u32str_4<U't',U'e',U'r',U'a'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<tera, wchar_t>
+{
+ typedef static_string::wstr_1<L'T'>::type short_name;
+ typedef static_string::wstr_4<L'r',L'e',L'r',L'a'>::type long_name;
+};
+#endif
+
+// peta
+
+template <>
+struct ratio_static_string<peta, char>
+{
+ typedef static_string::str_1<'P'>::type short_name;
+ typedef static_string::str_4<'p','e','t','a'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<peta, char16_t>
+{
+ typedef static_string::u16str_1<u'P'>::type short_name;
+ typedef static_string::u16str_4<u'p',u'e',u't',u'a'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<peta, char32_t>
+{
+ typedef static_string::u32str_1<U'P'>::type short_name;
+ typedef static_string::u32str_4<U'p',U'e',U't',U'a'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<peta, wchar_t>
+{
+ typedef static_string::wstr_1<L'P'>::type short_name;
+ typedef static_string::wstr_4<L'p',L'e',L't',L'a'>::type long_name;
+};
+#endif
+
+// exa
+
+template <>
+struct ratio_static_string<exa, char>
+{
+ typedef static_string::str_1<'E'>::type short_name;
+ typedef static_string::str_3<'e','x','a'>::type long_name;
+};
+
+#ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
+
+template <>
+struct ratio_static_string<exa, char16_t>
+{
+ typedef static_string::u16str_1<u'E'>::type short_name;
+ typedef static_string::u16str_3<u'e',u'x',u'a'>::type long_name;
+};
+
+template <>
+struct ratio_static_string<exa, char32_t>
+{
+ typedef static_string::u32str_1<U'E'>::type short_name;
+ typedef static_string::u32str_3<U'e',U'x',U'a'>::type long_name;
+};
+
+#endif
+
+#ifndef BOOST_NO_STD_WSTRING
+template <>
+struct ratio_static_string<exa, wchar_t>
+{
+ typedef static_string::wstr_1<L'E'>::type short_name;
+ typedef static_string::wstr_3<L'e',L'x',L'a'>::type long_name;
+};
+#endif
+
+}
+
+#endif // BOOST_RATIO_RATIO_STATIC_STRING_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk