Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70321 - in branches/release/libs/ratio: . doc example example/type_traits example/type_traits/detail test test/ratio_arithmetic test/ratio_comparison test/ratio_extensions test/ratio_io test/ratio_ratio
From: vicente.botet_at_[hidden]
Date: 2011-03-21 13:18:02


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

Log:
Ratio: import from Trunk
Added:
   branches/release/libs/ratio/
   branches/release/libs/ratio/doc/
   branches/release/libs/ratio/doc/Jamfile.v2 (contents, props changed)
   branches/release/libs/ratio/doc/ratio.qbk (contents, props changed)
   branches/release/libs/ratio/example/
   branches/release/libs/ratio/example/config.hpp (contents, props changed)
   branches/release/libs/ratio/example/display_ex.cpp (contents, props changed)
   branches/release/libs/ratio/example/duration.hpp (contents, props changed)
   branches/release/libs/ratio/example/si_physics.cpp (contents, props changed)
   branches/release/libs/ratio/example/static_assert.hpp (contents, props changed)
   branches/release/libs/ratio/example/type_traits/
   branches/release/libs/ratio/example/type_traits/add_rvalue_reference.hpp (contents, props changed)
   branches/release/libs/ratio/example/type_traits/common_type.hpp (contents, props changed)
   branches/release/libs/ratio/example/type_traits/declval.hpp (contents, props changed)
   branches/release/libs/ratio/example/type_traits/detail/
   branches/release/libs/ratio/example/type_traits/detail/common_type.hpp (contents, props changed)
   branches/release/libs/ratio/index.html (contents, props changed)
   branches/release/libs/ratio/test/
   branches/release/libs/ratio/test/Jamfile.v2 (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_2_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_3_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_divide_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_multiply_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_subtract_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_arithmetic/ratio_subtract_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_comparison/
   branches/release/libs/ratio/test/ratio_comparison/ratio_equal_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_comparison/ratio_greater_equal_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_comparison/ratio_greater_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_comparison/ratio_less_equal_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_comparison/ratio_less_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_comparison/ratio_not_equal_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/
   branches/release/libs/ratio/test/ratio_extensions/mpl_abs_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_arithmetic_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_comparison_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_divides_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_equal_to_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_greater_equal_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_greater_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_less_equal_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_less_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_minus_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_negate_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_not_equal_to_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_plus_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_rational_constant_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_sign_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/mpl_times_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_extensions/ratio_ext_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_io/
   branches/release/libs/ratio/test/ratio_io/ratio_io_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_io/ratio_io_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_ratio/
   branches/release/libs/ratio/test/ratio_ratio/ratio1_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_ratio/ratio2_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_ratio/ratio3_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_ratio/ratio4_fail.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_ratio/ratio_pass.cpp (contents, props changed)
   branches/release/libs/ratio/test/ratio_test.cpp (contents, props changed)
   branches/release/libs/ratio/test/typedefs_pass.cpp (contents, props changed)

Added: branches/release/libs/ratio/doc/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/doc/Jamfile.v2 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,75 @@
+# Boost.Ratio library documentation Jamfile ---------------------------------
+#
+# Copyright Vicente J. Botet Escriba 2010. Use, modification and
+# distribution is 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)
+#
+# See http://www.boost.org for updates, documentation, and revision history.
+
+#import doxygen ;
+import quickbook ;
+
+#doxygen autodoc
+# :
+# [ glob ../../../boost/chrono/*.hpp ]
+# [ glob ../../../boost/chrono/allocators/*.hpp ]
+# :
+# <doxygen:param>EXTRACT_ALL=NO
+# <doxygen:param>HIDE_UNDOC_MEMBERS=YES
+# <doxygen:param>EXTRACT_PRIVATE=NO
+# <doxygen:param>EXPAND_ONLY_PREDEF=YES
+# <doxygen:param>PREDEFINED=BOOST_INTERPROCESS_DOXYGEN_INVOKED
+# <xsl:param>"boost.doxygen.reftitle=Boost.Chrono Reference"
+# ;
+
+xml ratio : ratio.qbk ;
+
+boostbook standalone
+ :
+ ratio
+ :
+ # HTML options first:
+ # Use graphics not text for navigation:
+ <xsl:param>navig.graphics=1
+ # How far down we chunk nested sections, basically all of them:
+ <xsl:param>chunk.section.depth=0
+ # Don't put the first section on the same page as the TOC:
+ <xsl:param>chunk.first.sections=1
+ # How far down sections get TOC's
+ <xsl:param>toc.section.depth=4
+ # Max depth in each TOC:
+ <xsl:param>toc.max.depth=2
+ # How far down we go with TOC's
+ <xsl:param>generate.section.toc.level=10
+ # Path for links to Boost:
+ <xsl:param>boost.root=../../../..
+ # Path for libraries index:
+ <xsl:param>boost.libraries=../../../../libs/libraries.htm
+ # Use the main Boost stylesheet:
+ <xsl:param>html.stylesheet=../../../../doc/src/boostbook.css
+
+ # PDF Options:
+ # TOC Generation: this is needed for FOP-0.9 and later:
+ <xsl:param>fop1.extensions=0
+ # Or enable this if you're using XEP:
+ <xsl:param>xep.extensions=1
+ # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
+ <xsl:param>fop.extensions=0
+ # No indent on body text:
+ <xsl:param>body.start.indent=0pt
+ # Margin size:
+ <xsl:param>page.margin.inner=0.5in
+ # Margin size:
+ <xsl:param>page.margin.outer=0.5in
+ # Yes, we want graphics for admonishments:
+ <xsl:param>admon.graphics=1
+ # Set this one for PDF generation *only*:
+ # default pnd graphics are awful in PDF form,
+ # better use SVG's instead:
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>admon.graphics.path=$(boost-images)/
+ <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/ratio/doc/html
+ ;
+
+install pdf-install : standalone : <location>. <install-type>PDF ;

Added: branches/release/libs/ratio/doc/ratio.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/doc/ratio.qbk 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,1965 @@
+[/
+ / Copyright (c) 2008 Howard Hinnant
+ / Copyright (c) 2006, 2008 Beman Dawes
+ / Copyright (c) 2009-2011 Vicente J. Botet Escriba
+ /
+ / 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)
+ /]
+
+[library Boost.Ratio
+ [quickbook 1.5]
+ [version 1.0.1]
+ [authors [Hinnant, Howard]]
+ [authors [Dawes, Beman]]
+ [authors [Botet Escriba, Vicente J.]]
+ [copyright 2008 Howard Hinnant]
+ [copyright 2006, 2008 Beman Dawes]
+ [copyright 2009-2011 Vicente J. Botet Escriba]
+ [category math]
+ [id ratio]
+ [dirname ratio]
+ [purpose
+ Compile time rational arithmetic.
+ ]
+ [license
+ 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])
+ ]
+]
+
+[/==================]
+[def __Boost_Ratio [*Boost.Ratio]]
+
+[/===============================================]
+
+[def __time_point `time_point`]
+[def __hours `hours`]
+
+[/===============================================]
+[def __ratio [link ratio.reference.std.ratio_hpp.ratio `ratio`]]
+
+[template ratio_conf[link_text] [link ratio.reference.std.ratio_hpp.conf [link_text]]]
+
+[def __BOOST_RATIO_USES_STATIC_ASSERT [link ratio.reference.std.ratio_hpp.conf `BOOST_RATIO_USES_STATIC_ASSERT`]]
+[def __BOOST_RATIO_USES_MPL_ASSERT [link ratio.reference.std.ratio_hpp.conf `BOOST_RATIO_USES_MPL_ASSERT`]]
+[def __BOOST_RATIO_USES_ARRAY_ASSERT [link ratio.reference.std.ratio_hpp.conf `BOOST_RATIO_USES_ARRAY_ASSERT`]]
+
+[def __BOOST_RATIO_EXTENSIONS [link ratio.reference.std.ratio_hpp.extensions `BOOST_RATIO_EXTENSIONS`]]
+
+
+
+[template ratio_arithmetic[link_text] [link ratio.reference.std.ratio_hpp.ratio_arithmetic [link_text]]]
+[def __ratio_add [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_add`]]
+[def __ratio_subtract [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_subtract`]]
+[def __ratio_multiply [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_multiply`]]
+[def __ratio_divide [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_divide`]]
+[def __ratio_negate [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_negate`]]
+[def __ratio_abs [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_abs`]]
+[def __ratio_sign [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_sign`]]
+[def __ratio_gcd [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_gcd`]]
+[def __ratio_lcm [link ratio.reference.std.ratio_hpp.ratio_arithmetic `ratio_lcm`]]
+
+
+[template ratio_comparison[link_text] [link ratio.reference.std.ratio_hpp.ratio_comparison [link_text]]]
+[def __ratio_equal [link ratio.reference.std.ratio_hpp.ratio_comparison `ratio_equal`]]
+[def __ratio_not_equal [link ratio.reference.std.ratio_hpp.ratio_comparison `ratio_not_equal`]]
+[def __ratio_less [link ratio.reference.std.ratio_hpp.ratio_comparison `ratio_less`]]
+[def __ratio_less_equal [link ratio.reference.std.ratio_hpp.ratio_comparison `ratio_less_equal`]]
+[def __ratio_greater [link ratio.reference.std.ratio_hpp.ratio_comparison `ratio_greater`]]
+[def __ratio_greater_equal [link ratio.reference.std.ratio_hpp.ratio_comparison `ratio_greater_equal`]]
+
+
+[template ratio_si_typedefs[link_text] [link ratio.reference.std.ratio_hpp.ratio_si_typedefs [link_text]]]
+[def __atto [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `atto`]]
+[def __femto [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `femto`]]
+[def __pico [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `pico`]]
+[def __nano [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `nano`]]
+[def __micro [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `micro`]]
+[def __milli [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `milli`]]
+[def __centi [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `centi`]]
+[def __deci [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `deci`]]
+[def __deca [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `deca`]]
+[def __hecto [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `hecto`]]
+[def __kilo [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `kilo`]]
+[def __mega [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `mega`]]
+[def __giga [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `giga`]]
+[def __tera [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `tera`]]
+[def __peta [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `peta`]]
+[def __exa [link ratio.reference.std.ratio_hpp.ratio_si_typedefs `exa`]]
+
+[template mu[]'''&#x3BC;'''] [/ µ Greek small letter mu]
+
+[def __Rational_Constant [link ratio.reference.mpl.rational_constant Rational Constant]]
+
+
+[/warning Ratio is not part of the Boost libraries.]
+
+[/===============]
+[section Overview]
+[/===============]
+
+
+[/====================================]
+[heading How to Use This Documentation]
+[/====================================]
+
+This documentation makes use of the following naming and formatting conventions.
+
+* Code is in `fixed width font` and is syntax-highlighted.
+* Replaceable text that you will need to supply is in [~italics].
+* Free functions are rendered in the code font followed by `()`, as in `free_function()`.
+* If a name refers to a class template, it is specified like this: `class_template<>`; that is, it is in code font and its name is followed by `<>` to indicate that it is a class template.
+* If a name refers to a function-like macro, it is specified like this: `MACRO()`;
+ that is, it is uppercase in code font and its name is followed by `()` to indicate that it is a function-like macro. Object-like macros appear without the trailing `()`.
+* Names that refer to /concepts/ in the generic programming sense are specified in CamelCase.
+
+[note In addition, notes such as this one specify non-essential information that provides additional background or rationale.]
+
+Finally, you can mentally add the following to any code fragments in this document:
+
+ // Include all of Ratio files
+ #include <boost/ratio.hpp>
+ using namespace boost;
+
+[/=================]
+[section Motivation]
+[/=================]
+
+__Boost_Ratio aims to implement the compile time ratio facility in C++0x, as proposed in [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm [*N2661 - A Foundation to Sleep On]]. That document provides background and motivation for key design decisions and is the source of a good deal of information in this documentation.
+
+[endsect]
+
+[/==================]
+[section Description]
+[/==================]
+
+The __Boost_Ratio library provides:
+
+* A class template, __ratio, for specifying compile time rational constants such as 1/3 of a nanosecond or the number of inches per meter. __ratio represents a compile time ratio of compile time constants with support for compile time arithmetic with overflow and division by zero protection.
+
+* It provides a textual representation of `boost::ratio<N, D>` in the form of a `std::basic_string` which can be useful for I/O.
+
+* Some extension related to the __Rational_Constant concept enabling the use of __ratio<> in the context of [*Boost.MPL] numeric metafunctions.
+
+[endsect]
+
+[endsect]
+
+
+[/==============================]
+[section:users_guide User's Guide]
+[/==============================]
+
+[/======================================]
+[section:getting_started Getting Started]
+[/======================================]
+
+[/======================================]
+[section:install Installing Ratio]
+[/======================================]
+
+[/=================================]
+[heading Getting Boost.Ratio ]
+[/=================================]
+
+Boost.Ratio is in the latest Boost release in the folder `/boost/ratio`. Documentation, tests and examples folder are at `boost/libs/ratio/`.
+
+You can also access the latest (unstable?) state from the [@http://svn.boost.org/svn/boost/trunk Boost trunk] directories `boost/ratio` and `libs/ratio`.
+
+Just go to [@http://svn.boost.org/trac/boost/wiki/BoostSubversion the wiki] and follow the instructions there for anonymous SVN access.
+
+[/==========================================]
+[heading Where to install Boost.Ratio? ]
+[/==========================================]
+
+The simple way is to decompress (or checkout from SVN) the files in your BOOST_ROOT directory.
+
+[/=================================]
+[heading Building Boost.Ratio ]
+[/=================================]
+
+__Boost_Ratio is a header only library, so no need to compile anything, you just need to `include <boost/ratio.hpp>`.
+
+
+[/===================]
+[heading Requirements]
+[/===================]
+
+__Boost_Ratio depends on some Boost libraries. For these specific parts you must use either Boost version 1.39.0 or later (even older versions may work).
+
+In particular, __Boost_Ratio depends on:
+
+[variablelist
+[
+ [[@http://www.boost.org/libs/config [*Boost.Config]]] [for configuration purposes, ...]
+]
+[
+ [[@http://www.boost.org/libs/integer [*Boost.Integer]]] [for cstdint conformance, and integer traits ...]
+]
+[
+ [[@http://www.boost.org/libs/mpl [*Boost.MPL]]] [for MPL Assert and bool, logical ...]
+]
+[
+ [[@http://www.boost.org/libs/static_assert [*Boost.StaticAssert]]] [for STATIC_ASSERT, ...]
+]
+[
+ [[@http://www.boost.org/libs/type_traits [*Boost.TypeTraits]]] [for is_base, is_convertible ...]
+]
+[
+ [[@http://www.boost.org/libs/utility [*Boost.Utility/EnableIf]]] [for enable_if, ...]
+]
+]
+
+
+[/=========================================================]
+[heading Building an executable that uses __Boost_Ratio ]
+[/=========================================================]
+
+No link is needed.
+
+
+[/=========================]
+[heading Exception safety ]
+[/=========================]
+
+All functions in the library are exception-neutral, providing the strong exception safety guarantee.
+
+[/=====================]
+[heading Thread safety ]
+[/=====================]
+
+All functions in the library are thread-unsafe except when noted explicitly.
+
+[/========================]
+[heading Tested compilers ]
+[/========================]
+
+__Boost_Ratio should work with an C++03 conforming compiler. The current version has been tested on:
+
+Windows with
+
+* MSVC 10.0
+* MSVC 9.0 Express
+* MSVC 8.0
+
+Cygwin 1.5 with
+
+* GCC 3.4.4
+
+Cygwin 1.7 with
+
+* GCC 4.3.4
+
+MinGW with
+
+* GCC 4.4.0
+* GCC 4.5.0
+* GCC 4.5.0 -std=c++0x
+* GCC 4.6.0
+* GCC 4.6.0 -std=c++0x
+
+Ubuntu 10.10
+
+* GCC 4.4.5
+* GCC 4.4.5 -std=c++0x
+* GCC 4.5.1
+* GCC 4.5.1 -std=c++0x
+* clang 2.8
+
+Initial versions were tested on:
+
+MacOS with GCC 4.2.4
+
+Ubuntu Linux with GCC 4.2.4
+
+[note Please let us know how this works on other platforms/compilers.]
+
+[note Please send any questions, comments and bug reports to boost <at> lists <dot> boost <dot> org.]
+
+[endsect]
+[endsect]
+
+
+[section Tutorial]
+
+[heading Ratio]
+
+__ratio is a general purpose utility inspired by Walter Brown allowing one to easily and safely compute rational values at compile-time. The __ratio class catches all errors (such as divide by zero and overflow) at compile time. It is used in the duration and __time_point classes to efficiently create units of time. It can also be used in other "quantity" libraries or anywhere there is a rational constant which is known at compile-time. The use of this utility can greatly reduce the chances of run-time overflow because the __ratio (and any ratios resulting from __ratio arithmetic) are always reduced to the lowest terms.
+
+__ratio is a template taking two `intmax_ts`, with the second defaulted to 1. In addition to copy constructors and assignment, it only has two public members, both of which are `static const intmax_t`. One is the numerator of the __ratio and the other is the denominator. The __ratio is always normalized such that it is expressed in lowest terms, and the denominator is always positive. When the numerator is 0, the denominator is always 1.
+
+[*Example:]
+
+ typedef __ratio<5, 3> five_thirds;
+ // five_thirds::num == 5, five_thirds::den == 3
+
+ typedef __ratio<25, 15> also_five_thirds;
+ // also_five_thirds::num == 5, also_five_thirds::den == 3
+
+ typedef ratio_divide<five_thirds, also_five_thirds>::type one;
+ // one::num == 1, one::den == 1
+
+This facility also includes convenience typedefs for the SI prefixes __atto through __exa corresponding to their internationally recognized definitions (in terms of __ratio). This is a tremendous syntactic convenience. It will prevent errors in specifying constants as one no longer has to double count the number of zeros when trying to write millions or billions.
+
+[*Example:]
+
+ typedef ratio_multiply<__ratio<5>, giga>::type _5giga;
+ // _5giga::num == 5000000000, _5giga::den == 1
+
+ typedef ratio_multiply<__ratio<5>, nano>::type _5nano;
+ // _5nano::num == 1, _5nano::den == 200000000
+
+[heading Ratio I/O]
+
+For each `ratio<N, D>` there exists a `ratio_string<ratio<N, D>, CharT>` for which you can query two strings: `short_name` and `long_name`. For those `ratio`'s that correspond to an [@http://en.wikipedia.org/wiki/SI_prefix#List_of_SI_prefixes SI prefix] long_name corresponds to the internationally recognized prefix, stored as a `basic_string<CharT>`. For example `ratio_string<mega, char>::long_name()` returns `string("mega")`. For those `ratio`s that correspond to an [@http://en.wikipedia.org/wiki/SI_prefix#List_of_SI_prefixes SI prefix] `short_name` corresponds to the internationally recognized symbol, stored as a `basic_string<CharT>`. For example, `ratio_string<mega, char>::short_name()` returns `string("M")`. For all other `ratio`s, both `long_name()` and `short_name()` return a `basic_string` containing "[`ratio::num/ratio::den`]".
+
+`ratio_string<ratio<N, D>, CharT>` is only defined for four character types:
+
+* `char`: UTF-8
+* `char16_t`: UTF-16
+* `char32_t`: UTF-32
+* `wchar_t`: UTF-16 (if wchar_t is 16 bits) or UTF-32
+
+When the character is char, UTF-8 will be used to encode the names. When the character is `char16_t`, UTF-16 will be used to encode the names. When the character is `char32_t`, UTF-32 will be used to encode the names. When the character is `wchar_t`, the encoding will be UTF-16 if `wchar_t` is 16 bits, and otherwise UTF-32.
+
+The `short_name` (Greek mu or [mu]) for micro is defined by [@http://www.unicode.org/charts/PDF/U0080.pdf Unicode] to be U+00B5.
+
+[*Examples:]
+
+ #include <boost/ratio/ratio_io.hpp>
+ #include <iostream>
+
+ int main()
+ {
+ using namespace std;
+ using namespace boost;
+
+ cout << "ratio_string<deca, char>::long_name() = "
+ << ratio_string<deca, char>::long_name() << '\n';
+ cout << "ratio_string<deca, char>::short_name() = "
+ << ratio_string<deca, char>::short_name() << '\n';
+
+ cout << "ratio_string<giga, char>::long_name() = "
+ << ratio_string<giga, char>::long_name() << '\n';
+ cout << "ratio_string<giga, char>::short_name() = "
+ << ratio_string<giga, char>::short_name() << '\n';
+
+ cout << "ratio_string<ratio<4, 6>, char>::long_name() = "
+ << ratio_string<ratio<4, 6>, char>::long_name() << '\n';
+ cout << "ratio_string<ratio<4, 6>, char>::short_name() = "
+ << ratio_string<ratio<4, 6>, char>::short_name() << '\n';
+ }
+
+The output will be
+
+ ratio_string<deca, char>::long_name() = deca
+ ratio_string<deca, char>::short_name() = da
+ ratio_string<giga, char>::long_name() = giga
+ ratio_string<giga, char>::short_name() = G
+ ratio_string<ratio<4, 6>, char>::long_name() = [2/3]
+ ratio_string<ratio<4, 6>, char>::short_name() = [2/3]
+
+
+[heading Ratio MPL Numeric Metafunctions]
+
+With the view of the _ratio class as a __Rational_Constant we can mix _ratio<> and [*Boost.MPL] Integral Constants in the same expression, as in
+
+ typedef mpl::times<int_<5>, giga>::type _5giga;
+ // _5giga::num == 5000000000, _5giga::den == 1
+
+ typedef mpl::times<int_<5>, nano>::type _5nano;
+ // _5nano::num == 1, _5nano::den == 200000000
+
+
+[endsect]
+[/===============]
+[section:Examples Example]
+[/===============]
+
+[/===============]
+[section SI units]
+[/===============]
+
+This example illustrates the use of type-safe physics code interoperating with `boost::chrono::duration` types, taking advantage of the __Boost_Ratio infrastructure and design philosophy.
+
+Let's start by defining a `length` class template that mimics `boost::chrono::duration`, which represents a time duration in various units, but restricts the representation to `double` and uses __Boost_Ratio for length unit conversions:
+
+
+ template <class Ratio>
+ class length {
+ private:
+ double len_;
+ public:
+ typedef Ratio ratio;
+ length() : len_(1) {}
+ length(const double& len) : len_(len) {}
+
+ template <class R>
+ length(const length<R>& d)
+ : len_(d.count() * boost::ratio_divide<Ratio, R>::type::den /
+ boost::ratio_divide<Ratio, R>::type::num) {}
+
+ double count() const {return len_;}
+
+ length& operator+=(const length& d) {len_ += d.count(); return *this;}
+ length& operator-=(const length& d) {len_ -= d.count(); return *this;}
+
+ length operator+() const {return *this;}
+ length operator-() const {return length(-len_);}
+
+ length& operator*=(double rhs) {len_ *= rhs; return *this;}
+ length& operator/=(double rhs) {len_ /= rhs; return *this;}
+ };
+
+
+Here's a small sampling of length units:
+
+ typedef length<boost::__ratio<1> > meter; // set meter as "unity"
+ typedef length<boost::__centi> centimeter; // 1/100 meter
+ typedef length<boost::__kilo> kilometer; // 1000 meters
+ typedef length<boost::__ratio<254, 10000> > inch; // 254/10000 meters
+
+Note that since `length`'s template parameter is actually a generic ratio type, so we can use boost::ratio allowing for more complex length units:
+
+ typedef length<boost::ratio_multiply<boost::__ratio<12>, inch::__ratio>::type> foot; // 12 inchs
+ typedef length<boost::ratio_multiply<boost::__ratio<5280>, foot::__ratio>::type> mile; // 5280 feet
+
+Now we need a floating point-based definition of seconds:
+
+ typedef boost::chrono::duration<double> seconds; // unity
+
+We can even support sub-nanosecond durations:
+
+ typedef boost::chrono::duration<double, boost::__pico> picosecond; // 10^-12 seconds
+ typedef boost::chrono::duration<double, boost::__femto> femtosecond; // 10^-15 seconds
+ typedef boost::chrono::duration<double, boost::__atto> attosecond; // 10^-18 seconds
+
+Finally, we can write a proof-of-concept of an SI units library, hard-wired for meters and floating point seconds, though it will accept other units:
+
+ template <class R1, class R2>
+ class quantity
+ {
+ double q_;
+ public:
+ typedef R1 time_dim;
+ typedef R2 distance_dim;
+ quantity() : q_(1) {}
+
+ double get() const {return q_;}
+ void set(double q) {q_ = q;}
+ };
+
+ template <>
+ class quantity<boost::__ratio<1>, boost::__ratio<0> >
+ {
+ double q_;
+ public:
+ quantity() : q_(1) {}
+ quantity(seconds d) : q_(d.count()) {} // note: only User1::seconds needed here
+
+ double get() const {return q_;}
+ void set(double q) {q_ = q;}
+ };
+
+ template <>
+ class quantity<boost::__ratio<0>, boost::__ratio<1> >
+ {
+ double q_;
+ public:
+ quantity() : q_(1) {}
+ quantity(meter d) : q_(d.count()) {} // note: only User1::meter needed here
+
+ double get() const {return q_;}
+ void set(double q) {q_ = q;}
+ };
+
+ template <>
+ class quantity<boost::__ratio<0>, boost::__ratio<0> >
+ {
+ double q_;
+ public:
+ quantity() : q_(1) {}
+ quantity(double d) : q_(d) {}
+
+ double get() const {return q_;}
+ void set(double q) {q_ = q;}
+ };
+
+That allows us to create some useful SI-based unit types:
+
+ typedef quantity<boost::__ratio<0>, boost::__ratio<0> > Scalar;
+ typedef quantity<boost::__ratio<1>, boost::__ratio<0> > Time; // second
+ typedef quantity<boost::__ratio<0>, boost::__ratio<1> > Distance; // meter
+ typedef quantity<boost::__ratio<-1>, boost::__ratio<1> > Speed; // meter/second
+ typedef quantity<boost::__ratio<-2>, boost::__ratio<1> > Acceleration; // meter/second^2
+
+To make quantity useful, we need to be able to do arithmetic:
+
+ template <class R1, class R2, class R3, class R4>
+ quantity<typename boost::ratio_subtract<R1, R3>::type,
+ typename boost::ratio_subtract<R2, R4>::type>
+ operator/(const quantity<R1, R2>& x, const quantity<R3, R4>& y)
+ {
+ typedef quantity<typename boost::ratio_subtract<R1, R3>::type,
+ typename boost::ratio_subtract<R2, R4>::type> R;
+ R r;
+ r.set(x.get() / y.get());
+ return r;
+ }
+
+ template <class R1, class R2, class R3, class R4>
+ quantity<typename boost::ratio_add<R1, R3>::type,
+ typename boost::ratio_add<R2, R4>::type>
+ operator*(const quantity<R1, R2>& x, const quantity<R3, R4>& y)
+ {
+ typedef quantity<typename boost::ratio_add<R1, R3>::type,
+ typename boost::ratio_add<R2, R4>::type> R;
+ R r;
+ r.set(x.get() * y.get());
+ return r;
+ }
+
+ template <class R1, class R2>
+ quantity<R1, R2>
+ operator+(const quantity<R1, R2>& x, const quantity<R1, R2>& y)
+ {
+ typedef quantity<R1, R2> R;
+ R r;
+ r.set(x.get() + y.get());
+ return r;
+ }
+
+ template <class R1, class R2>
+ quantity<R1, R2>
+ operator-(const quantity<R1, R2>& x, const quantity<R1, R2>& y)
+ {
+ typedef quantity<R1, R2> R;
+ R r;
+ r.set(x.get() - y.get());
+ return r;
+ }
+
+With all of the foregoing scaffolding, we can now write an exemplar of a type-safe physics function:
+
+ Distance
+ compute_distance(Speed v0, Time t, Acceleration a)
+ {
+ return v0 * t + Scalar(.5) * a * t * t; // if a units mistake is made here it won't compile
+ }
+
+
+Finally, we can exercise what we've created, even using custom time durations (`User1::seconds`) as well as Boost time durations (`boost::chrono::hours`). The input can be in arbitrary, though type-safe, units, the output is always in SI units. (A complete Units library would support other units, of course.)
+
+ int main()
+ {
+ typedef boost::__ratio<8, BOOST_INTMAX_C(0x7FFFFFFFD)> R1;
+ typedef boost::__ratio<3, BOOST_INTMAX_C(0x7FFFFFFFD)> R2;
+ typedef User1::quantity<boost::ratio_subtract<boost::__ratio<0>, boost::__ratio<1> >::type,
+ boost::ratio_subtract<boost::__ratio<1>, boost::__ratio<0> >::type > RR;
+ typedef boost::ratio_subtract<R1, R2>::type RS;
+ std::cout << RS::num << '/' << RS::den << '\n';
+
+
+ std::cout << "*************\n";
+ std::cout << "* testUser1 *\n";
+ std::cout << "*************\n";
+ User1::Distance d( User1::mile(110) );
+ User1::Time t( boost::chrono::__hours(2) );
+
+ RR r=d / t;
+ //r.set(d.get() / t.get());
+
+ User1::Speed rc= r;
+
+ User1::Speed s = d / t;
+ std::cout << "Speed = " << s.get() << " meters/sec\n";
+ User1::Acceleration a = User1::Distance( User1::foot(32.2) ) / User1::Time() / User1::Time();
+ std::cout << "Acceleration = " << a.get() << " meters/sec^2\n";
+ User1::Distance df = compute_distance(s, User1::Time( User1::seconds(0.5) ), a);
+ std::cout << "Distance = " << df.get() << " meters\n";
+ std::cout << "There are "
+ << User1::mile::ratio::den << '/' << User1::mile::ratio::num << " miles/meter";
+ User1::meter mt = 1;
+ User1::mile mi = mt;
+ std::cout << " which is approximately " << mi.count() << '\n';
+ std::cout << "There are "
+ << User1::mile::ratio::num << '/' << User1::mile::ratio::den << " meters/mile";
+ mi = 1;
+ mt = mi;
+ std::cout << " which is approximately " << mt.count() << '\n';
+ User1::attosecond as(1);
+ User1::seconds sec = as;
+ std::cout << "1 attosecond is " << sec.count() << " seconds\n";
+ std::cout << "sec = as; // compiles\n";
+ sec = User1::seconds(1);
+ as = sec;
+ std::cout << "1 second is " << as.count() << " attoseconds\n";
+ std::cout << "as = sec; // compiles\n";
+ std::cout << "\n";
+ return 0;
+ }
+
+['See the source file [@../../example/si_physics.cpp example/si_physics.cpp]]
+
+[endsect]
+
+
+[endsect]
+
+[/================================]
+[section:ext_references External Resources]
+[/================================]
+
+[variablelist
+
+[
+ [[@http://www.open-std.org/jtc1/sc22/wg21 [*C++ Standards Committee's current Working Paper]]]
+ [The most authoritative reference material for the library is the C++ Standards Committee's current Working Paper (WP). 20.6 Compile-time rational arithmetic "ratio"]
+]
+
+[
+ [[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm [*N2661 - A Foundation to Sleep On]]]
+ [From Howard E. Hinnant, Walter E. Brown, Jeff Garland and Marc Paterno. Is very informative and provides motivation for key design decisions]
+]
+
+
+[
+ [[@http://lwg.github.com/issues/lwg-defects.html#1281 [*LWG 1281. CopyConstruction and Assignment between ratios having the same normalized form]]]
+ [From Vicente Juan Botet Escriba.]
+]
+
+
+]
+
+[endsect]
+
+[endsect]
+
+[/=================]
+[section:reference Reference ]
+[/=================]
+
+[/=================================================]
+[section:std C++0x Recommendation]
+[/=================================================]
+
+[/=================================================]
+[section:ratio_ratio_hpp Header `<boost/ratio.hpp>`]
+[/=================================================]
+
+This header includes all the ratio related header files
+
+ #include <boost/ratio/ratio.hpp>
+ #include <boost/ratio/ratio_io.hpp>
+ #include <boost/ratio/rational_constant.hpp>
+
+[endsect]
+
+[/========================================================]
+[section:ratio_fwdhpp Header `<boost/ratio/ratio_fwd.hpp>`]
+[/========================================================]
+
+This header provides forward declarations for the `<boost/ratio/ratio.hpp>` file.
+
+ namespace boost {
+
+ 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;
+ template <class R> struct __ratio_negate;
+ template <class R> struct __ratio_sign;
+ template <class R> struct __ratio_abs;
+ template <class R1, class R2> struct __ratio_gcd;
+ template <class R1, class R2> struct __ratio_lcm;
+
+ // 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<1LL, 1000000000000000000LL> __atto;
+ typedef ratio<1LL, 1000000000000000LL> __femto;
+ typedef ratio<1LL, 1000000000000LL> __pico;
+ typedef ratio<1LL, 1000000000LL> __nano;
+ typedef ratio<1LL, 1000000LL> __micro;
+ typedef ratio<1LL, 1000LL> __milli;
+ typedef ratio<1LL, 100LL> __centi;
+ typedef ratio<1LL, 10LL> __deci;
+ typedef ratio< 10LL, 1LL> __deca;
+ typedef ratio< 100LL, 1LL> __hecto;
+ typedef ratio< 1000LL, 1LL> __kilo;
+ typedef ratio< 1000000LL, 1LL> __mega;
+ typedef ratio< 1000000000LL, 1LL> __giga;
+ typedef ratio< 1000000000000LL, 1LL> __tera;
+ typedef ratio< 1000000000000000LL, 1LL> __peta;
+ typedef ratio<1000000000000000000LL, 1LL> __exa;
+ }
+
+[endsect]
+
+[/=================================================]
+[section:ratio_hpp Header `<boost/ratio/ratio.hpp>`]
+[/=================================================]
+
+__ratio is a facility which is useful in specifying compile-time rational constants. Compile-time rational arithmetic is supported with protection against overflow and divide by zero. Such a facility is very handy to efficiently represent 1/3 of a nanosecond, or to specify an inch in terms of meters (for example 254/10000 meters - which __ratio will reduce to 127/5000 meters).
+
+ // Configuration macros
+ #define __BOOST_RATIO_USES_STATIC_ASSERT
+ #define __BOOST_RATIO_USES_MPL_ASSERT
+ #define __BOOST_RATIO_USES_ARRAY_ASSERT
+ #define __BOOST_RATIO_EXTENSIONS
+
+
+[section:conf Configuration Macros]
+
+When BOOST_NO_STATIC_ASSERT is defined, the user can select the way static assertions are reported. Define
+
+* BOOST_RATIO_USES_STATIC_ASSERT to use Boost.StaticAssert.
+* BOOST_RATIO_USES_MPL_ASSERT to use [*Boost.MPL] static assertions.
+* BOOST_RATIO_USES_RATIO_ASSERT to use __Boost_Ratio static assertions.
+
+The default behavior is as if BOOST_RATIO_USES_ARRAY_ASSERT is defined.
+
+When BOOST_RATIO_USES_MPL_ASSERT is not defined the following symbols are defined as shown:
+
+ #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"
+
+Depending upon the static assertion system used, a hint as to the failing assertion will appear in some form in the compiler diagnostic output.
+
+When BOOST_RATIO_EXTENSIONS is defined, __Boost_Ratio provides in addition some extenion to the C++ standard, see below.
+
+
+[endsect]
+
+[section:ratio Class Template `ratio<>`]
+
+ template <boost::intmax_t N, boost::intmax_t D>
+ class ratio {
+ public:
+ static const boost::intmax_t num;
+ static const boost::intmax_t den;
+ typedef ratio<num, den> type;
+
+ #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() = default;
+
+ template <intmax_t _N2, intmax_t _D2>
+ ratio(const ratio<_N2, _D2>&);
+
+ template <intmax_t _N2, intmax_t _D2>
+ ratio& operator=(const ratio<_N2, _D2>&);
+
+ static value_type value();
+ value_type operator()() const;
+ #endif
+ };
+
+A diagnostic will be emitted if __ratio is instantiated with `D == 0`, or if the absolute value of `N` or `D` cannot be represented. [*Note:] These rules ensure that infinite ratios are avoided and that for any negative input, there exists a representable value of its absolute value which is positive. In a two's complement representation, this excludes the most negative value.
+
+The members num and den will be normalized values of the template arguments N and D computed as follows. Let `gcd` denote the greatest common divisor of `N`'s absolute value and of `D`'s absolute value. Then:
+
+* `num` has the value `sign(N)*sign(D)*abs(N)/gcd`.
+
+* `den` has the value `abs(D)/gcd`.
+
+The nested typedef `type` denotes the normalized form of this __ratio type. It should be
+used when the normalized form of the template arguments are required, since the arguments are not necessarily normalized.
+
+Two __ratio classes `__ratio<N1,D1>` and `__ratio<N2,D2>` have the same normalized form if `__ratio<N1,D1>::type` is the same type as `__ratio<N2,D2>::type`
+
+[section:ca Construction and Assignment]
+
+Included only if BOOST_RATIO_EXTENSIONS is defined.
+
+[heading Default Constructor]
+
+ ratio()=default;
+
+[*Effects:] Constructs a __ratio object.
+
+[heading Copy Constructor]
+
+ template <intmax_t N2, intmax_t D2>
+ ratio(const __ratio<N2, D2>& r);
+
+[*Effects:] Constructs a __ratio object.
+
+[*Remarks:] This constructor will not participate in overload resolution unless `r` has the same normalized form as `*this`.
+
+[heading Assignement]
+
+ template <intmax_t N2, intmax_t D2>
+ __ratio& operator=(const __ratio<N2, D2>& r);
+
+[*Effects:] Assigns a __ratio object.
+
+[*Returns:] *this.
+
+[*Remarks:] This operator will not participate in overload resolution unless `r` has the same normalized form as `*this`.
+
+[endsect]
+
+[section:mpl MPL Numeric Metafunctions]
+
+Included only if BOOST_RATIO_EXTENSIONS is defined.
+
+In order to work with [*Boost.MPL] numeric metafunctions as a __Rational_Constant, the following has beed added:
+
+ 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;
+[endsect]
+
+[section:obs Observers]
+
+Included only if BOOST_RATIO_EXTENSIONS is defined.
+
+ static value_type value();
+ value_type operator()() const;
+
+[*Returns:] value_type(num,den);
+
+[endsect]
+
+[endsect]
+
+
+[section:ratio_arithmetic `ratio` Arithmetic]
+
+For each of the class templates in this section, each template parameter refers to a `ratio`. If the implementation is unable to form the indicated __ratio due to overflow, a diagnostic will be issued.
+
+[heading `ratio_add<>`]
+
+ template <class R1, class R2> struct ratio_add {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `__ratio<R1::num * R2::den + R2::num * R1::den, R1::den * R2::den>::type`.
+
+[heading `ratio_subtract<>`]
+
+ template <class R1, class R2> struct ratio_subtract {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `__ratio<R1::num * R2::den - R2::num * R1::den, R1::den * R2::den>::type`.
+
+[heading `ratio_multiply<>`]
+
+ template <class R1, class R2> struct ratio_multiply {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `__ratio<R1::num * R2::num, R1::den * R2::den>::type`.
+
+[heading `ratio_divide<>`]
+
+ template <class R1, class R2> struct ratio_divide {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `__ratio<R1::num * R2::den, R2::num * R1::den>::type`.
+
+[heading `ratio_negate<>`]
+
+This extension of the C++ standard helps in the definition of some [*Boost.MPL] numeric metafunctions.
+
+
+ template <class R> struct ratio_negate {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `__ratio<-R::num, R::den>::type`.
+
+[heading `ratio_abs<>`]
+
+This extension of the C++ standard helps in the definition of some [*Boost.MPL] numeric metafunctions.
+
+ template <class R> struct ratio_abs {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `__ratio<abs_c<intmax_t,R::num>::value, R::den>::type`.
+
+[heading `ratio_sign<>`]
+
+This extension of the C++ standard helps in the definition of some [*Boost.MPL] numeric metafunctions.
+
+ template <class R> struct ratio_sign {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `sign_c<intmax_t,R::num>::type`.
+
+[heading `ratio_gcd<>`]
+
+This extension of the C++ standard helps in the definition of some [*Boost.MPL] numeric metafunctions.
+
+ template <class R1, class R2> struct ratio_gcd {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `ratio<gcd_c<intmax_t, R1::num, R2::num>::value, mpl::lcm_c<intmax_t, R1::den, R2::den>::value>::type`.
+
+[heading `ratio_lcm<>`]
+
+This extension of the C++ standard helps in the definition of some [*Boost.MPL] numeric metafunctions.
+
+ template <class R1, class R2> struct ratio_lcm {
+ typedef [/see below] type;
+ };
+
+The nested typedef `type` is a synonym for `ratio<lcm_c<intmax_t, R1::num, R2::num>::value, gcd_c<intmax_t, R1::den, R2::den>::value>::type`.
+
+[endsect]
+
+[section:ratio_comparison `ratio` Comparison]
+
+[heading `ratio_equal<>`]
+
+ template <class R1, class R2> struct ratio_equal
+ : public boost::integral_constant<bool, [/see below] > {};
+
+If R1::num == R2::num && R1::den == R2::den, ratio_equal derives from true_type, else derives from false_type.
+
+[heading `ratio_not_equal<>`]
+
+ template <class R1, class R2> struct ratio_not_equal
+ : public boost::integral_constant<bool, !ratio_equal<R1, R2>::value> {};
+
+[heading `ratio_less<>`]
+
+ template <class R1, class R2>
+ struct ratio_less
+ : public boost::integral_constant<bool, [/see below] > {};
+
+If R1::num * R2::den < R2::num * R1::den, ratio_less derives from true_type, else derives from false_type.
+
+[heading `ratio_less_equal<>`]
+
+ template <class R1, class R2> struct ratio_less_equal
+ : public boost::integral_constant<bool, !ratio_less<R2, R1>::value> {};
+
+[heading `ratio_greater<>`]
+
+ template <class R1, class R2> struct ratio_greater
+ : public boost::integral_constant<bool, ratio_less<R2, R1>::value> {};
+
+[heading `ratio_greater_equal<>`]
+
+ template <class R1, class R2> struct ratio_greater_equal
+ : public boost::integral_constant<bool, !ratio_less<R1, R2>::value> {};
+
+
+[endsect]
+
+[section:ratio_si_typedefs SI typedefs]
+
+The [@http://en.wikipedia.org/wiki/SI_prefix#List_of_SI_prefixes International System of Units] specifies twenty SI prefixes. __Boost_Ratio defines all except `yocto`, `zepto`, `zetta`, and `yotta`
+
+ // convenience SI typedefs
+ typedef __ratio<1LL, 1000000000000000000LL> atto;
+ typedef __ratio<1LL, 1000000000000000LL> femto;
+ typedef __ratio<1LL, 1000000000000LL> pico;
+ typedef __ratio<1LL, 1000000000LL> nano;
+ typedef __ratio<1LL, 1000000LL> micro;
+ typedef __ratio<1LL, 1000LL> milli;
+ typedef __ratio<1LL, 100LL> centi;
+ typedef __ratio<1LL, 10LL> deci;
+ typedef __ratio< 10LL, 1LL> deca;
+ typedef __ratio< 100LL, 1LL> hecto;
+ typedef __ratio< 1000LL, 1LL> kilo;
+ typedef __ratio< 1000000LL, 1LL> mega;
+ typedef __ratio< 1000000000LL, 1LL> giga;
+ typedef __ratio< 1000000000000LL, 1LL> tera;
+ typedef __ratio< 1000000000000000LL, 1LL> peta;
+ typedef __ratio<1000000000000000000LL, 1LL> exa;
+
+[endsect]
+
+
+[section:limitations Limitations]
+
+The following are limitations of Boost.Ratio relative to the specification in the C++0x draft standard:
+
+* Four of the SI units typedefs -- `yocto`, `zepto`, `zetta`, and `yotta` -- are to be conditionally supported, if the range of `intmax_t` allows, but are not supported by __Boost_Ratio.
+* Ratio values should be of type static `constexpr intmax_t` (see [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3135.html#1122 Ratio values should be constexpr]), but for compiler not supporting `constexpr` today, __Boost_Ratio uses `static const intmax_t` instead.
+* Rational arithmetic should use template aliases (see [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3134.html#921 Rational Arithmetic should use template aliases]), but those are not available in C++03, so inheritance is used instead.
+
+[endsect]
+
+[section:extensions Extensions]
+
+When __BOOST_RATIO_EXTENSIONS is defined __Boost_Ratio provides the following extensions:
+
+* Extends the requirements of the C++0x draft standard by making the copy constructor and copy assignment operator have the same normalized form (see [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3133.html#1281 copy constructor and assignment between ratios having the same normalized form]).
+* More C++ standard like metafunctions applied to ratio types, like __static_abs or __static_negate.
+* An __Boost_Mpl rational constant concept and the associated __Boost_Mpl arithmetic and comparison specializations including __numeric_cast, __plus, __equal_to between others.
+
+[endsect]
+
+[endsect]
+[endsect]
+[section:io Ratio I/O]
+
+[/=======================================================]
+[section:ratio_io_hpp Header `<boost/ratio/ratio_io.hpp>`]
+[/=======================================================]
+
+This header provides `ratio_string<>` which can generate a textual representation of a `ratio<>` in the form of a `std::basic_string<>`. These strings can be useful for I/O.
+
+ namespace boost {
+ template <class Ratio, class CharT>
+ struct ratio_string
+ {
+ static std::basic_string<CharT> short_name();
+ static std::basic_string<CharT> long_name();
+ };
+ }
+
+[endsect]
+[endsect]
+[section:mpl Rational Constant]
+
+[/===========================================]
+[section:rational_constant Rational Constant Concept]
+[/===========================================]
+
+[heading Description]
+
+A __Rational_Constant is a holder class for a compile-time value of a rational type. Every __Rational_Constant is also a nullary Metafunction, returning itself. A rational constant object is implicitly convertible to the corresponding run-time value of the rational type.
+
+[heading Expression requirements]
+
+In the following table and subsequent specifications, r is a model of __Rational_Constant.
+
+[table
+ [[Expression][Type] [Complexity]]
+ [[`r::tag`][`rational_c_tag`] [Constant time]]
+ [[`r::value_type`][A rational type] [Constant time]]
+ [[`r::num_type`][An integral type] [Constant time]]
+ [[`r::den_type`][An integral type] [Constant time]]
+ [[`r::num`][An Integral constant expression] [Constant time]]
+ [[`r::den`][An Integral constant expression] [Constant time]]
+ [[`r::type`][__Rational_Constant] [Constant time]]
+ [[`r::value_type const c=r()`][] [Constant time]]
+]
+
+[heading Expression semantics]
+
+[table
+ [[Expression][Semantics]]
+ [[`r::tag`][r's tag type; r::tag::value is r's conversion rank.]]
+ [[`r::value_type`][A cv-unqualified type of `r()`]]
+ [[`r::num_type`][A cv-unqualified type of `r::num`]]
+ [[`r::den_type`][A cv-unqualified type of `r::den`]]
+ [[`r::num`][The numerator of the rational constant]]
+ [[`r::den`][The denominator of the rational constant]]
+ [[`r::type`][equal_to<n::type,n>::value == true.]]
+ [[`r::value_type const c=r()`][`r::value_type const c=r::value_type(r::num,r::den)`]]
+]
+
+[heading Models]
+
+* __ratio<>
+
+[endsect]
+
+[/===========================================]
+[section:rational_constant_hpp Header `<boost/ratio/mpl/rational_constant.hpp>`]
+[/===========================================]
+
+This header includes all the rational constant related header files
+
+ #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>
+
+
+[endsect] [/section:rational_constant_hpp Header `<boost/ratio/rational_constant.hpp>`]
+
+[/===========================================]
+[section:mpl_rational_c_tag_hpp Header `<boost/ratio/mpl/rational_c_tag.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+
+ struct rational_c_tag : int_<10> {};
+
+ }
+ }
+
+[endsect] [/section:mpl_rational_c_tag_hpp Header `<boost/ratio/mpl/rational_c_tag.hpp>`]
+
+[/===========================================]
+[section:mpl_numeric_cast_hpp Header `<boost/ratio/mpl/numeric_cast.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+
+ template<> struct numeric_cast< integral_c_tag,rational_c_tag >;
+
+ }
+ }
+
+[section:numeric_cast `mpl::numeric_cast<>` Specialization]
+
+A Integral Constant is seen as a ratio with numerator the Integral Constant value and denominator 1.
+
+ template<> struct numeric_cast< integral_c_tag,rational_c_tag >
+ {
+ template< typename N > struct apply
+ : ratio< N::value, 1 >
+ {
+ };
+ };
+
+[endsect] [/section:numeric_cast `mpl::numeric_cast<>` Specialization]
+
+[endsect] [/section:mpl_numeric_cast_hpp Header `<boost/ratio/mpl/numeric_cast.hpp>`]
+
+[/===========================================]
+[section:mpl_arithmetic_hpp Header `<boost/ratio/mpl/arithmetic.hpp>`]
+[/===========================================]
+
+This header includes all the rational constant arithmetic MPL specializations.
+
+ #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>
+
+
+[endsect] [/section:mpl_arithmetic_hpp Header `<boost/ratio/mpl/arithmetic.hpp>`]
+
+[/===========================================]
+[section:mpl_plus_hpp Header `<boost/ratio/mpl/plus.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct plus_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:plus_impl `mpl::plus_impl<>` Specialization]
+
+The specialization relays on the __ratio_add template class.
+
+ template<>
+ struct plus_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : __ratio_add<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:plus_impl `mpl::plus_impl<>` Specialization]
+[endsect] [/section:mpl_plus_hpp Header `<boost/ratio/mpl/plus.hpp>`]
+
+[/===========================================]
+[section:mpl_minus_hpp Header `<boost/ratio/mpl/minus.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct minus_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:minus_impl `mpl::minus_impl<>` Specialization]
+
+The specialization relays on the __ratio_subtract template class.
+
+ template<>
+ struct plus_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : __ratio_subtract<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:minus_impl `mpl::minus_impl<>` Specialization]
+[endsect] [/section:mpl_minus_hpp Header `<boost/ratio/mpl/minus.hpp>`]
+
+[/===========================================]
+[section:mpl_times_hpp Header `<boost/ratio/mpl/times.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct times_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:times_impl `mpl::times_impl<>` Specialization]
+
+The specialization relays on the __ratio_multiply template class.
+
+ template<>
+ struct times_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : __ratio_multiply<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:times_impl `mpl::times_impl<>` Specialization]
+[endsect] [/section:mpl_times_hpp Header `<boost/ratio/mpl/times.hpp>`]
+
+[/===========================================]
+[section:mpl_divides_hpp Header `<boost/ratio/mpl/divides.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct divides_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:divides_impl `mpl::divides_impl<>` Specialization]
+
+The specialization relays on the __ratio_divide template class.
+
+ template<>
+ struct divides_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : __ratio_divide<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:divides_impl `mpl::divides_impl<>` Specialization]
+[endsect] [/section:mpl_divides_hpp Header `<boost/ratio/mpl/divides.hpp>`]
+
+[/===========================================]
+[section:mpl_gcd_hpp Header `<boost/ratio/mpl/gcd.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct gcd_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:gcd_impl `mpl::gcd_impl<>` Specialization]
+
+The specialization relays on the __ratio_gcd template class.
+
+ template<>
+ struct gcd_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : __ratio_gcd<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:gcd_impl `mpl::gcd_impl<>` Specialization]
+[endsect] [/section:mpl_gcd_hpp Header `<boost/ratio/mpl/gcd.hpp>`]
+
+[/===========================================]
+[section:mpl_lcm_hpp Header `<boost/ratio/mpl/lcm.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct lcm_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:lcm_impl `mpl::lcm_impl<>` Specialization]
+
+The specialization relays on the __ratio_lcm template class.
+
+ template<>
+ struct lcm_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : __ratio_lcm<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:lcm_impl `mpl::lcm_impl<>` Specialization]
+[endsect] [/section:mpl_lcm_hpp Header `<boost/ratio/mpl/lcm.hpp>`]
+
+[/===========================================]
+[section:mpl_negate_hpp Header `<boost/ratio/mpl/negate.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct negate_impl< rational_c_tag >;
+ }
+ }
+
+[section:negate_impl `mpl::negate_impl<>` Specialization]
+
+The specialization relays on the __ratio_negate template class.
+
+ template<>
+ struct negate_impl< rational_c_tag >
+ {
+ template< typename R > struct apply
+ : __ratio_negate<R>
+ {
+ };
+ };
+
+[endsect] [/section:negate_impl `mpl::negate_impl<>` Specialization]
+[endsect] [/section:mpl_negate_hpp Header `<boost/ratio/mpl/negate.hpp>`]
+
+[/===========================================]
+[section:mpl_abs_hpp Header `<boost/ratio/mpl/abs.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct abs_impl< rational_c_tag >;
+ }
+ }
+
+[section:abs_impl `mpl::abs_impl<>` Specialization]
+
+The specialization relays on the __ratio_abs template class.
+
+ template<>
+ struct abs_impl< rational_c_tag >
+ {
+ template< typename R > struct apply
+ : __ratio_abs<R>
+ {
+ };
+ };
+
+[endsect] [/section:abs_impl `mpl::abs_impl<>` Specialization]
+[endsect] [/section:mpl_abs_hpp Header `<boost/ratio/mpl/abs.hpp>`]
+
+[/===========================================]
+[section:mpl_sign_hpp Header `<boost/ratio/mpl/sign.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct sign_impl< rational_c_tag >;
+ }
+ }
+
+[section:sign_impl `mpl::sign_impl<>` Specialization]
+
+The specialization relays on the __ratio_sign template class.
+
+ template<>
+ struct sign_impl< rational_c_tag >
+ {
+ template< typename R > struct apply
+ : __ratio_sign<R>
+ {
+ };
+ };
+
+[endsect] [/section:sign_impl `mpl::sign_impl<>` Specialization]
+[endsect] [/section:mpl_sign_hpp Header `<boost/ratio/mpl/sign.hpp>`]
+
+[/===========================================]
+[section:mpl_comparison_hpp Header `<boost/ratio/mpl/comparison.hpp>`]
+[/===========================================]
+
+This header includes all the rational constant comparison MPL specializations.
+
+ #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>
+
+
+[endsect] [/section:mpl_comparison_hpp Header `<boost/ratio/mpl/mpl_comparison_hpp.hpp>`]
+
+[/===========================================]
+[section:mpl_equal_to_hpp Header `<boost/ratio/mpl/equal_to.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct equal_to_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:equal_to `mpl::equal_to_impl<>` Specialization]
+
+The specialization relays on the __ratio_equal template class.
+
+ template<>
+ struct equal_to_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : __ratio_equal<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:equal_to `mpl::equal_to_impl<>` Specialization]
+[endsect] [/section:mpl_equal_to_hpp Header `<boost/ratio/mpl/equal_to.hpp>`]
+
+[/===========================================]
+[section:mpl_not_equal_to_hpp Header `<boost/ratio/mpl/not_equal_to.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct not_equal_to_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:not_equal_to `mpl::not_equal_to_impl<>` Specialization]
+
+The specialization relays on the __ratio_not_equal template class.
+
+ template<>
+ struct not_equal_to_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : __ratio_not_equal<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:not_equal_to `mpl::not_equal_to_impl<>` Specialization]
+[endsect] [/section:mpl_not_equal_to_hpp Header `<boost/ratio/mpl/not_equal_to.hpp>`]
+
+[/===========================================]
+[section:mpl_less_hpp Header `<boost/ratio/mpl/less.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct less_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:less `mpl::less_impl<>` Specialization]
+
+The specialization relays on the __ratio_less template class.
+
+ template<>
+ struct less_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : ratio_less<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:less `mpl::less_impl<>` Specialization]
+[endsect] [/section:mpl_less_hpp Header `<boost/ratio/mpl/less.hpp>`]
+
+[/===========================================]
+[section:mpl_less_equal_hpp Header `<boost/ratio/mpl/less_equal.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct less_equal_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:less_equal `mpl::less_equal_impl<>` Specialization]
+
+The specialization relays on the __ratio_less_equal template class.
+
+ template<>
+ struct less_equal_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : ratio_less_equal<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:less_equal `mpl::less_equal_impl<>` Specialization]
+[endsect] [/section:mpl_less_equal_hpp Header `<boost/ratio/mpl/less_equal.hpp>`]
+
+[/===========================================]
+[section:mpl_greater_hpp Header `<boost/ratio/mpl/greater.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct greater_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:greater `mpl::greater_impl<>` Specialization]
+
+The specialization relays on the __ratio_greater template class.
+
+ template<>
+ struct greater_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : ratio_greater<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:greater `mpl::greater_impl<>` Specialization]
+[endsect] [/section:mpl_greater_hpp Header `<boost/ratio/mpl/greater.hpp>`]
+
+
+[/===========================================]
+[section:mpl_greater_equal_hpp Header `<boost/ratio/mpl/greater_equal.hpp>`]
+[/===========================================]
+
+ namespace boost {
+ namespace mpl {
+ template<>
+ struct greater_equal_impl< rational_c_tag,rational_c_tag >;
+ }
+ }
+
+[section:greater_equal `mpl::greater_equal_impl<>` Specialization]
+
+The specialization relays on the __ratio_greater_equal template class.
+
+ template<>
+ struct greater_equal_impl< rational_c_tag,rational_c_tag >
+ {
+ template< typename R1, typename R2 > struct apply
+ : ratio_greater_equal<R1, R2>
+ {
+ };
+ };
+
+[endsect] [/section:greater_equal `mpl::greater_equal_impl<>` Specialization]
+[endsect] [/section:mpl_greater_equal_hpp Header `<boost/ratio/mpl/greater_equal.hpp>`]
+
+
+[endsect]
+[endsect]
+
+
+[/=================]
+[section Appendices]
+[/=================]
+[/==================================]
+[section:history Appendix A: History]
+[/==================================]
+
+[section [*Version 1.0.1, Jan 8, 2011] ]
+
+* Added MPL Rational Constant and the associated numeric metafunction specializations.
+
+[endsect]
+
+
+[section [*Version 1.0.0, Jan 2, 2011] ]
+
+* Moved ratio to trunk.
+* Documentation revision.
+
+[endsect]
+
+[section [*Version 0.2.1, September 27, 2010] ]
+[*Fixes:]
+
+* Removal of LLVM adapted files due to incompatible License issue.
+
+[endsect]
+
+[section [*Version 0.2.0, September 22, 2010] ]
+[*Features:]
+
+* Added ratio_string traits.
+
+[*Fixes:]
+
+* ratio_less overflow avoided following the algorithm from libc++.
+
+[*Test:]
+
+* A more complete test has been included adapted from the test of from libc++/ratio.
+
+[endsect]
+
+[section [*Version 0.1.0, September 10, 2010] ]
+[*Features:]
+
+* Ratio has been extracted from Boost.Chrono.
+
+[endsect]
+
+[endsect] [/section:history Appendix A: History]
+
+[/======================================]
+[section:rationale Appendix B: Rationale]
+
+[heading Why ratio needs CopyConstruction and Assignment from ratios having the same normalized form]
+
+Current [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3000.pdf [*N3000]] doesn't allows to copy-construct or assign ratio instances of ratio classes having the same normalized form.
+
+This simple example
+
+ __ratio<1,3> r1;
+ __ratio<3,9> r2;
+ r1 = r2; // (1)
+
+fails to compile in (1). Other example
+
+ __ratio<1,3> r1;
+ __ratio_subtract<__ratio<2,3>,__ratio<1,3> > r2=r1; // (2)
+
+The type of `__ratio_subtract<__ratio<2,3>,__ratio<1,3> >` could be `__ratio<3,9>` so the compilation could fail in (2). It could also be __ratio<1,3> and the compilation succeeds.
+
+[heading Why ratio needs the nested normalizer typedef type]
+
+The current resolution of issue LWG 1281 acknowledges the need for a nested type typedef, so Boost.Ratio is tracking the likely final version of std::ratio.
+
+[endsect] [/section:rationale Appendix B: Rationale]
+
+
+[/======================================================]
+[section:implementation Appendix C: Implementation Notes]
+
+[heading How does Boost.Ratio try to avoid compile-time rational arithmetic overflow?]
+
+When the result is representable, but a simple application of arithmetic rules would result in overflow, e.g. `ratio_multiply<ratio<INTMAX_MAX,2>,ratio<2,INTMAX_MAX>>` can be reduced to `ratio<1,1>`, but the direct result of `ratio<INTMAX_MAX*2,INTMAX_MAX*2>` would result in overflow.
+
+Boost.Ratio implements some simplifications in order to reduce the possibility of overflow. The general ideas are:
+
+* The `num` and `den` `ratio<>` fields are normalized.
+* Use the gcd of some of the possible products that can overflow, and simplify before doing the product.
+* Use some equivalences relations that avoid addition or subtraction that can overflow or underflow.
+
+The following subsections cover each case in more detail.
+
+[*ratio_add]
+
+In
+
+ (n1/d1)+(n2/d2)=(n1*d2+n2*d1)/(d1*d2)
+
+either n1*d2+n2*d1 or d1*d2 can overflow.
+
+ ( (n1 * d2) + (n2 * d1) )
+ --------------------------
+ (d1 * d2)
+
+Dividing by gcd(d1,d2) on both num and den
+
+ ( (n1 * (d2/gcd(d1,d2))) + (n2 * (d1/gcd(d1,d2))) )
+ ----------------------------------------------------
+ ((d1 * d2) / gcd(d1,d2))
+
+
+Multipliying and diving by gcd(n1,n2) in numerator
+
+ ( ((gcd(n1,n2)*(n1/gcd(n1,n2))) * (d2/gcd(d1,d2))) +
+ ((gcd(n1,n2)*(n2/gcd(n1,n2))) * (d1/gcd(d1,d2)))
+ )
+ --------------------------------------------------
+ ( (d1 * d2) / gcd(d1,d2) )
+
+Factorizing gcd(n1,n2)
+
+ ( gcd(n1,n2) *
+ ( ((n1/gcd(n1,n2)) * (d2/gcd(d1,d2))) + ((n2/gcd(n1,n2)) * (d1/gcd(d1,d2))) )
+ )
+ -------------------------------------------------------------------------------
+ ( (d1 * d2) / gcd(d1,d2) )
+
+Regrouping
+
+ ( gcd(n1,n2) *
+ ( ((n1/gcd(n1,n2)) * (d2/gcd(d1,d2))) + ((n2/gcd(n1,n2)) * (d1/gcd(d1,d2))) )
+ )
+ -------------------------------------------------------------------------------
+ ( (d1 / gcd(d1,d2)) * d2 )
+
+Dividing by (d1 / gcd(d1,d2))
+
+ ( ( gcd(n1,n2) / (d1 / gcd(d1,d2)) ) *
+ ( ((n1/gcd(n1,n2)) * (d2/gcd(d1,d2))) + ((n2/gcd(n1,n2)) * (d1/gcd(d1,d2))) )
+ )
+ -------------------------------------------------------------------------------
+ d2
+
+
+Dividing by d2
+
+ ( gcd(n1,n2) / (d1 / gcd(d1,d2)) ) *
+ ( ((n1/gcd(n1,n2)) * (d2/gcd(d1,d2))) + ((n2/gcd(n1,n2)) * (d1/gcd(d1,d2))) / d2 )
+
+This expression correspond to the multiply of two ratios that have less risk of overflow as the initial numerators and denominators appear now in most of the cases divided by a gcd.
+
+
+For ratio_subtract the reasoning is the same.
+
+[*ratio_multiply]
+
+In
+
+ (n1/d1)*(n2/d2)=((n1*n2)/(d1*d2))
+
+either n1*n2 or d1*d2 can overflow.
+
+Dividing by gcc(n1,d2) numerator and denominator
+
+ (((n1/gcc(n1,d2))*n2)
+ ---------------------
+ (d1*(d2/gcc(n1,d2))))
+
+Dividing by gcc(n2,d1)
+
+ ((n1/gcc(n1,d2))*(n2/gcc(n2,d1)))
+ ---------------------------------
+ ((d1/gcc(n2,d1))*(d2/gcc(n1,d2)))
+
+And now all the initial numerator and denominators have been reduced, avoiding the overflow.
+
+For ratio_divide the reasoning is similar.
+
+[*ratio_less]
+
+In order to evaluate
+
+ (n1/d1)<(n2/d2)
+
+without moving to floating-point numbers, two techniques are used:
+
+* First compare the sign of the numerators.
+
+If sign(n1) < sign(n2) the result is true.
+
+If sign(n1) == sign(n2) the result depends on the following after making the numerators positive
+
+* When the sign is equal the technique used is to work with integer division and modulo when the signs are equal.
+
+Let call Qi the integer division of ni and di, and Mi the modulo of ni and di.
+
+ ni = Qi * di + Mi and Mi < di
+
+Form
+
+ ((n1*d2)<(d1*n2))
+
+we get
+
+ (((Q1 * d1 + M1)*d2)<(d1*((Q2 * d2 + M2))))
+
+Developing
+
+ ((Q1 * d1 * d2)+ (M1*d2))<((d1 * Q2 * d2) + (d1*M2))
+
+Dividing by d1*d2
+
+ Q1 + (M1/d1) < Q2 + (M2/d2)
+
+If Q1=Q2 the result depends on
+
+ (M1/d1) < (M2/d2)
+
+If M1==0==M2 the result is false
+
+If M1=0 M2!=0 the result is true
+
+If M1!=0 M2==0 the result is false
+
+If M1!=0 M2!=0 the result depends on
+
+ (d2/M2) < (d1/M1)
+
+If Q1!=Q2, the result of
+
+ Q1 + (M1/d1) < Q2 + (M2/d2)
+
+depends only on Q1 and Q2 as Qi are integers and (Mi/di) <1 because Mi<di.
+
+if Q1>Q2, Q1==Q2+k, k>=1
+
+ Q2+k + (M1/d1) < Q2 + (M2/d2)
+ k + (M1/d1) < (M2/d2)
+ k < (M2/d2) - (M1/d1)
+
+but the difference between two numbers between 0 and 1 can not be greater than 1, so the result is false.
+
+if Q2>Q1, Q2==Q1+k, k>=1
+
+ Q1 + (M1/d1) < Q1+k + (M2/d2)
+ (M1/d1) < k + (M2/d2)
+ (M1/d1) - (M2/d2) < k
+
+which is always true, so the result is true.
+
+The following table recapitulates this analisys
+
+[table
+ [[ratio<n1,d1>][ratio<n2,d2>] [Q1] [Q2] [M1] [M2] [Result]]
+ [[ratio<n1,d1>][ratio<n2,d2>] [Q1] [Q2] [!=0] [!=0] [Q1 < Q2]]
+ [[ratio<n1,d1>][ratio<n2,d2>] [Q] [Q] [0] [0] [false]]
+ [[ratio<n1,d1>][ratio<n2,d2>] [Q] [Q] [0] [!=0] [true]]
+ [[ratio<n1,d1>][ratio<n2,d2>] [Q] [Q] [!=0] [0] [false]]
+ [[ratio<n1,d1>][ratio<n2,d2>] [Q] [Q] [!=0] [!=0] [ratio_less<ratio<d2,M2>, ratio<d1/M1>>]]
+]
+
+[endsect] [/section:implementation Appendix C: Implementation Notes]
+
+[/======================================================]
+[section:faq Appendix D: FAQ]
+[/======================================================]
+
+[endsect] [/section:faq Appendix D: FAQ]
+
+
+[/====================================================]
+[section:acknowledgements Appendix E: Acknowledgements]
+[/====================================================]
+
+The library code was derived 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 by Beman Dawes to conform to Boost conventions.
+
+`time2_demo` contained this comment:
+
+Much thanks to Andrei Alexandrescu, Walter Brown, Peter Dimov, Jeff Garland, Terry Golubiewski, Daniel Krugler, Anthony Williams.
+
+Howard Hinnant, who is the real author of the library, has provided valuable feedback and suggestions during the development of the library. In particular, The ratio_io.hpp source has been adapted from the experimental header `<ratio_io>` from Howard Hinnant.
+
+The acceptance review of Boost.Ratio took place between October 2nd and 11th 2010. Many thanks to Anthony Williams, the review manager, and to all the reviewers: Bruno Santos, Joel Falcou, Robert Stewart, Roland Bock, Tom Tan and Paul A. Bristol.
+
+Thanks to Andrew Chinoff and Paul A. Bristol for his help polishing the documentation.
+
+[endsect] [/section:acknowledgements Appendix E: Acknowledgements]
+
+[/====================================================]
+[section:tests Appendix F: Tests]
+[/====================================================]
+
+In order to test you need to run
+
+ bjam libs/ratio/test
+
+You can also run a specific suite of test by doing
+
+ cd libs/chrono/test
+ bjam ratio
+
+
+[section `ratio`]
+[table
+ [[Name] [kind] [Description] [Result] [Ticket]]
+ [[typedefs.pass] [run] [check the num/den are correct for the predefined typedefs] [Pass] [#]]
+ [[ratio.pass] [run] [check the num/den are correctly simplified] [Pass] [#]]
+ [[ratio1.fail] [compile-fails] [The template argument D shall not be zero] [Pass] [#]]
+ [[ratio2.fail] [compile-fails] [the absolute values of the template arguments N and D shall be representable by type intmax_t] [Pass] [#]]
+ [[ratio3.fail] [compile-fails] [the absolute values of the template arguments N and D shall be representable by type intmax_t] [Pass] [#]]
+]
+[endsect]
+
+[section `comparison`]
+[table
+ [[Name] [kind] [Description] [Result] [Ticket]]
+ [[ratio_equal.pass] [run] [check ratio_equal metafunction class] [Pass] [#]]
+ [[ratio_not_equal.pass] [run] [check ratio_not_equal metafunction class] [Pass] [#]]
+ [[ratio_less.pass] [run] [check ratio_less metafunction class] [Pass] [#]]
+ [[ratio_less_equal.pass] [run] [check ratio_less_equal metafunction class] [Pass] [#]]
+ [[ratio_greater.pass] [run] [check ratio_greater metafunction class] [Pass] [#]]
+ [[ratio_greater_equal.pass] [run] [check ratio_greater_equal metafunction class] [Pass] [#]]
+]
+[endsect]
+
+[section `arithmetic`]
+[table
+ [[Name] [kind] [Description] [Result] [Ticket]]
+ [[ratio_add.pass] [run] [check ratio_add metafunction class] [Pass] [#]]
+ [[ratio_subtract.pass] [run] [check ratio_subtract metafunction class] [Pass] [#]]
+ [[ratio_multiply.pass] [run] [check ratio_multiply metafunction class] [Pass] [#]]
+ [[ratio_divide.pass] [run] [check ratio_divide metafunction class] [Pass] [#]]
+ [[ratio_add.fail] [compile-fails] [check ratio_add overflow metafunction class] [Pass] [#]]
+ [[ratio_subtract.fail] [compile-fails] [check ratio_subtract underflow metafunction class] [Pass] [#]]
+ [[ratio_multiply.fail] [compile-fails] [check ratio_multiply overflow metafunction class] [Pass] [#]]
+ [[ratio_divide.fail] [compile-fails] [check ratio_divide overflow metafunction class] [Pass] [#]]
+]
+[endsect]
+
+[endsect] [/section:tests Appendix F: Tests]
+
+[/=====================================]
+[section:tickets Appendix G: Tickets]
+[/=====================================]
+
+[table
+ [[Ticket] [Description] [Resolution] [State]]
+ [[1] [result of metafunctions ratio_multiply and ratio_divide were not normalized ratios.] [Use of the nested ratio typedef type on ratio arithmetic operations.] [Closed]]
+ [[2] [INTMAX_C is not always defined.] [Replace INTMAX_C by BOOST_INTMAX_C until boost/cstdint.hpp ensures INTMAX_C is always defined.] [Closed]]
+
+ [[3] [MSVC reports a warning instead of an error when there is an integral constant overflow.] [manage with MSVC reporting a warning instead of an error when there is an integral constant overflow.] [Closed]]
+ [[4] [ration_less overflow on cases where it can be avoided.] [Change the algorithm as implemented in libc++.] [Closed]]
+ [/[#] [XXXX] [XXXX] [Closed]]
+]
+
+[endsect] [/section:tickets Appendix G: Tickets]
+
+
+[/=====================================]
+[section:todo Appendix H: Future Plans]
+[/=====================================]
+
+[heading For later releases]
+
+* Use template aliases on compiler providing it.
+* Implement [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3135.html#3135 multiple arguments] ratio arithmetic.
+
+[endsect] [/section:todo Appendix H: Future Plans]
+
+
+[endsect] [/section Appendices]
+

Added: branches/release/libs/ratio/example/config.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/config.hpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,123 @@
+// boost/chrono/config.hpp -------------------------------------------------//
+
+// Copyright Beman Dawes 2003, 2006, 2008
+// Copyright 2009 Vicente J. Botet Escriba
+
+// 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/chrono for documentation.
+
+#ifndef BOOST_EX_CHRONO_CONFIG_HPP
+#define BOOST_EX_CHRONO_CONFIG_HPP
+
+#include <boost/config.hpp>
+
+// BOOST_EX_CHRONO_POSIX_API, BOOST_EX_CHRONO_MAC_API, or BOOST_EX_CHRONO_WINDOWS_API
+// can be defined by the user to specify which API should be used
+
+#if defined(BOOST_EX_CHRONO_WINDOWS_API)
+# warning Boost.Chrono will use the Windows API
+#elif defined(BOOST_EX_CHRONO_MAC_API)
+# warning Boost.Chrono will use the Mac API
+#elif defined(BOOST_EX_CHRONO_POSIX_API)
+# warning Boost.Chrono will use the POSIX API
+#endif
+
+# if defined( BOOST_EX_CHRONO_WINDOWS_API ) && defined( BOOST_EX_CHRONO_POSIX_API )
+# error both BOOST_EX_CHRONO_WINDOWS_API and BOOST_EX_CHRONO_POSIX_API are defined
+# elif defined( BOOST_EX_CHRONO_WINDOWS_API ) && defined( BOOST_EX_CHRONO_MAC_API )
+# error both BOOST_EX_CHRONO_WINDOWS_API and BOOST_EX_CHRONO_MAC_API are defined
+# elif defined( BOOST_EX_CHRONO_MAC_API ) && defined( BOOST_EX_CHRONO_POSIX_API )
+# error both BOOST_EX_CHRONO_MAC_API and BOOST_EX_CHRONO_POSIX_API are defined
+# elif !defined( BOOST_EX_CHRONO_WINDOWS_API ) && !defined( BOOST_EX_CHRONO_MAC_API ) && !defined( BOOST_EX_CHRONO_POSIX_API )
+# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
+# define BOOST_EX_CHRONO_WINDOWS_API
+# define BOOST_EX_CHRONO_HAS_CLOCK_MONOTONIC
+# define BOOST_EX_CHRONO_HAS_THREAD_CLOCK
+# define BOOST_EX_CHRONO_THREAD_CLOCK_IS_MONOTONIC true
+# elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
+# define BOOST_EX_CHRONO_MAC_API
+# define BOOST_EX_CHRONO_HAS_CLOCK_MONOTONIC
+# define BOOST_EX_CHRONO_THREAD_CLOCK_IS_MONOTONIC true
+# else
+# define BOOST_EX_CHRONO_POSIX_API
+# endif
+# endif
+
+# if defined( BOOST_EX_CHRONO_POSIX_API )
+# include <time.h> //to check for CLOCK_REALTIME and CLOCK_MONOTONIC and _POSIX_THREAD_CPUTIME
+# if defined(CLOCK_REALTIME)
+# if defined(CLOCK_MONOTONIC)
+# define BOOST_EX_CHRONO_HAS_CLOCK_MONOTONIC
+# endif
+# else
+# error <time.h> does not supply CLOCK_REALTIME
+# endif
+# if defined(_POSIX_THREAD_CPUTIME)
+# define BOOST_EX_CHRONO_HAS_THREAD_CLOCK
+# define BOOST_EX_CHRONO_THREAD_CLOCK_IS_MONOTONIC true
+# endif
+# endif
+
+
+
+// enable dynamic linking on Windows ---------------------------------------//
+
+//# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_EX_CHRONO_DYN_LINK)) && defined(__BORLANDC__) && defined(__WIN32__)
+//# error Dynamic linking Boost.System does not work for Borland; use static linking instead
+//# endif
+
+#ifdef BOOST_HAS_DECLSPEC // defined by boost.config
+// we need to import/export our code only if the user has specifically
+// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
+// libraries to be dynamically linked, or BOOST_EX_CHRONO_DYN_LINK
+// if they want just this one to be dynamically liked:
+#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_EX_CHRONO_DYN_LINK)
+// export if this is our own source, otherwise import:
+#ifdef BOOST_EX_CHRONO_SOURCE
+# define BOOST_EX_CHRONO_DECL __declspec(dllexport)
+#else
+# define BOOST_EX_CHRONO_DECL __declspec(dllimport)
+#endif // BOOST_EX_CHRONO_SOURCE
+#endif // DYN_LINK
+#endif // BOOST_HAS_DECLSPEC
+//
+// if BOOST_EX_CHRONO_DECL isn't defined yet define it now:
+#ifndef BOOST_EX_CHRONO_DECL
+#define BOOST_EX_CHRONO_DECL
+#endif
+
+// define constexpr related macros ------------------------------//
+
+//~ #include <boost/config.hpp>
+#if defined(BOOST_NO_CONSTEXPR)
+#define BOOST_EX_CHRONO_CONSTEXPR
+#define BOOST_EX_CHRONO_CONST_REF const&
+#else
+#define BOOST_EX_CHRONO_CONSTEXPR constexpr
+#define BOOST_EX_CHRONO_CONST_REF
+#endif
+
+// enable automatic library variant selection ------------------------------//
+
+#if !defined(BOOST_EX_CHRONO_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_EX_CHRONO_NO_LIB)
+//
+// Set the name of our library; this will get undef'ed by auto_link.hpp
+// once it's done with it:
+//
+#define BOOST_LIB_NAME boost_chrono
+//
+// If we're importing code from a dll, then tell auto_link.hpp about it:
+//
+#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_EX_CHRONO_DYN_LINK)
+# define BOOST_DYN_LINK
+#endif
+//
+// And include the header that does the work:
+//
+#include <boost/config/auto_link.hpp>
+#endif // auto-linking disabled
+
+#endif // BOOST_EX_CHRONO_CONFIG_HPP
+

Added: branches/release/libs/ratio/example/display_ex.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/display_ex.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,39 @@
+// io_ex2.cpp ----------------------------------------------------------//
+
+// Copyright 2010 Howard Hinnant
+// Copyright 2010 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 adapted by Vicente J. Botet Escriba from Hinnant's html documentation.
+Many thanks to Howard for making his code available under the Boost license.
+*/
+
+#include <iostream>
+#include <boost/ratio/ratio_io.hpp>
+
+int main()
+{
+ using namespace std;
+ using namespace boost;
+
+ cout << "ratio_string<deca, char>::long_name() = "
+ << ratio_string<boost::deca, char>::long_name() << '\n';
+ cout << "ratio_string<deca, char>::short_name() = "
+ << ratio_string<boost::deca, char>::short_name() << '\n';
+
+ cout << "ratio_string<giga, char>::long_name() = "
+ << ratio_string<boost::giga, char>::long_name() << '\n';
+ cout << "ratio_string<giga, char>::short_name() = "
+ << ratio_string<boost::giga, char>::short_name() << '\n';
+
+ cout << "ratio_string<ratio<4, 6>, char>::long_name() = "
+ << ratio_string<boost::ratio<4, 6>, char>::long_name() << '\n';
+ cout << "ratio_string<ratio<4, 6>, char>::short_name() = "
+ << ratio_string<boost::ratio<4, 6>, char>::short_name() << '\n';
+
+ return 0;
+}
+

Added: branches/release/libs/ratio/example/duration.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/duration.hpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,798 @@
+// duration.hpp --------------------------------------------------------------//
+
+// Copyright 2008 Howard Hinnant
+// Copyright 2008 Beman Dawes
+// Copyright 2009-2010 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.9 Time utilities [time] of the C++ committee's 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.
+*/
+
+
+#ifndef BOOST_EX_CHRONO_DURATION_HPP
+#define BOOST_EX_CHRONO_DURATION_HPP
+
+#include "config.hpp"
+#include "static_assert.hpp"
+
+//~ #include <iostream>
+
+#include <climits>
+#include <limits>
+
+
+#include <boost/mpl/logical.hpp>
+#include <boost/ratio/ratio.hpp>
+#include <boost/type_traits/common_type.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+#include <boost/type_traits/is_floating_point.hpp>
+#include <boost/type_traits/is_unsigned.hpp>
+
+#include <boost/cstdint.hpp>
+#if (defined(BOOST_MSVC) && (BOOST_MSVC == 1500)) || defined(__IBMCPP__)
+#else
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/detail/workaround.hpp>
+#include <boost/integer_traits.hpp>
+
+#if !defined(BOOST_NO_STATIC_ASSERT) || !defined(BOOST_EX_CHRONO_USES_MPL_ASSERT)
+#define BOOST_EX_CHRONO_A_DURATION_REPRESENTATION_CAN_NOT_BE_A_DURATION "A duration representation can not be a duration"
+#define BOOST_EX_CHRONO_SECOND_TEMPLATE_PARAMETER_OF_DURATION_MUST_BE_A_STD_RATIO "Second template parameter of duration must be a boost::ratio"
+#define BOOST_EX_CHRONO_DURATION_PERIOD_MUST_BE_POSITIVE "duration period must be positive"
+#define BOOST_EX_CHRONO_SECOND_TEMPLATE_PARAMETER_OF_TIME_POINT_MUST_BE_A_BOOST_EX_CHRONO_DURATION "Second template parameter of time_point must be a boost_ex::chrono::duration"
+#endif
+
+
+//----------------------------------------------------------------------------//
+// //
+// 20.9 Time utilities [time] //
+// synopsis //
+// //
+//----------------------------------------------------------------------------//
+
+namespace boost_ex {
+ using boost::ratio;
+
+namespace chrono {
+
+ template <class Rep, class Period = ratio<1> >
+ class duration;
+
+ namespace detail
+ {
+ template <class T>
+ struct is_duration
+ : boost::false_type {};
+
+ template <class Rep, class Period>
+ struct is_duration<duration<Rep, Period> >
+ : boost::true_type {};
+ //template <class T>
+ // struct is_duration
+ // : is_duration<typename boost::remove_cv<T>::type> {};
+
+ template <class Duration, class Rep, bool = is_duration<Rep>::value>
+ struct duration_divide_result
+ {
+ };
+
+ template <class Duration, class Rep2,
+ bool = (
+ (boost::is_convertible<typename Duration::rep,
+ typename boost::common_type<typename Duration::rep, Rep2>::type>::value)
+ && (boost::is_convertible<Rep2,
+ typename boost::common_type<typename Duration::rep, Rep2>::type>::value)
+ )
+ >
+ struct duration_divide_imp
+ {
+ };
+
+ template <class Rep1, class Period, class Rep2>
+ struct duration_divide_imp<duration<Rep1, Period>, Rep2, true>
+ {
+ typedef duration<typename boost::common_type<Rep1, Rep2>::type, Period> type;
+ };
+
+ template <class Rep1, class Period, class Rep2>
+ struct duration_divide_result<duration<Rep1, Period>, Rep2, false>
+ : duration_divide_imp<duration<Rep1, Period>, Rep2>
+ {
+ };
+
+///
+ template <class Rep, class Duration, bool = is_duration<Rep>::value>
+ struct duration_divide_result2
+ {
+ };
+
+ template <class Rep, class Duration,
+ bool = (
+ (boost::is_convertible<typename Duration::rep,
+ typename boost::common_type<typename Duration::rep, Rep>::type>::value)
+ && (boost::is_convertible<Rep,
+ typename boost::common_type<typename Duration::rep, Rep>::type>::value)
+ )
+ >
+ struct duration_divide_imp2
+ {
+ };
+
+ template <class Rep1, class Rep2, class Period >
+ struct duration_divide_imp2<Rep1, duration<Rep2, Period>, true>
+ {
+ //typedef typename boost::common_type<Rep1, Rep2>::type type;
+ typedef double type;
+ };
+
+ template <class Rep1, class Rep2, class Period >
+ struct duration_divide_result2<Rep1, duration<Rep2, Period>, false>
+ : duration_divide_imp2<Rep1, duration<Rep2, Period> >
+ {
+ };
+
+///
+ template <class Duration, class Rep, bool = is_duration<Rep>::value>
+ struct duration_modulo_result
+ {
+ };
+
+ template <class Duration, class Rep2,
+ bool = (
+ //boost::is_convertible<typename Duration::rep,
+ //typename boost::common_type<typename Duration::rep, Rep2>::type>::value
+ //&&
+ boost::is_convertible<Rep2,
+ typename boost::common_type<typename Duration::rep, Rep2>::type>::value
+ )
+ >
+ struct duration_modulo_imp
+ {
+ };
+
+ template <class Rep1, class Period, class Rep2>
+ struct duration_modulo_imp<duration<Rep1, Period>, Rep2, true>
+ {
+ typedef duration<typename boost::common_type<Rep1, Rep2>::type, Period> type;
+ };
+
+ template <class Rep1, class Period, class Rep2>
+ struct duration_modulo_result<duration<Rep1, Period>, Rep2, false>
+ : duration_modulo_imp<duration<Rep1, Period>, Rep2>
+ {
+ };
+
+ } // namespace detail
+} // namespace chrono
+}
+
+namespace boost {
+// common_type trait specializations
+
+template <class Rep1, class Period1, class Rep2, class Period2>
+ struct common_type<boost_ex::chrono::duration<Rep1, Period1>,
+ boost_ex::chrono::duration<Rep2, Period2> >;
+
+}
+namespace boost_ex {
+
+namespace chrono {
+
+ // customization traits
+ template <class Rep> struct treat_as_floating_point;
+ template <class Rep> struct duration_values;
+
+ // duration arithmetic
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
+// operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
+// operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+// template <class Rep1, class Period, class Rep2>
+// typename boost::enable_if_c
+// <
+// boost::is_convertible<Rep1, typename common_type<Rep1, Rep2>::type>::value
+// && boost::is_convertible<Rep2, typename common_type<Rep1, Rep2>::type>::value,
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// >::type
+// operator*(const duration<Rep1, Period>& d, const Rep2& s);
+// template <class Rep1, class Period, class Rep2>
+// typename boost::enable_if_c
+// <
+// boost::is_convertible<Rep1, typename common_type<Rep1, Rep2>::type>::value
+// && boost::is_convertible<Rep2, typename common_type<Rep1, Rep2>::type>::value,
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// >::type
+// operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+// template <class Rep1, class Period, class Rep2>
+// typename boost::disable_if <detail::is_duration<Rep2>,
+// typename detail::duration_divide_result<duration<Rep1, Period>, Rep2>::type
+// >::type
+// operator/(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// typename common_type<Rep1, Rep2>::type
+// operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+ // duration comparisons
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+ // duration_cast
+
+ //template <class ToDuration, class Rep, class Period>
+ // ToDuration duration_cast(const duration<Rep, Period>& d);
+
+ // convenience typedefs
+ typedef duration<boost::int_least64_t, boost::nano> nanoseconds; // at least 64 bits needed
+ typedef duration<boost::int_least64_t, boost::micro> microseconds; // at least 55 bits needed
+ typedef duration<boost::int_least64_t, boost::milli> milliseconds; // at least 45 bits needed
+ typedef duration<boost::int_least64_t> seconds; // at least 35 bits needed
+ typedef duration<boost::int_least32_t, ratio< 60> > minutes; // at least 29 bits needed
+ typedef duration<boost::int_least32_t, ratio<3600> > hours; // at least 23 bits needed
+
+//----------------------------------------------------------------------------//
+// duration helpers //
+//----------------------------------------------------------------------------//
+
+ namespace detail
+ {
+
+ // duration_cast
+
+ // duration_cast is the heart of this whole prototype. It can convert any
+ // duration to any other. It is also (implicitly) used in converting
+ // time_points. The conversion is always exact if possible. And it is
+ // always as efficient as hand written code. If different representations
+ // are involved, care is taken to never require implicit conversions.
+ // Instead static_cast is used explicitly for every required conversion.
+ // If there are a mixture of integral and floating point representations,
+ // the use of common_type ensures that the most logical "intermediate"
+ // representation is used.
+ template <class FromDuration, class ToDuration,
+ class Period = typename boost::ratio_divide<typename FromDuration::period,
+ typename ToDuration::period>::type,
+ bool = Period::num == 1,
+ bool = Period::den == 1>
+ struct duration_cast;
+
+ // When the two periods are the same, all that is left to do is static_cast from
+ // the source representation to the target representation (which may be a no-op).
+ // This conversion is always exact as long as the static_cast from the source
+ // representation to the destination representation is exact.
+ template <class FromDuration, class ToDuration, class Period>
+ struct duration_cast<FromDuration, ToDuration, Period, true, true>
+ {
+ ToDuration operator()(const FromDuration& fd) const
+ {
+ return ToDuration(static_cast<typename ToDuration::rep>(fd.count()));
+ }
+ };
+
+ // When the numerator of FromPeriod / ToPeriod is 1, then all we need to do is
+ // divide by the denominator of FromPeriod / ToPeriod. The common_type of
+ // the two representations is used for the intermediate computation before
+ // static_cast'ing to the destination.
+ // This conversion is generally not exact because of the division (but could be
+ // if you get lucky on the run time value of fd.count()).
+ template <class FromDuration, class ToDuration, class Period>
+ struct duration_cast<FromDuration, ToDuration, Period, true, false>
+ {
+ ToDuration operator()(const FromDuration& fd) const
+ {
+ typedef typename boost::common_type<
+ typename ToDuration::rep,
+ typename FromDuration::rep,
+ boost::intmax_t>::type C;
+ return ToDuration(static_cast<typename ToDuration::rep>(
+ static_cast<C>(fd.count()) / static_cast<C>(Period::den)));
+ }
+ };
+
+ // When the denomenator of FromPeriod / ToPeriod is 1, then all we need to do is
+ // multiply by the numerator of FromPeriod / ToPeriod. The common_type of
+ // the two representations is used for the intermediate computation before
+ // static_cast'ing to the destination.
+ // This conversion is always exact as long as the static_cast's involved are exact.
+ template <class FromDuration, class ToDuration, class Period>
+ struct duration_cast<FromDuration, ToDuration, Period, false, true>
+ {
+ ToDuration operator()(const FromDuration& fd) const
+ {
+ typedef typename boost::common_type<
+ typename ToDuration::rep,
+ typename FromDuration::rep,
+ boost::intmax_t>::type C;
+ return ToDuration(static_cast<typename ToDuration::rep>(
+ static_cast<C>(fd.count()) * static_cast<C>(Period::num)));
+ }
+ };
+
+ // When neither the numerator or denominator of FromPeriod / ToPeriod is 1, then we need to
+ // multiply by the numerator and divide by the denominator of FromPeriod / ToPeriod. The
+ // common_type of the two representations is used for the intermediate computation before
+ // static_cast'ing to the destination.
+ // This conversion is generally not exact because of the division (but could be
+ // if you get lucky on the run time value of fd.count()).
+ template <class FromDuration, class ToDuration, class Period>
+ struct duration_cast<FromDuration, ToDuration, Period, false, false>
+ {
+ ToDuration operator()(const FromDuration& fd) const
+ {
+ typedef typename boost::common_type<
+ typename ToDuration::rep,
+ typename FromDuration::rep,
+ boost::intmax_t>::type C;
+ return ToDuration(static_cast<typename ToDuration::rep>(
+ static_cast<C>(fd.count()) * static_cast<C>(Period::num)
+ / static_cast<C>(Period::den)));
+ }
+ };
+
+ } // namespace detail
+
+//----------------------------------------------------------------------------//
+// //
+// 20.9.2 Time-related traits [time.traits] //
+// //
+//----------------------------------------------------------------------------//
+//----------------------------------------------------------------------------//
+// 20.9.2.1 treat_as_floating_point [time.traits.is_fp] //
+// Probably should have been treat_as_floating_point. Editor notifed. //
+//----------------------------------------------------------------------------//
+
+ // Support bidirectional (non-exact) conversions for floating point rep types
+ // (or user defined rep types which specialize treat_as_floating_point).
+ template <class Rep>
+ struct treat_as_floating_point : boost::is_floating_point<Rep> {};
+
+//----------------------------------------------------------------------------//
+// 20.9.2.2 duration_values [time.traits.duration_values] //
+//----------------------------------------------------------------------------//
+
+ namespace detail {
+ template <class T, bool = boost::is_arithmetic<T>::value>
+ struct chrono_numeric_limits {
+ static T lowest() throw() {return (std::numeric_limits<T>::min) ();}
+ };
+
+ template <class T>
+ struct chrono_numeric_limits<T,true> {
+ static T lowest() throw() {return (std::numeric_limits<T>::min) ();}
+ };
+
+ template <>
+ struct chrono_numeric_limits<float,true> {
+ static float lowest() throw() {return -(std::numeric_limits<float>::max) ();}
+ };
+
+ template <>
+ struct chrono_numeric_limits<double,true> {
+ static double lowest() throw() {return -(std::numeric_limits<double>::max) ();}
+ };
+
+ template <>
+ struct chrono_numeric_limits<long double,true> {
+ static long double lowest() throw() {return -(std::numeric_limits<long double>::max)();}
+ };
+
+ template <class T>
+ struct numeric_limits : chrono_numeric_limits<typename boost::remove_cv<T>::type> {};
+
+ }
+ template <class Rep>
+ struct duration_values
+ {
+ static Rep zero() {return Rep(0);}
+ static Rep max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (std::numeric_limits<Rep>::max)();}
+
+ static Rep min BOOST_PREVENT_MACRO_SUBSTITUTION () {return detail::numeric_limits<Rep>::lowest();}
+ };
+
+} // namespace chrono
+}
+//----------------------------------------------------------------------------//
+// 20.9.2.3 Specializations of common_type [time.traits.specializations] //
+//----------------------------------------------------------------------------//
+namespace boost {
+template <class Rep1, class Period1, class Rep2, class Period2>
+struct common_type<boost_ex::chrono::duration<Rep1, Period1>,
+ boost_ex::chrono::duration<Rep2, Period2> >
+{
+ typedef boost_ex::chrono::duration<typename common_type<Rep1, Rep2>::type,
+ typename boost::ratio_gcd<Period1, Period2>::type> type;
+};
+
+}
+//----------------------------------------------------------------------------//
+// //
+// 20.9.3 Class template duration [time.duration] //
+// //
+//----------------------------------------------------------------------------//
+
+namespace boost_ex {
+
+namespace chrono {
+
+ template <class Rep, class Period>
+ class duration
+ {
+ BOOST_EX_CHRONO_STATIC_ASSERT(!boost_ex::chrono::detail::is_duration<Rep>::value, BOOST_EX_CHRONO_A_DURATION_REPRESENTATION_CAN_NOT_BE_A_DURATION, ());
+ BOOST_EX_CHRONO_STATIC_ASSERT(boost::ratio_detail::is_ratio<Period>::value, BOOST_EX_CHRONO_SECOND_TEMPLATE_PARAMETER_OF_DURATION_MUST_BE_A_STD_RATIO, ());
+ BOOST_EX_CHRONO_STATIC_ASSERT(Period::num>0, BOOST_EX_CHRONO_DURATION_PERIOD_MUST_BE_POSITIVE, ());
+ public:
+ typedef Rep rep;
+ typedef Period period;
+ private:
+ rep rep_;
+ public:
+
+ duration() { } // = default;
+ template <class Rep2>
+ explicit duration(const Rep2& r
+#if (defined(BOOST_MSVC) && (BOOST_MSVC == 1500)) || defined(__IBMCPP__)
+#else
+ , typename boost::enable_if <
+ boost::mpl::and_ <
+ boost::is_convertible<Rep2, rep>,
+ boost::mpl::or_ <
+ treat_as_floating_point<rep>,
+ boost::mpl::and_ <
+ boost::mpl::not_ < treat_as_floating_point<rep> >,
+ boost::mpl::not_ < treat_as_floating_point<Rep2> >
+ >
+ >
+ >
+ >::type* = 0
+#endif
+ )
+ : rep_(r) { }
+ ~duration() {} //= default;
+ duration(const duration& rhs) : rep_(rhs.rep_) {} // = default;
+ duration& operator=(const duration& rhs) // = default;
+ {
+ if (&rhs != this) rep_= rhs.rep_;
+ return *this;
+ }
+
+ // conversions
+ template <class Rep2, class Period2>
+ duration(const duration<Rep2, Period2>& d
+#if (defined(BOOST_MSVC) && (BOOST_MSVC == 1500)) || defined(__IBMCPP__)
+#else
+ , typename boost::enable_if <
+ boost::mpl::or_ <
+ treat_as_floating_point<rep>,
+ boost::mpl::and_ <
+ boost::mpl::bool_ < boost::ratio_divide<Period2, period>::type::den == 1>,
+ boost::mpl::not_ < treat_as_floating_point<Rep2> >
+ >
+ >
+ >::type* = 0
+#endif
+ )
+//~ #ifdef __GNUC__
+ // GCC 4.2.4 refused to accept a definition at this point,
+ // yet both VC++ 9.0 SP1 and Intel ia32 11.0 accepted the definition
+ // without complaint. VC++ 9.0 SP1 refused to accept a later definition,
+ // although that was fine with GCC 4.2.4 and Intel ia32 11.0. Thus we
+ // have to support both approaches.
+ //~ ;
+//~ #else
+ //~ : rep_(chrono::duration_cast<duration>(d).count()) {}
+ : rep_(chrono::detail::duration_cast<duration<Rep2, Period2>, duration>()(d).count()) {}
+//~ #endif
+
+ // observer
+
+ rep count() const {return rep_;}
+
+ // arithmetic
+
+ duration operator+() const {return *this;}
+ duration operator-() const {return duration(-rep_);}
+ duration& operator++() {++rep_; return *this;}
+ duration operator++(int) {return duration(rep_++);}
+ duration& operator--() {--rep_; return *this;}
+ duration operator--(int) {return duration(rep_--);}
+
+ duration& operator+=(const duration& d) {rep_ += d.count(); return *this;}
+ duration& operator-=(const duration& d) {rep_ -= d.count(); return *this;}
+
+ duration& operator*=(const rep& rhs) {rep_ *= rhs; return *this;}
+ duration& operator/=(const rep& rhs) {rep_ /= rhs; return *this;}
+ duration& operator%=(const rep& rhs) {rep_ %= rhs; return *this;}
+ duration& operator%=(const duration& rhs) {rep_ %= rhs.count(); return *this;};
+ // 20.9.3.4 duration special values [time.duration.special]
+
+ static duration zero() {return duration(duration_values<rep>::zero());}
+ static duration min BOOST_PREVENT_MACRO_SUBSTITUTION () {return duration((duration_values<rep>::min)());}
+ static duration max BOOST_PREVENT_MACRO_SUBSTITUTION () {return duration((duration_values<rep>::max)());}
+ };
+
+//----------------------------------------------------------------------------//
+// 20.9.3.5 duration non-member arithmetic [time.duration.nonmember] //
+//----------------------------------------------------------------------------//
+
+ // Duration +
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ typename boost::common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
+ operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ typename boost::common_type<duration<Rep1, Period1>,
+ duration<Rep2, Period2> >::type result = lhs;
+ result += rhs;
+ return result;
+ }
+
+ // Duration -
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ typename boost::common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
+ operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ typename boost::common_type<duration<Rep1, Period1>,
+ duration<Rep2, Period2> >::type result = lhs;
+ result -= rhs;
+ return result;
+ }
+
+ // Duration *
+
+ template <class Rep1, class Period, class Rep2>
+ inline
+#if (defined(BOOST_MSVC) && (BOOST_MSVC == 1500)) || defined(__IBMCPP__)
+ duration<typename boost::common_type<Rep1, Rep2>::type, Period>
+#else
+typename boost::enable_if <
+ boost::mpl::and_ <
+ boost::is_convertible<Rep1, typename boost::common_type<Rep1, Rep2>::type>,
+ boost::is_convertible<Rep2, typename boost::common_type<Rep1, Rep2>::type>
+ >,
+ duration<typename boost::common_type<Rep1, Rep2>::type, Period>
+ >::type
+#endif
+ operator*(const duration<Rep1, Period>& d, const Rep2& s)
+ {
+ typedef typename boost::common_type<Rep1, Rep2>::type CR;
+ duration<CR, Period> r = d;
+ r *= static_cast<CR>(s);
+ return r;
+ }
+
+ template <class Rep1, class Period, class Rep2>
+ inline
+#if (defined(BOOST_MSVC) && (BOOST_MSVC == 1500)) || defined(__IBMCPP__)
+ duration<typename boost::common_type<Rep1, Rep2>::type, Period>
+#else
+ typename boost::enable_if <
+ boost::mpl::and_ <
+ boost::is_convertible<Rep1, typename boost::common_type<Rep1, Rep2>::type>,
+ boost::is_convertible<Rep2, typename boost::common_type<Rep1, Rep2>::type>
+ >,
+ duration<typename boost::common_type<Rep1, Rep2>::type, Period>
+ >::type
+#endif
+ operator*(const Rep1& s, const duration<Rep2, Period>& d)
+ {
+ return d * s;
+ }
+
+ // Duration /
+
+ template <class Rep1, class Period, class Rep2>
+ inline
+ typename boost::disable_if <boost_ex::chrono::detail::is_duration<Rep2>,
+ typename boost_ex::chrono::detail::duration_divide_result<duration<Rep1, Period>, Rep2>::type
+ >::type
+ operator/(const duration<Rep1, Period>& d, const Rep2& s)
+ {
+ typedef typename boost::common_type<Rep1, Rep2>::type CR;
+ duration<CR, Period> r = d;
+ r /= static_cast<CR>(s);
+ return r;
+ }
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ typename boost::common_type<Rep1, Rep2>::type
+ operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ typedef typename boost::common_type<duration<Rep1, Period1>,
+ duration<Rep2, Period2> >::type CD;
+ return CD(lhs).count() / CD(rhs).count();
+ }
+
+ template <class Rep1, class Rep2, class Period>
+ inline
+ typename boost::disable_if <boost_ex::chrono::detail::is_duration<Rep1>,
+ typename boost_ex::chrono::detail::duration_divide_result2<Rep1, duration<Rep2, Period> >::type
+ >::type
+ operator/(const Rep1& s, const duration<Rep2, Period>& d)
+ {
+ typedef typename boost::common_type<Rep1, Rep2>::type CR;
+ duration<CR, Period> r = d;
+ //return static_cast<CR>(r.count()) / static_cast<CR>(s);
+ return static_cast<CR>(s)/r.count();
+ }
+
+ // Duration %
+
+ template <class Rep1, class Period, class Rep2>
+ typename boost::disable_if <boost_ex::chrono::detail::is_duration<Rep2>,
+ typename boost_ex::chrono::detail::duration_modulo_result<duration<Rep1, Period>, Rep2>::type
+ >::type
+ operator%(const duration<Rep1, Period>& d, const Rep2& s) {
+ typedef typename boost::common_type<Rep1, Rep2>::type CR;
+ duration<CR, Period> r = d;
+ r %= static_cast<CR>(s);
+ return r;
+ }
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ typename boost::common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
+ operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs) {
+ typedef typename boost::common_type<duration<Rep1, Period1>,
+ duration<Rep2, Period2> >::type CD;
+ CD r(lhs);
+ r%=CD(rhs);
+ return r;
+ }
+
+
+//----------------------------------------------------------------------------//
+// 20.9.3.6 duration comparisons [time.duration.comparisons] //
+//----------------------------------------------------------------------------//
+
+ namespace detail
+ {
+ template <class LhsDuration, class RhsDuration>
+ struct duration_eq
+ {
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {
+ typedef typename boost::common_type<LhsDuration, RhsDuration>::type CD;
+ return CD(lhs).count() == CD(rhs).count();
+ }
+ };
+
+ template <class LhsDuration>
+ struct duration_eq<LhsDuration, LhsDuration>
+ {
+ bool operator()(const LhsDuration& lhs, const LhsDuration& rhs)
+ {return lhs.count() == rhs.count();}
+ };
+
+ template <class LhsDuration, class RhsDuration>
+ struct duration_lt
+ {
+ bool operator()(const LhsDuration& lhs, const RhsDuration& rhs)
+ {
+ typedef typename boost::common_type<LhsDuration, RhsDuration>::type CD;
+ return CD(lhs).count() < CD(rhs).count();
+ }
+ };
+
+ template <class LhsDuration>
+ struct duration_lt<LhsDuration, LhsDuration>
+ {
+ bool operator()(const LhsDuration& lhs, const LhsDuration& rhs)
+ {return lhs.count() < rhs.count();}
+ };
+
+ } // namespace detail
+
+ // Duration ==
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ bool
+ operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ return boost_ex::chrono::detail::duration_eq<duration<Rep1, Period1>, duration<Rep2, Period2> >()(lhs, rhs);
+ }
+
+ // Duration !=
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ bool
+ operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ return !(lhs == rhs);
+ }
+
+ // Duration <
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ bool
+ operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ return boost_ex::chrono::detail::duration_lt<duration<Rep1, Period1>, duration<Rep2, Period2> >()(lhs, rhs);
+ }
+
+ // Duration >
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ bool
+ operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ return rhs < lhs;
+ }
+
+ // Duration <=
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ bool
+ operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ return !(rhs < lhs);
+ }
+
+ // Duration >=
+
+ template <class Rep1, class Period1, class Rep2, class Period2>
+ inline
+ bool
+ operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
+ {
+ return !(lhs < rhs);
+ }
+
+//----------------------------------------------------------------------------//
+// 20.9.3.7 duration_cast [time.duration.cast] //
+//----------------------------------------------------------------------------//
+
+ // Compile-time select the most efficient algorithm for the conversion...
+ template <class ToDuration, class Rep, class Period>
+ inline
+#if (defined(BOOST_MSVC) && (BOOST_MSVC == 1500)) || defined(__IBMCPP__)
+ ToDuration
+#else
+ typename boost::enable_if <boost_ex::chrono::detail::is_duration<ToDuration>, ToDuration>::type
+#endif
+ duration_cast(const duration<Rep, Period>& fd)
+ {
+ return boost_ex::chrono::detail::duration_cast<duration<Rep, Period>, ToDuration>()(fd);
+ }
+
+}
+}
+#endif // BOOST_EX_CHRONO_DURATION_HPP

Added: branches/release/libs/ratio/example/si_physics.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/si_physics.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,236 @@
+// ratio_test.cpp ----------------------------------------------------------//
+
+// Copyright 2008 Howard Hinnant
+// Copyright 2008 Beman Dawes
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <iostream>
+#include <boost/ratio/ratio.hpp>
+#include "duration.hpp"
+
+namespace User1
+{
+// Example type-safe "physics" code interoperating with chrono::duration types
+// and taking advantage of the std::ratio infrastructure and design philosophy.
+
+// length - mimics chrono::duration except restricts representation to double.
+// Uses boost::ratio facilities for length units conversions.
+
+template <class Ratio>
+class length
+{
+public:
+ typedef Ratio ratio;
+private:
+ double len_;
+public:
+
+ length() : len_(1) {}
+ length(const double& len) : len_(len) {}
+
+ // conversions
+ template <class R>
+ length(const length<R>& d)
+ : len_(d.count() * boost::ratio_divide<Ratio, R>::type::den /
+ boost::ratio_divide<Ratio, R>::type::num) {}
+
+ // observer
+
+ double count() const {return len_;}
+
+ // arithmetic
+
+ length& operator+=(const length& d) {len_ += d.count(); return *this;}
+ length& operator-=(const length& d) {len_ -= d.count(); return *this;}
+
+ length operator+() const {return *this;}
+ length operator-() const {return length(-len_);}
+
+ length& operator*=(double rhs) {len_ *= rhs; return *this;}
+ length& operator/=(double rhs) {len_ /= rhs; return *this;}
+};
+
+// Sparse sampling of length units
+typedef length<boost::ratio<1> > meter; // set meter as "unity"
+typedef length<boost::centi> centimeter; // 1/100 meter
+typedef length<boost::kilo> kilometer; // 1000 meters
+typedef length<boost::ratio<254, 10000> > inch; // 254/10000 meters
+// length takes ratio instead of two integral types so that definitions can be made like so:
+typedef length<boost::ratio_multiply<boost::ratio<12>, inch::ratio>::type> foot; // 12 inchs
+typedef length<boost::ratio_multiply<boost::ratio<5280>, foot::ratio>::type> mile; // 5280 feet
+
+// Need a floating point definition of seconds
+typedef boost_ex::chrono::duration<double> seconds; // unity
+// Demo of (scientific) support for sub-nanosecond resolutions
+typedef boost_ex::chrono::duration<double, boost::pico> picosecond; // 10^-12 seconds
+typedef boost_ex::chrono::duration<double, boost::femto> femtosecond; // 10^-15 seconds
+typedef boost_ex::chrono::duration<double, boost::atto> attosecond; // 10^-18 seconds
+
+// A very brief proof-of-concept for SIUnits-like library
+// Hard-wired to floating point seconds and meters, but accepts other units (shown in testUser1())
+template <class R1, class R2>
+class quantity
+{
+ double q_;
+public:
+ typedef R1 time_dim;
+ typedef R2 distance_dim;
+ quantity() : q_(1) {}
+
+ double get() const {return q_;}
+ void set(double q) {q_ = q;}
+};
+
+template <>
+class quantity<boost::ratio<1>, boost::ratio<0> >
+{
+ double q_;
+public:
+ quantity() : q_(1) {}
+ quantity(seconds d) : q_(d.count()) {} // note: only User1::seconds needed here
+
+ double get() const {return q_;}
+ void set(double q) {q_ = q;}
+};
+
+template <>
+class quantity<boost::ratio<0>, boost::ratio<1> >
+{
+ double q_;
+public:
+ quantity() : q_(1) {}
+ quantity(meter d) : q_(d.count()) {} // note: only User1::meter needed here
+
+ double get() const {return q_;}
+ void set(double q) {q_ = q;}
+};
+
+template <>
+class quantity<boost::ratio<0>, boost::ratio<0> >
+{
+ double q_;
+public:
+ quantity() : q_(1) {}
+ quantity(double d) : q_(d) {}
+
+ double get() const {return q_;}
+ void set(double q) {q_ = q;}
+};
+
+// Example SI-Units
+typedef quantity<boost::ratio<0>, boost::ratio<0> > Scalar;
+typedef quantity<boost::ratio<1>, boost::ratio<0> > Time; // second
+typedef quantity<boost::ratio<0>, boost::ratio<1> > Distance; // meter
+typedef quantity<boost::ratio<-1>, boost::ratio<1> > Speed; // meter/second
+typedef quantity<boost::ratio<-2>, boost::ratio<1> > Acceleration; // meter/second^2
+
+template <class R1, class R2, class R3, class R4>
+quantity<typename boost::ratio_subtract<R1, R3>::type, typename boost::ratio_subtract<R2, R4>::type>
+operator/(const quantity<R1, R2>& x, const quantity<R3, R4>& y)
+{
+ typedef quantity<typename boost::ratio_subtract<R1, R3>::type, typename boost::ratio_subtract<R2, R4>::type> R;
+ R r;
+ r.set(x.get() / y.get());
+ return r;
+}
+
+template <class R1, class R2, class R3, class R4>
+quantity<typename boost::ratio_add<R1, R3>::type, typename boost::ratio_add<R2, R4>::type>
+operator*(const quantity<R1, R2>& x, const quantity<R3, R4>& y)
+{
+ typedef quantity<typename boost::ratio_add<R1, R3>::type, typename boost::ratio_add<R2, R4>::type> R;
+ R r;
+ r.set(x.get() * y.get());
+ return r;
+}
+
+template <class R1, class R2>
+quantity<R1, R2>
+operator+(const quantity<R1, R2>& x, const quantity<R1, R2>& y)
+{
+ typedef quantity<R1, R2> R;
+ R r;
+ r.set(x.get() + y.get());
+ return r;
+}
+
+template <class R1, class R2>
+quantity<R1, R2>
+operator-(const quantity<R1, R2>& x, const quantity<R1, R2>& y)
+{
+ typedef quantity<R1, R2> R;
+ R r;
+ r.set(x.get() - y.get());
+ return r;
+}
+
+// Example type-safe physics function
+Distance
+compute_distance(Speed v0, Time t, Acceleration a)
+{
+ return v0 * t + Scalar(.5) * a * t * t; // if a units mistake is made here it won't compile
+}
+
+} // User1
+
+// Exercise example type-safe physics function and show interoperation
+// of custom time durations (User1::seconds) and standard time durations (std::hours).
+// Though input can be arbitrary (but type-safe) units, output is always in SI-units
+// (a limitation of the simplified Units lib demoed here).
+
+
+
+int main()
+{
+ //~ typedef boost::ratio<8, BOOST_INTMAX_C(0x7FFFFFFFD)> R1;
+ //~ typedef boost::ratio<3, BOOST_INTMAX_C(0x7FFFFFFFD)> R2;
+ typedef User1::quantity<boost::ratio_subtract<boost::ratio<0>, boost::ratio<1> >::type,
+ boost::ratio_subtract<boost::ratio<1>, boost::ratio<0> >::type > RR;
+ //~ typedef boost::ratio_subtract<R1, R2>::type RS;
+ //~ std::cout << RS::num << '/' << RS::den << '\n';
+
+
+ std::cout << "*************\n";
+ std::cout << "* testUser1 *\n";
+ std::cout << "*************\n";
+ User1::Distance d(( User1::mile(110) ));
+ boost_ex::chrono::hours h((2));
+ User1::Time t(( h ));
+ //~ boost_ex::chrono::seconds sss=boost_ex::chrono::duration_cast<boost_ex::chrono::seconds>(h);
+ //~ User1::seconds sss((120));
+ //~ User1::Time t(( sss ));
+
+ //typedef User1::quantity<boost::ratio_subtract<User1::Distance::time_dim, User1::Time::time_dim >::type,
+ // boost::ratio_subtract<User1::Distance::distance_dim, User1::Time::distance_dim >::type > R;
+ RR r=d / t;
+ //r.set(d.get() / t.get());
+
+ User1::Speed rc= r;
+
+ User1::Speed s = d / t;
+ std::cout << "Speed = " << s.get() << " meters/sec\n";
+ User1::Acceleration a = User1::Distance( User1::foot(32.2) ) / User1::Time() / User1::Time();
+ std::cout << "Acceleration = " << a.get() << " meters/sec^2\n";
+ User1::Distance df = compute_distance(s, User1::Time( User1::seconds(0.5) ), a);
+ std::cout << "Distance = " << df.get() << " meters\n";
+ std::cout << "There are " << User1::mile::ratio::den << '/' << User1::mile::ratio::num << " miles/meter";
+ User1::meter mt = 1;
+ User1::mile mi = mt;
+ std::cout << " which is approximately " << mi.count() << '\n';
+ std::cout << "There are " << User1::mile::ratio::num << '/' << User1::mile::ratio::den << " meters/mile";
+ mi = 1;
+ mt = mi;
+ std::cout << " which is approximately " << mt.count() << '\n';
+ User1::attosecond as(1);
+ User1::seconds sec = as;
+ std::cout << "1 attosecond is " << sec.count() << " seconds\n";
+ std::cout << "sec = as; // compiles\n";
+ sec = User1::seconds(1);
+ as = sec;
+ std::cout << "1 second is " << as.count() << " attoseconds\n";
+ std::cout << "as = sec; // compiles\n";
+ std::cout << "\n";
+ return 0;
+}

Added: branches/release/libs/ratio/example/static_assert.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/static_assert.hpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,30 @@
+// static_assert.hpp --------------------------------------------------------------//
+
+// Copyright 2009-2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+
+#ifndef BOOST_EX_CHRONO_DETAIL_STATIC_ASSERT_HPP
+#define BOOST_EX_CHRONO_DETAIL_STATIC_ASSERT_HPP
+
+#include "config.hpp"
+
+#ifndef BOOST_NO_STATIC_ASSERT
+#define BOOST_EX_CHRONO_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG)
+#elif defined(BOOST_CHRONO_USES_STATIC_ASSERT)
+#include <boost/static_assert.hpp>
+#define BOOST_EX_CHRONO_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND)
+#elif defined(BOOST_CHRONO_USES_MPL_ASSERT)
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/bool.hpp>
+#define BOOST_EX_CHRONO_STATIC_ASSERT(CND, MSG, TYPES) \
+ BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES)
+#else
+//~ #elif defined(BOOST_CHRONO_USES_ARRAY_ASSERT)
+#define BOOST_EX_CHRONO_STATIC_ASSERT(CND, MSG, TYPES) static char BOOST_JOIN(boost_chrono_test_,__LINE__)[(CND)?1:-1]
+//~ #define BOOST_EX_CHRONO_STATIC_ASSERT(CND, MSG, TYPES)
+#endif
+
+#endif // BOOST_EX_CHRONO_DETAIL_STATIC_ASSERT_HPP

Added: branches/release/libs/ratio/example/type_traits/add_rvalue_reference.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/type_traits/add_rvalue_reference.hpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,67 @@
+// add_rvalue_reference.hpp ---------------------------------------------------------//
+
+// Copyright 2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#ifndef BOOST_EX_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
+#define BOOST_EX_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
+
+#include <boost/config.hpp>
+
+//----------------------------------------------------------------------------//
+
+#include <boost/type_traits/is_void.hpp>
+#include <boost/type_traits/is_reference.hpp>
+
+// should be the last #include
+#include <boost/type_traits/detail/type_trait_def.hpp>
+
+//----------------------------------------------------------------------------//
+// //
+// C++03 implementation of //
+// 20.7.6.2 Reference modifications [meta.trans.ref] //
+// Written by Vicente J. Botet Escriba //
+// //
+// If T names an object or function type then the member typedef type
+// shall name T&&; otherwise, type shall name T. [ Note: This rule reflects
+// the semantics of reference collapsing. For example, when a type T names
+// a type T1&, the type add_rvalue_reference<T>::type is not an rvalue
+// reference. -end note ]
+//----------------------------------------------------------------------------//
+
+namespace boost_ex {
+
+namespace type_traits_detail {
+
+ template <typename T, bool b>
+ struct add_rvalue_reference_helper
+ { typedef T type; };
+
+ template <typename T>
+ struct add_rvalue_reference_helper<T, true>
+ {
+#if !defined(BOOST_NO_RVALUE_REFERENCES)
+ typedef T&& type;
+#else
+ typedef T type;
+#endif
+ };
+
+ template <typename T>
+ struct add_rvalue_reference_imp
+ {
+ typedef typename boost_ex::type_traits_detail::add_rvalue_reference_helper
+ <T, (!boost::is_void<T>::value && !boost::is_reference<T>::value) >::type type;
+ };
+
+}
+
+BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_rvalue_reference,T,typename boost_ex::type_traits_detail::add_rvalue_reference_imp<T>::type)
+
+} // namespace boost_ex
+
+#include <boost/type_traits/detail/type_trait_undef.hpp>
+
+#endif // BOOST_EX_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP

Added: branches/release/libs/ratio/example/type_traits/common_type.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/type_traits/common_type.hpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,151 @@
+// common_type.hpp ---------------------------------------------------------//
+
+// Copyright 2008 Howard Hinnant
+// Copyright 2008 Beman Dawes
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#ifndef BOOST_EX_TYPE_TRAITS_EXT_COMMON_TYPE_HPP
+#define BOOST_EX_TYPE_TRAITS_EXT_COMMON_TYPE_HPP
+
+#include <boost/config.hpp>
+
+//----------------------------------------------------------------------------//
+#if defined(BOOST_NO_VARIADIC_TEMPLATES)
+#define BOOST_EX_COMMON_TYPE_ARITY 3
+#endif
+
+//----------------------------------------------------------------------------//
+#if defined(BOOST_NO_DECLTYPE) && !defined(BOOST_EX_COMMON_TYPE_DONT_USE_TYPEOF)
+#define BOOST_TYPEOF_SILENT
+#include <boost/typeof/typeof.hpp> // boost wonders never cease!
+#endif
+
+//----------------------------------------------------------------------------//
+#ifndef BOOST_NO_STATIC_ASSERT
+#define BOOST_EX_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG)
+#elif defined(BOOST_EX_COMMON_TYPE_USES_STATIC_ASSERT)
+#include <boost/static_assert.hpp>
+#define BOOST_EX_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND)
+#elif defined(BOOST_EX_COMMON_TYPE_USES_MPL_ASSERT)
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/bool.hpp>
+#define BOOST_EX_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) \
+ BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES)
+#else
+//~ #elif defined(BOOST_EX_COMMON_TYPE_USES_ARRAY_ASSERT)
+#define BOOST_EX_COMMON_TYPE_CONCAT(A,B) A##B
+#define BOOST_EX_COMMON_TYPE_NAME(A,B) BOOST_EX_COMMON_TYPE_CONCAT(A,B)
+#define BOOST_EX_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) static char BOOST_EX_COMMON_TYPE_NAME(__boost_common_type_test_,__LINE__)[(CND)?1:-1]
+//~ #define BOOST_EX_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES)
+#endif
+
+#if !defined(BOOST_NO_STATIC_ASSERT) || !defined(BOOST_EX_COMMON_TYPE_USES_MPL_ASSERT)
+#define BOOST_EX_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE "must be complete type"
+#endif
+
+#if defined(BOOST_NO_DECLTYPE) && defined(BOOST_EX_COMMON_TYPE_DONT_USE_TYPEOF)
+#include "detail/common_type.hpp"
+#include <boost/type_traits/remove_cv.hpp>
+#endif
+#include <boost/mpl/if.hpp>
+#include "declval.hpp"
+
+//----------------------------------------------------------------------------//
+// //
+// C++03 implementation of //
+// 20.6.7 Other transformations [meta.trans.other] //
+// Written by Howard Hinnant //
+// Adapted for Boost by Beman Dawes, Vicente Botet and Jeffrey Hellrung //
+// //
+//----------------------------------------------------------------------------//
+
+namespace boost_ex {
+
+// prototype
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+ template<typename... T>
+ struct common_type;
+#else // or no specialization
+ template <class T, class U = void, class V = void>
+ struct common_type
+ {
+ public:
+ typedef typename common_type<typename common_type<T, U>::type, V>::type type;
+ };
+#endif
+
+
+// 1 arg
+ template<typename T>
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+ struct common_type<T>
+#else
+ struct common_type<T, void, void>
+
+#endif
+ {
+ BOOST_EX_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_EX_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T));
+ public:
+ typedef T type;
+ };
+
+// 2 args
+namespace type_traits_detail {
+
+ template <class T, class U>
+ struct common_type_2
+ {
+ private:
+ BOOST_EX_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_EX_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T));
+ BOOST_EX_COMMON_TYPE_STATIC_ASSERT(sizeof(U) > 0, BOOST_EX_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (U));
+ static bool declval_bool(); // workaround gcc bug; not required by std
+ static typename add_rvalue_reference<T>::type declval_T(); // workaround gcc bug; not required by std
+ static typename add_rvalue_reference<U>::type declval_U(); // workaround gcc bug; not required by std
+
+#if !defined(BOOST_NO_DECLTYPE)
+ public:
+ typedef decltype(declval<bool>() ? declval<T>() : declval<U>()) type;
+#elif defined(BOOST_EX_COMMON_TYPE_DONT_USE_TYPEOF)
+ public:
+ typedef typename detail_type_traits_common_type::common_type_impl<
+ typename remove_cv<T>::type,
+ typename remove_cv<U>::type
+ >::type type;
+#else
+ public:
+ //~ typedef BOOST_TYPEOF_TPL(declval_bool() ? declval_T() : declval_U()) type;
+ typedef BOOST_TYPEOF_TPL(declval<bool>() ? declval<T>() : declval<U>()) type;
+#endif
+ };
+
+ template <class T>
+ struct common_type_2<T, T>
+ {
+ typedef T type;
+ };
+ }
+
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+ template <class T, class U>
+ struct common_type<T, U>
+#else
+ template <class T, class U>
+ struct common_type<T, U, void>
+#endif
+ : type_traits_detail::common_type_2<T,U>
+ { };
+
+
+// 3 or more args
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+ template<typename T, typename U, typename... V>
+ struct common_type<T, U, V...> {
+ public:
+ typedef typename common_type<typename common_type<T, U>::type, V...>::type type;
+ };
+#endif
+} // namespace boost_ex
+
+#endif // BOOST_TYPE_TRAITS_EXT_COMMON_TYPE_HPP

Added: branches/release/libs/ratio/example/type_traits/declval.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/type_traits/declval.hpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,44 @@
+// common_type.hpp ---------------------------------------------------------//
+
+// Copyright 2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#ifndef BOOST_EX_TYPE_TRAITS_EXT_DECLVAL__HPP
+#define BOOST_EX_TYPE_TRAITS_EXT_DECLVAL__HPP
+
+#include <boost/config.hpp>
+
+//----------------------------------------------------------------------------//
+
+#include "add_rvalue_reference.hpp"
+
+//----------------------------------------------------------------------------//
+// //
+// C++03 implementation of //
+// Written by Vicente J. Botet Escriba //
+//~ 20.3.4 Function template declval [declval]
+//~ 1 The library provides the function template declval to simplify the definition of expressions which occur as
+//~ unevaluated operands.
+//~ 2 Remarks: If this function is used, the program is ill-formed.
+//~ 3 Remarks: The template parameter T of declval may be an incomplete type.
+//~ [ Example:
+
+//~ template <class To, class From>
+//~ decltype(static_cast<To>(declval<From>())) convert(From&&);
+
+//~ declares a function template convert which only participats in overloading if the type From can be
+//~ explicitly converted to type To. For another example see class template common_type (20.7.6.6). -end
+//~ example ]
+// //
+//----------------------------------------------------------------------------//
+
+namespace boost_ex {
+
+ template <typename T>
+ typename add_rvalue_reference<T>::type declval(); //noexcept; // as unevaluated operand
+
+} // namespace boost
+
+#endif // BOOST_EX_TYPE_TRAITS_EXT_DECLVAL__HPP

Added: branches/release/libs/ratio/example/type_traits/detail/common_type.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/example/type_traits/detail/common_type.hpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,316 @@
+/*******************************************************************************
+ * boost/type_traits/detail/common_type.hpp
+ *
+ * Copyright 2010, Jeffrey Hellrung.
+ * 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)
+ *
+ * struct boost::common_type<T,U>
+ *
+ * common_type<T,U>::type is the type of the expression
+ * b() ? x() : y()
+ * where b() returns a bool, x() has return type T, and y() has return type U.
+ * See
+ * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm#common_type
+ *
+ * Note that this evaluates to void if one or both of T and U is void.
+ ******************************************************************************/
+
+#ifndef BOOST_EX_TYPE_TRAITS_EXT_DETAIL_COMMON_TYPE_HPP
+#define BOOST_EX_TYPE_TRAITS_EXT_DETAIL_COMMON_TYPE_HPP
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/at.hpp>
+#include <boost/mpl/begin_end.hpp>
+#include <boost/mpl/contains.hpp>
+#include <boost/mpl/copy.hpp>
+#include <boost/mpl/deref.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/inserter.hpp>
+#include <boost/mpl/next.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/vector/vector0.hpp>
+#include <boost/mpl/vector/vector10.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/type_traits/is_enum.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/make_signed.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/declval.hpp>
+
+namespace boost_ex
+{
+
+namespace detail_type_traits_common_type
+{
+
+/*******************************************************************************
+ * struct propagate_cv< From, To >
+ *
+ * This metafunction propagates cv-qualifiers on type From to type To.
+ ******************************************************************************/
+
+template< class From, class To >
+struct propagate_cv
+{ typedef To type; };
+template< class From, class To >
+struct propagate_cv< const From, To >
+{ typedef To const type; };
+template< class From, class To >
+struct propagate_cv< volatile From, To >
+{ typedef To volatile type; };
+template< class From, class To >
+struct propagate_cv< const volatile From, To >
+{ typedef To const volatile type; };
+
+/*******************************************************************************
+ * struct is_signable_integral<T>
+ *
+ * This metafunction determines if T is an integral type which can be made
+ * signed or unsigned.
+ ******************************************************************************/
+
+template< class T >
+struct is_signable_integral
+ : mpl::or_< is_integral<T>, is_enum<T> >
+{ };
+template<>
+struct is_signable_integral< bool >
+ : false_type
+{ };
+
+/*******************************************************************************
+ * struct sizeof_t<N>
+ * typedef ... yes_type
+ * typedef ... no_type
+ *
+ * These types are integral players in the use of the "sizeof trick", i.e., we
+ * can distinguish overload selection by inspecting the size of the return type
+ * of the overload.
+ ******************************************************************************/
+
+template< std::size_t N > struct sizeof_t { char _dummy[N]; };
+typedef sizeof_t<1> yes_type;
+typedef sizeof_t<2> no_type;
+BOOST_MPL_ASSERT_RELATION( sizeof( yes_type ), ==, 1 );
+BOOST_MPL_ASSERT_RELATION( sizeof( no_type ), ==, 2 );
+
+/*******************************************************************************
+ * rvalue_test(T&) -> no_type
+ * rvalue_test(...) -> yes_type
+ *
+ * These overloads are used to determine the rvalue-ness of an expression.
+ ******************************************************************************/
+
+template< class T > no_type rvalue_test(T&);
+yes_type rvalue_test(...);
+
+/*******************************************************************************
+ * struct conversion_test_overloads< Sequence >
+ *
+ * This struct has multiple overloads of the static member function apply, each
+ * one taking a single parameter of a type within the Boost.MPL sequence
+ * Sequence. Each such apply overload has a return type with sizeof equal to
+ * one plus the index of the parameter type within Sequence. Thus, we can
+ * deduce the type T of an expression as long as we can generate a finite set of
+ * candidate types containing T via these apply overloads and the "sizeof
+ * trick".
+ ******************************************************************************/
+
+template< class First, class Last, std::size_t Index >
+struct conversion_test_overloads_iterate
+ : conversion_test_overloads_iterate<
+ typename mpl::next< First >::type, Last, Index + 1
+ >
+{
+ using conversion_test_overloads_iterate<
+ typename mpl::next< First >::type, Last, Index + 1
+ >::apply;
+ static sizeof_t< Index + 1 >
+ apply(typename mpl::deref< First >::type);
+};
+
+template< class Last, std::size_t Index >
+struct conversion_test_overloads_iterate< Last, Last, Index >
+{ static sizeof_t< Index + 1 > apply(...); };
+
+template< class Sequence >
+struct conversion_test_overloads
+ : conversion_test_overloads_iterate<
+ typename mpl::begin< Sequence >::type,
+ typename mpl::end< Sequence >::type,
+ 0
+ >
+{ };
+
+/*******************************************************************************
+ * struct select< Sequence, Index >
+ *
+ * select is synonymous with mpl::at_c unless Index equals the size of the
+ * Boost.MPL Sequence, in which case this evaluates to void.
+ ******************************************************************************/
+
+template<
+ class Sequence, int Index,
+ int N = mpl::size< Sequence >::value
+>
+struct select
+ : mpl::at_c< Sequence, Index >
+{ };
+template< class Sequence, int N >
+struct select< Sequence, N, N >
+{ typedef void type; };
+
+/*******************************************************************************
+ * class deduce_common_type< T, U, NominalCandidates >
+ * struct nominal_candidates<T,U>
+ * struct common_type_dispatch_on_rvalueness<T,U>
+ * struct common_type_impl<T,U>
+ *
+ * These classes and structs implement the logic behind common_type, which goes
+ * roughly as follows. Let C be the type of the conditional expression
+ * declval< bool >() ? declval<T>() : declval<U>()
+ * if C is an rvalue, then:
+ * let T' and U' be T and U stripped of reference- and cv-qualifiers
+ * if T' and U' are pointer types, say, T' = V* and U' = W*, then:
+ * define the set of NominalCandidates to be
+ * { V*, W*, V'*, W'* }
+ * where V' is V with whatever cv-qualifiers are on W, and W' is W
+ * with whatever cv-qualifiers are on V
+ * else T' and U' are both "signable integral types" (integral and enum
+ * types excepting bool), then:
+ * define the set of NominalCandidates to be
+ * { unsigned(T'), unsigned(U'), signed(T'), signed(U') }
+ * where unsigned(X) is make_unsigned<X>::type and signed(X) is
+ * make_signed<X>::type
+ * else
+ * define the set of NominalCandidates to be
+ * { T', U' }
+ * else
+ * let V and W be T and U stripped of reference-qualifiers
+ * define the set of NominalCandidates to be
+ * { V&, W&, V'&, W'& }
+ * where V' is V with whatever cv-qualifiers are on W, and W' is W with
+ * whatever cv-qualifiers are on V
+ * define the set of Candidates to be equal to the set of NominalCandidates with
+ * duplicates removed, and use this set of Candidates to determine C using the
+ * conversion_test_overloads struct
+ ******************************************************************************/
+
+template< class T, class U, class NominalCandidates >
+class deduce_common_type
+{
+ typedef typename mpl::copy<
+ NominalCandidates,
+ mpl::inserter<
+ mpl::vector0<>,
+ mpl::if_<
+ mpl::contains< mpl::_1, mpl::_2 >,
+ mpl::_1,
+ mpl::push_back< mpl::_1, mpl::_2 >
+ >
+ >
+ >::type candidate_types;
+ static const int best_candidate_index =
+ sizeof( conversion_test_overloads< candidate_types >::apply(
+ declval< bool >() ? declval<T>() : declval<U>()
+ ) ) - 1;
+public:
+ typedef typename select< candidate_types, best_candidate_index >::type type;
+};
+
+template<
+ class T, class U,
+ class V = typename remove_cv< typename remove_reference<T>::type >::type,
+ class W = typename remove_cv< typename remove_reference<U>::type >::type,
+ bool = is_signable_integral<V>::value && is_signable_integral<W>::value
+>
+struct nominal_candidates;
+
+template< class T, class U, class V, class W >
+struct nominal_candidates< T, U, V, W, false >
+{ typedef mpl::vector2<V,W> type; };
+
+template< class T, class U, class V, class W >
+struct nominal_candidates< T, U, V, W, true >
+{
+ typedef mpl::vector4<
+ typename make_unsigned<V>::type,
+ typename make_unsigned<W>::type,
+ typename make_signed<V>::type,
+ typename make_signed<W>::type
+ > type;
+};
+
+template< class T, class U, class V, class W >
+struct nominal_candidates< T, U, V*, W*, false >
+{
+ typedef mpl::vector4<
+ V*, W*,
+ typename propagate_cv<W,V>::type *,
+ typename propagate_cv<V,W>::type *
+ > type;
+};
+
+template<
+ class T, class U,
+ bool = sizeof( ::boost::detail_type_traits_common_type::rvalue_test(
+ declval< bool >() ? declval<T>() : declval<U>()
+ ) ) == sizeof( yes_type )
+>
+struct common_type_dispatch_on_rvalueness;
+
+template< class T, class U >
+struct common_type_dispatch_on_rvalueness< T, U, true >
+ : deduce_common_type< T, U, typename nominal_candidates<T,U>::type >
+{ };
+
+template< class T, class U >
+struct common_type_dispatch_on_rvalueness< T, U, false >
+{
+private:
+ typedef typename remove_reference<T>::type unrefed_T_type;
+ typedef typename remove_reference<U>::type unrefed_U_type;
+public:
+ typedef typename deduce_common_type<
+ T, U,
+ mpl::vector4<
+ unrefed_T_type &,
+ unrefed_U_type &,
+ typename propagate_cv< unrefed_U_type, unrefed_T_type >::type &,
+ typename propagate_cv< unrefed_T_type, unrefed_U_type >::type &
+ >
+ >::type type;
+};
+
+template< class T, class U >
+struct common_type_impl
+ : common_type_dispatch_on_rvalueness<T,U>
+{ };
+
+template< class T > struct common_type_impl< T, void > { typedef void type; };
+template< class T > struct common_type_impl< void, T > { typedef void type; };
+template<> struct common_type_impl< void, void > { typedef void type; };
+template< > struct common_type_impl< char, short> { typedef int type; };
+template< > struct common_type_impl< short, char> { typedef int type; };
+template< > struct common_type_impl< unsigned char, short> { typedef int type; };
+template< > struct common_type_impl< short, unsigned char> { typedef int type; };
+template< > struct common_type_impl< unsigned char, unsigned short> { typedef int type; };
+template< > struct common_type_impl< unsigned short, unsigned char> { typedef int type; };
+template< > struct common_type_impl< char, unsigned short> { typedef int type; };
+template< > struct common_type_impl< unsigned short, char> { typedef int type; };
+
+} // namespace detail_type_traits_common_type
+
+
+} // namespace boost_ex
+
+#endif // BOOST_EX_TYPE_TRAITS_EXT_DETAIL_COMMON_TYPE_HPP

Added: branches/release/libs/ratio/index.html
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/index.html 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,15 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=../../doc/html/ratio.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+../../doc/html/ratio.html
+<p>&copy; Copyright 2009-2010 Vicente J. Botet Escrib&aacute;.
+Distributed under the Boost Software
+License, Version 1.0. (See accompanying file <a href="../../LICENSE_1_0.txt">
+LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+</body>
+</html>

Added: branches/release/libs/ratio/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/Jamfile.v2 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,119 @@
+# Boost Ratio Library test Jamfile
+
+# Copyright Beman Dawes 2003, 2006, 2008
+
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or
http://www.boost.org/LICENSE_1_0.txt
+
+# See library home page at http://www.boost.org/libs/ratio
+
+# uncomment one if the above lines if you build outside the Boost release
+#local BOOST_ROOT = /boost_1_41_0 ;
+#local BOOST_ROOT = c:/cygwin/boost_1_41_0 ;
+
+if ! $(BOOST_ROOT)
+{
+ BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
+}
+
+project
+ : requirements
+ #<os>LINUX:<threading>multi
+ # uncomment the line above if you build outside the Boost release
+ #<include>$(BOOST_ROOT)
+ # uncomment the line above if you build outside the Boost release
+ #<include>../../..
+ <toolset>msvc:<asynch-exceptions>on
+ <define>BOOST_ENABLE_WARNINGS
+ <define>BOOST_RATIO_USES_MPL_ASSERT
+ <define>BOOST_MPL_NEXT_PRIOR_EXT
+ <warnings>all
+ <toolset>gcc:<cxxflags>-Wextra
+ <toolset>gcc:<cxxflags>-Wno-long-long
+ <toolset>gcc:<cxxflags>-pedantic
+ <toolset>darwin:<cxxflags>-Wextra
+ <toolset>darwin:<cxxflags>-Wno-long-long
+ <toolset>darwin:<cxxflags>-pedantic
+ #<toolset>pathscale:<cxxflags>-Wextra
+ <toolset>pathscale:<cxxflags>-Wno-long-long
+ <toolset>pathscale:<cxxflags>-pedantic
+ <toolset>clang:<cxxflags>-Wextra
+ <toolset>clang:<cxxflags>-pedantic
+ <toolset>clang:<cxxflags>-Wno-long-long
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-missing-field-initializers
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
+ <toolset>gcc-mingw-4.6.0:<cxxflags>-fdiagnostics-show-option
+ <toolset>msvc:<cxxflags>/wd4127
+# Note: Some of the remarks from the Intel compiler are disabled
+# remark #1418: external function definition with no prior declaration
+# remark #304: access control not specified ("public" by default)
+ <toolset>intel:<cxxflags>-wd304,1418
+ ;
+
+ test-suite "ratio.ratio"
+ :
+ [ compile typedefs_pass.cpp ]
+ [ compile ratio_ratio/ratio_pass.cpp ]
+ [ compile-fail ratio_ratio/ratio1_fail.cpp ]
+ [ compile-fail ratio_ratio/ratio2_fail.cpp ]
+ [ compile-fail ratio_ratio/ratio3_fail.cpp ]
+ [ compile-fail ratio_ratio/ratio4_fail.cpp ]
+ ;
+
+ test-suite "ratio_io"
+ :
+ [ compile-fail ratio_io/ratio_io_fail.cpp ]
+ [ run ratio_io/ratio_io_pass.cpp ]
+ ;
+
+ test-suite "ratio.arithmetic"
+ :
+ [ compile ratio_arithmetic/ratio_add_pass.cpp ]
+ [ compile ratio_arithmetic/ratio_subtract_pass.cpp ]
+ [ compile ratio_arithmetic/ratio_multiply_pass.cpp ]
+ [ compile ratio_arithmetic/ratio_divide_pass.cpp ]
+ [ compile-fail ratio_arithmetic/ratio_add_fail.cpp ]
+ [ compile-fail ratio_arithmetic/ratio_add_2_fail.cpp ]
+ [ compile-fail ratio_arithmetic/ratio_add_3_fail.cpp ]
+ [ compile-fail ratio_arithmetic/ratio_subtract_fail.cpp ]
+ [ compile-fail ratio_arithmetic/ratio_multiply_fail.cpp ]
+ [ compile-fail ratio_arithmetic/ratio_divide_fail.cpp ]
+ ;
+
+ test-suite "ratio.comparison"
+ :
+ [ compile ratio_comparison/ratio_equal_pass.cpp ]
+ [ compile ratio_comparison/ratio_not_equal_pass.cpp ]
+ [ compile ratio_comparison/ratio_less_pass.cpp ]
+ [ compile ratio_comparison/ratio_less_equal_pass.cpp ]
+ [ compile ratio_comparison/ratio_greater_pass.cpp ]
+ [ compile ratio_comparison/ratio_greater_equal_pass.cpp ]
+ ;
+
+ test-suite "examples"
+ :
+ [ run ../example/si_physics.cpp ]
+ [ run ../example/display_ex.cpp ]
+ ;
+
+ test-suite "ratio.ext"
+ :
+ [ run ratio_extensions/ratio_ext_pass.cpp ]
+ [ compile ratio_extensions/mpl_plus_pass.cpp ]
+ [ compile ratio_extensions/mpl_minus_pass.cpp ]
+ [ compile ratio_extensions/mpl_times_pass.cpp ]
+ [ compile ratio_extensions/mpl_divides_pass.cpp ]
+ [ compile ratio_extensions/mpl_negate_pass.cpp ]
+ [ compile ratio_extensions/mpl_sign_pass.cpp ]
+ [ compile ratio_extensions/mpl_abs_pass.cpp ]
+ [ compile ratio_extensions/mpl_equal_to_pass.cpp ]
+ [ compile ratio_extensions/mpl_not_equal_to_pass.cpp ]
+ [ compile ratio_extensions/mpl_less_pass.cpp ]
+ [ compile ratio_extensions/mpl_less_equal_pass.cpp ]
+ [ compile ratio_extensions/mpl_greater_pass.cpp ]
+ [ compile ratio_extensions/mpl_greater_equal_pass.cpp ]
+ [ compile ratio_extensions/mpl_arithmetic_pass.cpp ]
+ [ compile ratio_extensions/mpl_comparison_pass.cpp ]
+ [ compile ratio_extensions/mpl_rational_constant_pass.cpp ]
+
+ ;

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_2_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_2_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+
+
+template <typename R>
+struct numerator;
+
+template <boost::intmax_t N, boost::intmax_t D>
+struct numerator<boost::ratio<N,D> > {
+ static const boost::intmax_t value = N;
+};
+
+
+BOOST_RATIO_STATIC_ASSERT((
+ numerator<boost::ratio_add<boost::ratio<1,2>,boost::ratio<1,3> > >::value == 1)
+ , NOTHING, ());

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_3_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_3_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+
+template <typename T, typename R>
+struct S {
+ T val;
+};
+
+boost::intmax_t func(S<int, boost::ratio<5,6> > const& s) {
+ return s.val*3;
+}
+
+
+boost::intmax_t test() {
+ return func(
+ S<int, boost::ratio_add<
+ boost::ratio<1,2>,
+ boost::ratio<1,3>
+ >
+ //~ ::type
+ >()
+ );
+}
+

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/integer_traits.hpp>
+
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+#define BOOST_RATIO_INTMAX_T_MAX boost::integer_traits<boost::intmax_t>::const_max
+
+typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+typedef boost::ratio<1, 1> R2;
+typedef boost::ratio_add<R1, R2>::type RT;
+
+BOOST_RATIO_STATIC_ASSERT(RT::num==BOOST_RATIO_INTMAX_T_MAX+1, NOTHING, (RT));
+BOOST_RATIO_STATIC_ASSERT(RT::den==1, NOTHING, (RT));

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_add
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 2 && R::den == 1, NOTHING, ());
+ typedef boost::ratio_add<R, R2> RR;
+ BOOST_RATIO_STATIC_ASSERT(RR::num == 3 && RR::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 127970191639601LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), 1> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_add<R1, R2>::type RT;
+ }
+
+}
+
+boost::intmax_t func(boost::ratio<5,6> s) {
+ return s.num;
+}
+
+
+boost::intmax_t test_conversion() {
+ return func(
+ boost::ratio_add<
+ boost::ratio<1,2>,
+ boost::ratio<1,3>
+ >
+ ()
+ );
+}
+

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_divide
+
+#include <boost/ratio/ratio.hpp>
+
+typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), 1> R1;
+typedef boost::ratio<1,2> R2;
+typedef boost::ratio_divide<R1, R2>::type RT;

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_divide_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_divide_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_divide
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 630992477165LL && R::den == 127339199162436LL, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_multiply
+
+#include <boost/ratio/ratio.hpp>
+
+typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), 1> R1;
+typedef boost::ratio<2,1> R2;
+typedef boost::ratio_multiply<R1, R2>::type RT;

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_multiply_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_multiply_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_multiply
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 15519594064236LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_subtract_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_subtract_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_subtract
+
+#include <boost/ratio/ratio.hpp>
+
+typedef boost::ratio<BOOST_RATIO_INTMAX_C(-0x7FFFFFFFFFFFFFFF), 1> R1;
+typedef boost::ratio<1,1> R2;
+typedef boost::ratio_subtract<R1, R2>::type RT;

Added: branches/release/libs/ratio/test/ratio_arithmetic/ratio_subtract_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_arithmetic/ratio_subtract_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_subtract
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -126708206685271LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_comparison/ratio_equal_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_comparison/ratio_equal_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_equal
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_equal<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_comparison/ratio_greater_equal_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_comparison/ratio_greater_equal_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1,BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1,BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater_equal<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_comparison/ratio_greater_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_comparison/ratio_greater_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_greater<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_comparison/ratio_less_equal_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_comparison/ratio_less_equal_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less_equal<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_comparison/ratio_less_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_comparison/ratio_less_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 0x7FFFFFFFFFFFFFFELL> R1;
+ typedef boost::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 0x7FFFFFFFFFFFFFFELL> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 0x7FFFFFFFFFFFFFFELL> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 0x7FFFFFFFFFFFFFFELL> R1;
+ typedef boost::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<641981, 1339063> R1;
+ typedef boost::ratio<1291640, 2694141LL> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1291640, 2694141LL> R1;
+ typedef boost::ratio<641981, 1339063> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_less<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_comparison/ratio_not_equal_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_comparison/ratio_not_equal_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_not_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_not_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_not_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::ratio_not_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_not_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_not_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_not_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio_not_equal<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_abs_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_abs_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test mpl::abs
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/abs.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<0> R1;
+ typedef boost::mpl::abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::mpl::abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::mpl::abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::mpl::abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::mpl::abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_arithmetic_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_arithmetic_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,13 @@
+//===----------------------------------------------------------------------===//
+// Copyright 2011 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/arithmetic.hpp>
+
+void test()
+{
+
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_comparison_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_comparison_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,13 @@
+//===----------------------------------------------------------------------===//
+// Copyright 2011 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/comparison.hpp>
+
+void test()
+{
+
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_divides_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_divides_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test mpl::divides
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/divides.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::divides<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::divides<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::divides<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::divides<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::mpl::divides<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::mpl::divides<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::mpl::divides<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 630992477165LL && R::den == 127339199162436LL, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_equal_to_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_equal_to_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test mpl::equal_to
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/equal_to.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_greater_equal_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_greater_equal_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/greater_equal.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1,BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1,BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater_equal<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_greater_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_greater_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/greater.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::greater<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::greater<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_less_equal_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_less_equal_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/less_equal.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less_equal<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less_equal<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_less_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_less_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/less.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 0x7FFFFFFFFFFFFFFELL> R1;
+ typedef boost::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 0x7FFFFFFFFFFFFFFELL> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 0x7FFFFFFFFFFFFFFELL> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 0x7FFFFFFFFFFFFFFELL> R1;
+ typedef boost::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<641981, 1339063> R1;
+ typedef boost::ratio<1291640, 2694141LL> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1291640, 2694141LL> R1;
+ typedef boost::ratio<641981, 1339063> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::less<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_minus_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_minus_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test mpl::minus
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/minus.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::minus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::minus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::minus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::minus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::mpl::minus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::mpl::minus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::mpl::minus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -126708206685271LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_negate_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_negate_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test mpl::negate
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/negate.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<0> R1;
+ typedef boost::mpl::negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::mpl::negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::mpl::negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::mpl::negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::mpl::negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_not_equal_to_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_not_equal_to_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/not_equal_to.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::not_equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::not_equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::not_equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((!boost::mpl::not_equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, -1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::not_equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::not_equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::not_equal_to<R1, R2>::value), NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
+ typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
+ BOOST_RATIO_STATIC_ASSERT((boost::mpl::not_equal_to<R1, R2>::value), NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_plus_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_plus_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test mpl::plus
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/plus.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::mpl::int_<1> R2;
+ typedef boost::mpl::plus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 2 && R::den == 1, NOTHING, ());
+ typedef boost::mpl::plus<R, R2> RR;
+ BOOST_RATIO_STATIC_ASSERT(RR::num == 3 && RR::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::mpl::int_<1> R1;
+ typedef boost::ratio<1, 2> R2;
+ typedef boost::mpl::plus<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::int_<0> R3;
+ typedef boost::mpl::plus<R1, R2, R3> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::int_<0> R3;
+ typedef boost::mpl::plus<R1, R2, R3> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::mpl::int_<0> R3;
+ typedef boost::mpl::plus<R1, R2, R3> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::mpl::int_<0> R3;
+ typedef boost::mpl::plus<R1, R2, R3> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::mpl::int_<0> R3;
+ typedef boost::mpl::plus<R1, R2, R3> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 127970191639601LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), 1> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::mpl::int_<0> R3;
+ typedef boost::mpl::plus<R1, R2, R3>::type RT;
+ }
+
+}
+
+boost::intmax_t func(boost::ratio<5,6> s) {
+ return s.num;
+}
+
+
+boost::intmax_t test_conversion() {
+ return func(
+ boost::mpl::plus<
+ boost::ratio<1,2>,
+ boost::ratio<1,3>
+ >
+ ()
+ );
+}
+

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_rational_constant_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_rational_constant_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,13 @@
+//===----------------------------------------------------------------------===//
+// Copyright 2011 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/comparison.hpp>
+
+void test()
+{
+
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_sign_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_sign_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test mpl::sign
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/sign.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<0> R1;
+ typedef boost::mpl::sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == 0, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::mpl::sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::mpl::sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::mpl::sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == -1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::mpl::sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == -1, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/mpl_times_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/mpl_times_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test mpl::times
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/mpl/times.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::times<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::times<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::times<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::mpl::times<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::mpl::times<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::mpl::times<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::mpl::times<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 15519594064236LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+}

Added: branches/release/libs/ratio/test/ratio_extensions/ratio_ext_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_extensions/ratio_ext_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,29 @@
+// Copyright 2011 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio: equivalent ratios convert with BOOST_RATIO_EXTENSIONS
+
+#define BOOST_RATIO_EXTENSIONS
+#include <boost/ratio/ratio.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::intmax_t func(boost::ratio<5,6> s);
+
+boost::intmax_t func(boost::ratio<5,6> s) {
+ return s.num;
+}
+
+void test();
+
+void test() {
+ boost::ratio<10,12> r;
+ BOOST_TEST((
+ func(r)==5
+ ));
+}
+
+int main()
+{
+ test();
+}

Added: branches/release/libs/ratio/test/ratio_io/ratio_io_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_io/ratio_io_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio_io.hpp>
+
+//typedef boost::ratio_string<boost::ratio_add<boost::ratio<1,2>, boost::ratio<1,3> >, char> R1;
+typedef boost::ratio_string<int, char> R1;
+
+void test() {
+
+ std::string str = R1::short_name();
+}

Added: branches/release/libs/ratio/test/ratio_io/ratio_io_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_io/ratio_io_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_add
+
+#include <boost/ratio/ratio_io.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <climits>
+
+int main()
+{
+
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::atto, char>::long_name() == "atto"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::atto, char>::short_name() == "a"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::femto, char>::long_name() == "femto"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::femto, char>::short_name() == "f"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::pico, char>::long_name() == "pico"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::pico, char>::short_name() == "p"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::nano, char>::long_name() == "nano"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::nano, char>::short_name() == "n"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::micro, char>::long_name() == "micro"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::micro, char>::short_name() == "\xC2\xB5"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::milli, char>::long_name() == "milli"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::milli, char>::short_name() == "m"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::centi, char>::long_name() == "centi"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::centi, char>::short_name() == "c"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::deci, char>::long_name() == "deci"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::deci, char>::short_name() == "d"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::deca, char>::long_name() == "deca"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::deca, char>::short_name() == "da"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::hecto, char>::long_name() == "hecto"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::hecto, char>::short_name() == "h"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::kilo, char>::long_name() == "kilo"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::kilo, char>::short_name() == "k"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::mega, char>::long_name() == "mega"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::mega, char>::short_name() == "M"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::giga, char>::long_name() == "giga"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::giga, char>::short_name() == "G"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::tera, char>::long_name() == "tera"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::tera, char>::short_name() == "T"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::peta, char>::long_name() == "peta"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::peta, char>::short_name() == "P"
+ ));
+ }
+ {
+ BOOST_TEST((
+ boost::ratio_string<boost::exa, char>::long_name() == "exa"
+ ));
+ BOOST_TEST((
+ boost::ratio_string<boost::exa, char>::short_name() == "E"
+ ));
+ }
+// return 1;
+ return boost::report_errors();
+}
+
+

Added: branches/release/libs/ratio/test/ratio_ratio/ratio1_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_ratio/ratio1_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio: The template argument D mus not be zero
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/cstdint.hpp>
+
+void test()
+{
+ const boost::intmax_t t1 = boost::ratio<1, 0>::num;
+ (void)t1;
+}

Added: branches/release/libs/ratio/test/ratio_ratio/ratio2_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_ratio/ratio2_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio: the absolute values of the template arguments N and D
+// must be representable by type intmax_t.
+
+#include <boost/ratio/ratio.hpp>
+#include <cstdint>
+
+void test()
+{
+ const boost::intmax_t t1 = boost::ratio<0x8000000000000000ULL, 1>::num;
+ (void)t1;
+}

Added: branches/release/libs/ratio/test/ratio_ratio/ratio3_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_ratio/ratio3_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio: the absolute values of the template arguments N and D
+// must be representable by type intmax_t.
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/cstdint.hpp>
+
+void test()
+{
+ const boost::intmax_t t1 = boost::ratio<1, 0x8000000000000000ULL>::num;
+ (void)t1;
+}

Added: branches/release/libs/ratio/test/ratio_ratio/ratio4_fail.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_ratio/ratio4_fail.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+//#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/ratio.hpp>
+
+boost::intmax_t func(boost::ratio<5,6> const& s) {
+ return s.num;
+}
+
+boost::intmax_t test() {
+ return func(boost::ratio<10,12>());
+}
+

Added: branches/release/libs/ratio/test/ratio_ratio/ratio_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_ratio/ratio_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio: The static data members num and den shall have thcommon
+// divisor of the absolute values of N and D:
+
+#include <boost/ratio/ratio.hpp>
+
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
+
+template <long long N, long long D, long long eN, long long eD>
+void test()
+{
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio<N, D>::num == eN), NOTHING, (boost::mpl::integral_c<boost::intmax_t,boost::ratio<N, D>::num>));
+ BOOST_RATIO_STATIC_ASSERT((boost::ratio<N, D>::den == eD), NOTHING, (boost::mpl::integral_c<boost::intmax_t,boost::ratio<N, D>::den>));
+}
+
+int main()
+{
+ test<1, 1, 1, 1>();
+ test<1, 10, 1, 10>();
+ test<10, 10, 1, 1>();
+ test<10, 1, 10, 1>();
+ test<12, 4, 3, 1>();
+ test<12, -4, -3, 1>();
+ test<-12, 4, -3, 1>();
+ test<-12, -4, 3, 1>();
+ test<4, 12, 1, 3>();
+ test<4, -12, -1, 3>();
+ test<-4, 12, -1, 3>();
+ test<-4, -12, 1, 3>();
+ test<222, 333, 2, 3>();
+ test<222, -333, -2, 3>();
+ test<-222, 333, -2, 3>();
+ test<-222, -333, 2, 3>();
+ test<BOOST_RATIO_INTMAX_T_MAX, 127, 72624976668147841LL, 1>();
+ test<-BOOST_RATIO_INTMAX_T_MAX, 127, -72624976668147841LL, 1>();
+ test<BOOST_RATIO_INTMAX_T_MAX, -127, -72624976668147841LL, 1>();
+ test<-BOOST_RATIO_INTMAX_T_MAX, -127, 72624976668147841LL, 1>();
+ //~ test<BOOST_RATIO_INTMAX_T_MAX, 127, BOOST_RATIO_INTMAX_T_MAX, 127>();
+ //~ test<-BOOST_RATIO_INTMAX_T_MAX, 127, -BOOST_RATIO_INTMAX_T_MAX, 127>();
+ //~ test<BOOST_RATIO_INTMAX_T_MAX, -127, -BOOST_RATIO_INTMAX_T_MAX, 127>();
+ //~ test<-BOOST_RATIO_INTMAX_T_MAX, -127, BOOST_RATIO_INTMAX_T_MAX, 127>();
+}

Added: branches/release/libs/ratio/test/ratio_test.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/ratio_test.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,36 @@
+// ratio_test.cpp ----------------------------------------------------------//
+
+// Copyright 2008 Howard Hinnant
+// Copyright 2008 Beman Dawes
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+#include <iostream>
+
+typedef boost::ratio<5, 3> five_thirds; // five_thirds::num == 5, five_thirds::den == 3
+typedef boost::ratio<25, 15> also_five_thirds; // also_five_thirds::num == 5, also_five_thirds::den == 3
+typedef boost::ratio_divide<five_thirds, also_five_thirds>::type one; // one::num == 1, one::den == 1
+
+
+typedef boost::ratio_multiply<boost::ratio<5>, boost::giga>::type _5giga; // _5giga::num == 5000000000, _5giga::den == 1
+typedef boost::ratio_multiply<boost::ratio<5>, boost::nano>::type _5nano; // _5nano::num == 1, _5nano::den == 200000000
+
+// Test the case described in library working group issue 948.
+
+typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFF0)> R1;
+typedef boost::ratio<8, 7> R2;
+typedef boost::ratio_multiply<R1, R2>::type RT;
+
+
+
+int main()
+{
+ typedef boost::ratio<8, BOOST_RATIO_INTMAX_C(0x7FFFFFFFD)> R1;
+ typedef boost::ratio<3, BOOST_RATIO_INTMAX_C(0x7FFFFFFFD)> R2;
+ typedef boost::ratio_subtract<R1, R2>::type RS;
+ std::cout << RS::num << '/' << RS::den << '\n';
+
+ return 0;
+}

Added: branches/release/libs/ratio/test/typedefs_pass.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/ratio/test/typedefs_pass.cpp 2011-03-21 13:17:54 EDT (Mon, 21 Mar 2011)
@@ -0,0 +1,29 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio typedef's
+
+#include <boost/ratio/ratio.hpp>
+
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+BOOST_RATIO_STATIC_ASSERT(boost::atto::num == 1 && boost::atto::den == 1000000000000000000ULL, NOTHING, (boost::mpl::integral_c<boost::intmax_t,boost::atto::den>));
+BOOST_RATIO_STATIC_ASSERT(boost::femto::num == 1 && boost::femto::den == 1000000000000000ULL, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::pico::num == 1 && boost::pico::den == 1000000000000ULL, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::nano::num == 1 && boost::nano::den == 1000000000ULL, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::micro::num == 1 && boost::micro::den == 1000000ULL, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::milli::num == 1 && boost::milli::den == 1000ULL, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::centi::num == 1 && boost::centi::den == 100ULL, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::deci::num == 1 && boost::deci::den == 10ULL, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::deca::num == 10ULL && boost::deca::den == 1, NOTHING, (boost::mpl::integral_c<boost::intmax_t,boost::deca::den>));
+BOOST_RATIO_STATIC_ASSERT(boost::hecto::num == 100ULL && boost::hecto::den == 1, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::kilo::num == 1000ULL && boost::kilo::den == 1, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::mega::num == 1000000ULL && boost::mega::den == 1, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::giga::num == 1000000000ULL && boost::giga::den == 1, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::tera::num == 1000000000000ULL && boost::tera::den == 1, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::peta::num == 1000000000000000ULL && boost::peta::den == 1, NOTHING, ());
+BOOST_RATIO_STATIC_ASSERT(boost::exa::num == 1000000000000000000ULL && boost::exa::den == 1, NOTHING, ());
+


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