diff --git a/doc/ratio.qbk b/doc/ratio.qbk index bfe9e5d..c57bbb9 100644 --- a/doc/ratio.qbk +++ b/doc/ratio.qbk @@ -9,13 +9,13 @@ [library Boost.Ratio [quickbook 1.5] - [version 1.0.1] + [version 2.0.0] [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] + [copyright 2009-2012 Vicente J. Botet Escriba] [category math] [id ratio] [dirname ratio] @@ -42,12 +42,14 @@ [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`]] +[def __BOOST_RATIO_USES_STATIC_ASSERT [link ratio.reference.config_hpp.assert `BOOST_RATIO_USES_STATIC_ASSERT`]] +[def __BOOST_RATIO_USES_MPL_ASSERT [link ratio.reference.config_hpp.assert `BOOST_RATIO_USES_MPL_ASSERT`]] +[def __BOOST_RATIO_USES_ARRAY_ASSERT [link ratio.reference.config_hpp.assert `BOOST_RATIO_USES_ARRAY_ASSERT`]] +[def __BOOST_RATIO_EXTENSIONS [link ratio.reference.config_hpp.ext `BOOST_RATIO_EXTENSIONS`]] +[def __BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0 [link ratio.reference.config_hpp.deprecated `BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0`]] +[def __BOOST_RATIO_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 [link ratio.reference.config_hpp.deprecated `BOOST_RATIO_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 `]] +[def __BOOST_RATIO_VERSION [link ratio.reference.config_hpp.version `BOOST_RATIO_VERSION `]] [template ratio_arithmetic[link_text] [link ratio.reference.std.ratio_hpp.ratio_arithmetic [link_text]]] @@ -313,7 +315,7 @@ This facility also includes convenience typedefs for the SI prefixes __atto thro [heading Ratio I/O] -For each `ratio` there exists a `ratio_string, 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`. For example `ratio_string::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`. For example, `ratio_string::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`]". +For each `ratio` there exists a `ratio_string, CharT>` for which you can query two strings: `symbol` and `prefix`. For those `ratio`'s that correspond to an [@http://en.wikipedia.org/wiki/SI_prefix#List_of_SI_prefixes SI prefix] prefix corresponds to the internationally recognized prefix, stored as a `basic_string`. For example `ratio_string::prefix()` returns `string("mega")`. For those `ratio`s that correspond to an [@http://en.wikipedia.org/wiki/SI_prefix#List_of_SI_prefixes SI prefix] `symbol` corresponds to the internationally recognized symbol, stored as a `basic_string`. For example, `ratio_string::symbol()` returns `string("M")`. For all other `ratio`s, both `prefix()` and `symbol()` return a `basic_string` containing "[`ratio::num/ratio::den`]". `ratio_string, CharT>` is only defined for four character types: @@ -324,7 +326,7 @@ For each `ratio` there exists a `ratio_string, CharT>` for whi 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. +The `symbol` (Greek mu or [mu]) for micro is defined by [@http://www.unicode.org/charts/PDF/U0080.pdf Unicode] to be U+00B5. [*Examples:] @@ -336,30 +338,30 @@ The `short_name` (Greek mu or [mu]) for micro is defined by [@http://www.unicode using namespace std; using namespace boost; - cout << "ratio_string::long_name() = " - << ratio_string::long_name() << '\n'; - cout << "ratio_string::short_name() = " - << ratio_string::short_name() << '\n'; + cout << "ratio_string::prefix() = " + << ratio_string::prefix() << '\n'; + cout << "ratio_string::symbol() = " + << ratio_string::symbol() << '\n'; - cout << "ratio_string::long_name() = " - << ratio_string::long_name() << '\n'; - cout << "ratio_string::short_name() = " - << ratio_string::short_name() << '\n'; + cout << "ratio_string::prefix() = " + << ratio_string::prefix() << '\n'; + cout << "ratio_string::symbol() = " + << ratio_string::symbol() << '\n'; - cout << "ratio_string, char>::long_name() = " - << ratio_string, char>::long_name() << '\n'; - cout << "ratio_string, char>::short_name() = " - << ratio_string, char>::short_name() << '\n'; + cout << "ratio_string, char>::prefix() = " + << ratio_string, char>::prefix() << '\n'; + cout << "ratio_string, char>::symbol() = " + << ratio_string, char>::symbol() << '\n'; } The output will be - ratio_string::long_name() = deca - ratio_string::short_name() = da - ratio_string::long_name() = giga - ratio_string::short_name() = G - ratio_string, char>::long_name() = [2/3] - ratio_string, char>::short_name() = [2/3] + ratio_string::prefix() = deca + ratio_string::symbol() = da + ratio_string::prefix() = giga + ratio_string::symbol() = G + ratio_string, char>::prefix() = [2/3] + ratio_string, char>::symbol() = [2/3] [heading Ratio MPL Numeric Metafunctions] @@ -641,6 +643,68 @@ Finally, we can exercise what we've created, even using custom time durations (` [section:reference Reference ] [/=================] +[/=================================================] +[section:config_hpp Header ``] +[/=================================================] + + + // Configuration macros + #define __BOOST_RATIO_VERSION + #define __BOOST_RATIO_EXTENSIONS + #define __BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0 + #define __BOOST_RATIO_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 + #define __BOOST_RATIO_USES_STATIC_ASSERT + #define __BOOST_RATIO_USES_MPL_ASSERT + #define __BOOST_RATIO_USES_ARRAY_ASSERT + + +[section:ext Extensions] + +When __BOOST_RATIO_EXTENSIONS is defined, __Boost_Ratio provides in addition some extension to the C++ standard, see below. + +[endsect] +[section:deprecated Deprecated] + +When __BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0 is defined the deprecated features stated as DEPRECATED V2 are provided. + +When __BOOST_RATIO_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 is defined the deprecated features stated as DEPRECATED V2 are NOT provided. + +[endsect] +[section:version Version] + +__BOOST_RATIO_VERSION stands for the Boost.Ratio version which can be 1 or 2. The default up to 1.55 is version 1. Since 1.56 it will be 2. + +When __BOOST_RATIO_VERSION is 1 __BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0 is defined by default. + +When __BOOST_RATIO_VERSION is 2 __BOOST_RATIO_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 is defined by default. + +[endsect] +[section:assert Static Assert] + +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_ARRAY_ASSERT to use __Boost_Ratio internal static assertions. + +The default behavior is as if __BOOST_RATIO_USES_ARRAY_ASSERT was 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. + + +[endsect] +[endsect] + [/=================================================] [section:std C++0x Recommendation] [/=================================================] @@ -707,46 +771,13 @@ This header provides forward declarations for the `` file [endsect] + [/=================================================] [section:ratio_hpp Header ``] [/=================================================] __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 @@ -756,7 +787,7 @@ When BOOST_RATIO_EXTENSIONS is defined, __Boost_Ratio provides in addition some static const boost::intmax_t den; typedef ratio type; - #ifdef BOOST_RATIO_EXTENSIONS + #ifdef __BOOST_RATIO_EXTENSIONS typedef mpl::rational_c_tag tag; typedef boost::rational value_type; typedef boost::intmax_t num_type; @@ -790,7 +821,7 @@ Two __ratio classes `__ratio` and `__ratio` have the same normaliz [section:ca Construction and Assignment] -Included only if BOOST_RATIO_EXTENSIONS is defined. +Included only if __BOOST_RATIO_EXTENSIONS is defined. [heading Default Constructor] @@ -822,7 +853,7 @@ Included only if BOOST_RATIO_EXTENSIONS is defined. [section:mpl MPL Numeric Metafunctions] -Included only if BOOST_RATIO_EXTENSIONS is defined. +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: @@ -834,7 +865,7 @@ In order to work with [*Boost.MPL] numeric metafunctions as a __Rational_Constan [section:obs Observers] -Included only if BOOST_RATIO_EXTENSIONS is defined. +Included only if __BOOST_RATIO_EXTENSIONS is defined. static value_type value(); value_type operator()() const; @@ -1031,14 +1062,236 @@ When __BOOST_RATIO_EXTENSIONS is defined __Boost_Ratio provides the following ex 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 struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + template <> struct ratio_string; + } + +[section:ratio_string Template Class `ratio_string<>`] + template struct ratio_string { - static std::basic_string short_name(); - static std::basic_string long_name(); + static std::basic_string symbol(); + static std::basic_string prefix(); + static std::basic_string short_name(); // DEPRECATED V2 + static std::basic_string long_name(); // DEPRECATED V2 }; - } +The class template ratio_string provides textual representations of the associated ratio appropriate for the character type charT. + +The primary template provides generic strings. Specializations provide the same static member functions but these functions return the English SI prefix and symbol names as specified by the General Conference on Weights and Measures. + +[section:prefix Static Member function `prefix()`] + + template + basic_string + ratio_string::prefix(); + +[*Returns]: A basic_string of the form: [Ratio::num/Ratio::den] + +[*Example]: `ratio_string, wchar_t>::prefix()` returns `L"[1/30]"`. + +[endsect] + +[section:symbol Static Member function `symbol()`] + + template + basic_string + ratio_string::symbol(); + +[*Returns]: prefix(). + + +[endsect] +[section:long_name Static Member function `long_name()` DEPRECATED V2] + + template + basic_string + ratio_string::long_name(); + +[*Returns]: prefix(). + +[endsect] +[section:short_name Static Member function `short_name()` DEPRECATED V2] + + template + basic_string + ratio_string::short_name(); + +[*Returns]: symbol(). + +[endsect] +[endsect] + + +[section:spe Specializations for `ratio_string<>`] + +For each specialization the table gives the return value for `prefix()` and `symbol()`. + +[table The return values of specializations of ratio_string + [[Specialization][`prefix()`] [`symbol()`]] + [[`ratio_string`][`"atto"`] [`"a"`]] + [[`ratio_string`][`u"atto"`] [`u"a"`]] + [[`ratio_string`][`U"atto"`] [`U"a"`]] + [[`ratio_string`][`L"atto"`] [`L"a"`]] + + [[`ratio_string`][`"femto"`] [`"f"`]] + [[`ratio_string`][`u"femto"`] [`u"f"`]] + [[`ratio_string`][`U"femto"`] [`U"f"`]] + [[`ratio_string`][`L"femto"`] [`L"f"`]] + + [[`ratio_string`][`"pico"`] [`"p"`]] + [[`ratio_string`][`u"pico"`] [`u"p"`]] + [[`ratio_string`][`U"pico"`] [`U"p"`]] + [[`ratio_string`][`L"pico"`] [`L"p"`]] + + [[`ratio_string`][`"nano"`] [`"a"`]] + [[`ratio_string`][`u"nano"`] [`u"a"`]] + [[`ratio_string`][`U"nano"`] [`U"a"`]] + [[`ratio_string`][`L"nano"`] [`L"a"`]] + + [[`ratio_string`][`"micro"`] [`u8"\u00B5"`]] + [[`ratio_string`][`u"micro"`] [`u"\u00B5"`]] + [[`ratio_string`][`U"micro"`] [`U"\u00B5"`]] + [[`ratio_string`][`L"micro"`] [`Lu8"\u00B5"`]] + + [[`ratio_string`][`"milli"`] [`"m"`]] + [[`ratio_string`][`u"milli"`] [`u"m"`]] + [[`ratio_string`][`U"milli"`] [`U"m"`]] + [[`ratio_string`][`L"milli"`] [`L"m"`]] + + [[`ratio_string`][`"centi"`] [`"c"`]] + [[`ratio_string`][`u"centi"`] [`u"c"`]] + [[`ratio_string`][`U"centi"`] [`U"c"`]] + [[`ratio_string`][`L"centi"`] [`L"c"`]] + + [[`ratio_string`][`"deci"`] [`"d"`]] + [[`ratio_string`][`u"deci"`] [`u"d"`]] + [[`ratio_string`][`U"deci"`] [`U"d"`]] + [[`ratio_string`][`L"deci"`] [`L"d"`]] + + [[`ratio_string`][`"deca"`] [`"da"`]] + [[`ratio_string`][`u"deca"`] [`u"da"`]] + [[`ratio_string`][`U"deca"`] [`U"da"`]] + [[`ratio_string`][`L"deca"`] [`L"da"`]] + + [[`ratio_string`][`"hecto"`] [`"h"`]] + [[`ratio_string`][`u"hecto"`] [`u"h"`]] + [[`ratio_string`][`U"hecto"`] [`U"h"`]] + [[`ratio_string`][`L"hecto"`] [`L"h"`]] + + [[`ratio_string`][`"kilo"`] [`"k"`]] + [[`ratio_string`][`u"kilo"`] [`u"k"`]] + [[`ratio_string`][`U"kilo"`] [`U"k"`]] + [[`ratio_string`][`L"kilo"`] [`L"k"`]] + + [[`ratio_string`][`"mega"`] [`"M"`]] + [[`ratio_string`][`u"mega"`] [`u"M"`]] + [[`ratio_string`][`U"mega"`] [`U"M"`]] + [[`ratio_string`][`L"mega"`] [`L"M"`]] + + [[`ratio_string`][`"giga"`] [`"G"`]] + [[`ratio_string`][`u"giga"`] [`u"G"`]] + [[`ratio_string`][`U"giga"`] [`U"G"`]] + [[`ratio_string`][`L"giga"`] [`L"G"`]] + + [[`ratio_string`][`"tera"`] [`"T"`]] + [[`ratio_string`][`u"tera"`] [`u"T"`]] + [[`ratio_string`][`U"tera"`] [`U"T"`]] + [[`ratio_string`][`L"tera"`] [`L"T"`]] + + [[`ratio_string`][`"peta"`] [`"P"`]] + [[`ratio_string`][`u"peta"`] [`u"P"`]] + [[`ratio_string`][`U"peta"`] [`U"P"`]] + [[`ratio_string`][`L"peta"`] [`L"P"`]] + + [[`ratio_string`][`"exa"`] [`"E"`]] + [[`ratio_string`][`u"exa"`] [`u"E"`]] + [[`ratio_string`][`U"exa"`] [`U"E"`]] + [[`ratio_string`][`L"exa"`] [`L"E"`]] + +] + +[endsect] [endsect] [endsect] [section:mpl Rational Constant] @@ -1596,6 +1849,18 @@ The specialization relays on the __ratio_greater_equal template class. [section:history Appendix A: History] [/==================================] +[section [*Version 2.0.0, November 1, 2012 - 1.52] ] + +[*Features:] + +* [@http://svn.boost.org/trac/boost/ticket/XXXX #XXXX] Replace the short_name and long_name functions by symbol and prefix functions respectively. + +[*Deprecated:] + +The ratio_string<>::short_name and ratio_string<>::long_name are deprecated. Use ratio_string<>::symbol and ratio_string<>::prefix respectively. These functions be removed in 1.55. + +[endsect] + [section [*Version 1.0.3, August 1, 2012 - 1.51] ] [*Fixes:] diff --git a/example/display_ex.cpp b/example/display_ex.cpp index 1bebd43..7627371 100644 --- a/example/display_ex.cpp +++ b/example/display_ex.cpp @@ -19,21 +19,21 @@ int main() using namespace std; using namespace boost; - cout << "ratio_string::long_name() = " - << ratio_string::long_name() << '\n'; - cout << "ratio_string::short_name() = " - << ratio_string::short_name() << '\n'; + cout << "ratio_string::prefix() = " + << ratio_string::prefix() << '\n'; + cout << "ratio_string::symbol() = " + << ratio_string::symbol() << '\n'; - cout << "ratio_string::long_name() = " - << ratio_string::long_name() << '\n'; - cout << "ratio_string::short_name() = " - << ratio_string::short_name() << '\n'; + cout << "ratio_string::prefix() = " + << ratio_string::prefix() << '\n'; + cout << "ratio_string::symbol() = " + << ratio_string::symbol() << '\n'; + + cout << "ratio_string, char>::prefix() = " + << ratio_string, char>::prefix() << '\n'; + cout << "ratio_string, char>::symbol() = " + << ratio_string, char>::symbol() << '\n'; - cout << "ratio_string, char>::long_name() = " - << ratio_string, char>::long_name() << '\n'; - cout << "ratio_string, char>::short_name() = " - << ratio_string, char>::short_name() << '\n'; - return 0; } diff --git a/example/duration.hpp b/example/duration.hpp index d7f6b20..48bb5f3 100644 --- a/example/duration.hpp +++ b/example/duration.hpp @@ -72,7 +72,7 @@ time2_demo contained this comment: namespace boost_ex { using boost::ratio; - + namespace chrono { template > @@ -387,22 +387,22 @@ namespace chrono { struct chrono_numeric_limits { static T lowest() throw() {return (std::numeric_limits::min) ();} }; - + template struct chrono_numeric_limits { static T lowest() throw() {return (std::numeric_limits::min) ();} }; - + template <> struct chrono_numeric_limits { static float lowest() throw() {return -(std::numeric_limits::max) ();} }; - + template <> struct chrono_numeric_limits { static double lowest() throw() {return -(std::numeric_limits::max) ();} }; - + template <> struct chrono_numeric_limits { static long double lowest() throw() {return -(std::numeric_limits::max)();} @@ -410,14 +410,14 @@ namespace chrono { template struct numeric_limits : chrono_numeric_limits::type> {}; - - } + + } template struct duration_values { static Rep zero() {return Rep(0);} static Rep max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (std::numeric_limits::max)();} - + static Rep min BOOST_PREVENT_MACRO_SUBSTITUTION () {return detail::numeric_limits::lowest();} }; @@ -443,7 +443,7 @@ struct common_type, //----------------------------------------------------------------------------// namespace boost_ex { - + namespace chrono { template @@ -465,11 +465,11 @@ namespace chrono { #if (defined(BOOST_MSVC) && (BOOST_MSVC == 1500)) || defined(__IBMCPP__) #else , typename boost::enable_if < - boost::mpl::and_ < + boost::mpl::and_ < boost::is_convertible, boost::mpl::or_ < treat_as_floating_point, - boost::mpl::and_ < + boost::mpl::and_ < boost::mpl::not_ < treat_as_floating_point >, boost::mpl::not_ < treat_as_floating_point > > @@ -493,9 +493,9 @@ namespace chrono { #if (defined(BOOST_MSVC) && (BOOST_MSVC == 1500)) || defined(__IBMCPP__) #else , typename boost::enable_if < - boost::mpl::or_ < + boost::mpl::or_ < treat_as_floating_point, - boost::mpl::and_ < + boost::mpl::and_ < boost::mpl::bool_ < boost::ratio_divide::type::den == 1>, boost::mpl::not_ < treat_as_floating_point > > @@ -580,13 +580,13 @@ namespace chrono { duration::type, Period> #else typename boost::enable_if < - boost::mpl::and_ < - boost::is_convertible::type>, + boost::mpl::and_ < + boost::is_convertible::type>, boost::is_convertible::type> >, duration::type, Period> >::type -#endif +#endif operator*(const duration& d, const Rep2& s) { typedef typename boost::common_type::type CR; @@ -601,13 +601,13 @@ typename boost::enable_if < duration::type, Period> #else typename boost::enable_if < - boost::mpl::and_ < + boost::mpl::and_ < boost::is_convertible::type>, boost::is_convertible::type> >, duration::type, Period> >::type -#endif +#endif operator*(const Rep1& s, const duration& d) { return d * s; @@ -788,12 +788,12 @@ typename boost::enable_if < ToDuration #else typename boost::enable_if , ToDuration>::type -#endif +#endif duration_cast(const duration& fd) { return boost_ex::chrono::detail::duration_cast, ToDuration>()(fd); } -} +} } #endif // BOOST_EX_CHRONO_DURATION_HPP diff --git a/include/boost/ratio/config.hpp b/include/boost/ratio/config.hpp new file mode 100644 index 0000000..68b2b8b --- /dev/null +++ b/include/boost/ratio/config.hpp @@ -0,0 +1,75 @@ +// config.hpp ---------------------------------------------------------------// + +// Copyright 2012 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_RATIO_CONFIG_HPP +#define BOOST_RATIO_CONFIG_HPP + +#include +#include + +#if !defined BOOST_RATIO_VERSION +#define BOOST_RATIO_VERSION 1 +#else +#if BOOST_RATIO_VERSION!=1 && BOOST_RATIO_VERSION!=2 +#error "BOOST_RATIO_VERSION must be 1 or 2" +#endif +#endif + +#if BOOST_RATIO_VERSION==1 +#if ! defined BOOST_RATIO_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 +#define BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0 +#endif +#endif + +#if BOOST_RATIO_VERSION==2 +#if ! defined BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0 +#define BOOST_RATIO_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 +#endif +#endif + +#ifdef INTMAX_C +#define BOOST_RATIO_INTMAX_C(a) INTMAX_C(a) +#else +#define BOOST_RATIO_INTMAX_C(a) a##LL +#endif + +#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFELL) + + +#ifndef BOOST_NO_CXX11_STATIC_ASSERT +#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG) +#elif defined(BOOST_RATIO_USES_STATIC_ASSERT) +#include +#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND) +#elif defined(BOOST_RATIO_USES_MPL_ASSERT) +#include +#include +#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) \ + BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES) +#else +//~ #elif defined(BOOST_RATIO_USES_ARRAY_ASSERT) +#define BOOST_RATIO_CONCAT(A,B) A##B +#define BOOST_RATIO_NAME(A,B) BOOST_RATIO_CONCAT(A,B) +#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) static char BOOST_RATIO_NAME(__boost_ratio_test_,__LINE__)[(CND)?1:-1] +//~ #define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) +#endif + +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) || !defined(BOOST_RATIO_USES_MPL_ASSERT) +#define BOOST_RATIO_OVERFLOW_IN_ADD "overflow in ratio add" +#define BOOST_RATIO_OVERFLOW_IN_SUB "overflow in ratio sub" +#define BOOST_RATIO_OVERFLOW_IN_MUL "overflow in ratio mul" +#define BOOST_RATIO_OVERFLOW_IN_DIV "overflow in ratio div" +#define BOOST_RATIO_NUMERATOR_IS_OUT_OF_RANGE "ratio numerator is out of range" +#define BOOST_RATIO_DIVIDE_BY_0 "ratio divide by 0" +#define BOOST_RATIO_DENOMINATOR_IS_OUT_OF_RANGE "ratio denominator is out of range" +#endif + + +//#define BOOST_RATIO_EXTENSIONS + +#endif // header diff --git a/include/boost/ratio/detail/overflow_helpers.hpp b/include/boost/ratio/detail/overflow_helpers.hpp index a95467f..0e292fa 100644 --- a/include/boost/ratio/detail/overflow_helpers.hpp +++ b/include/boost/ratio/detail/overflow_helpers.hpp @@ -32,6 +32,7 @@ time2_demo contained this comment: #ifndef BOOST_RATIO_DETAIL_RATIO_OPERATIONS_HPP #define BOOST_RATIO_DETAIL_RATIO_OPERATIONS_HPP +#include #include #include #include @@ -42,35 +43,6 @@ time2_demo contained this comment: #include #include -#if !defined(BOOST_NO_STATIC_ASSERT) || !defined(BOOST_RATIO_USES_MPL_ASSERT) -#define BOOST_RATIO_OVERFLOW_IN_ADD "overflow in ratio add" -#define BOOST_RATIO_OVERFLOW_IN_SUB "overflow in ratio sub" -#define BOOST_RATIO_OVERFLOW_IN_MUL "overflow in ratio mul" -#define BOOST_RATIO_OVERFLOW_IN_DIV "overflow in ratio div" -#define BOOST_RATIO_NUMERATOR_IS_OUT_OF_RANGE "ratio numerator is out of range" -#define BOOST_RATIO_DIVIDE_BY_0 "ratio divide by 0" -#define BOOST_RATIO_DENOMINATOR_IS_OUT_OF_RANGE "ratio denominator is out of range" -#endif - -#ifndef BOOST_NO_STATIC_ASSERT -#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG) -#elif defined(BOOST_RATIO_USES_STATIC_ASSERT) -#include -#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND) -#elif defined(BOOST_RATIO_USES_MPL_ASSERT) -#include -#include -#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) \ - BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES) -#else -//~ #elif defined(BOOST_RATIO_USES_ARRAY_ASSERT) -#define BOOST_RATIO_CONCAT(A,B) A##B -#define BOOST_RATIO_NAME(A,B) BOOST_RATIO_CONCAT(A,B) -#define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) static char BOOST_RATIO_NAME(__boost_ratio_test_,__LINE__)[(CND)?1:-1] -//~ #define BOOST_RATIO_STATIC_ASSERT(CND, MSG, TYPES) -#endif - - // // We simply cannot include this header on gcc without getting copious warnings of the kind: // @@ -273,7 +245,7 @@ namespace ratio_detail > >::type type; }; - + template struct ratio_subtract > { @@ -322,7 +294,7 @@ namespace ratio_detail ((R2::num / gcd_n1_n2 ==1) && (R1::den / gcd_d1_d2)==1) > type; }; - + template struct is_ratio : public boost::false_type {}; diff --git a/include/boost/ratio/detail/ratio_io.hpp b/include/boost/ratio/detail/ratio_io.hpp new file mode 100644 index 0000000..87044e2 --- /dev/null +++ b/include/boost/ratio/detail/ratio_io.hpp @@ -0,0 +1,1043 @@ +// ratio_io +// +// (C) Copyright Howard Hinnant +// (C) Copyright 2010 Vicente J. Botet Escriba +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// This code was adapted by Vicente from Howard Hinnant's experimental work +// on chrono i/o under lvm/libc++ to Boost + +#ifndef BOOST_RATIO_DETAIL_RATIO_IO_HPP +#define BOOST_RATIO_DETAIL_RATIO_IO_HPP + +/* + + ratio_io synopsis + +#include +#include + +namespace boost +{ + +template +struct ratio_string +{ + static basic_string short_name(); + static basic_string long_name(); +}; + +} // boost + +*/ + +#include +#include +#include +#include +#include + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +#include +#include +#endif + +#if defined(BOOST_NO_CXX11_UNICODE_LITERALS) || defined(BOOST_NO_CXX11_CHAR16_T) || defined(BOOST_NO_CXX11_CHAR32_T) +//~ #define BOOST_RATIO_HAS_UNICODE_SUPPORT +#else +#define BOOST_RATIO_HAS_UNICODE_SUPPORT 1 +#endif + +namespace boost { + +//template +//struct ratio_string_is_localizable : false_type {}; +//template +//struct ratio_string_id : integral_constant {}; + +template +struct ratio_string +{ + static std::basic_string short_name() {return long_name();} + static std::basic_string long_name(); + static std::basic_string symbol() {return short_name();} + static std::basic_string prefix() {return long_name();} +}; + +template +std::basic_string +ratio_string::long_name() +{ + std::basic_ostringstream os; + os << CharT('[') << Ratio::num << CharT('/') + << Ratio::den << CharT(']'); + return os.str(); +} + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +namespace ratio_detail { +template +struct ratio_string_static +{ + static std::string short_name() { + return std::basic_string( + static_string::c_str< + typename ratio_static_string::short_name + >::value); + } + static std::string long_name() { + return std::basic_string( + static_string::c_str< + typename ratio_static_string::long_name + >::value); + } + static std::basic_string symbol() {return short_name();} + static std::basic_string prefix() {return long_name();} +}; +} +#endif +// atto +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'a');} + static std::string long_name() {return std::string("atto");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'a');} + static std::u16string long_name() {return std::u16string(u"atto");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'a');} + static std::u32string long_name() {return std::u32string(U"atto");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'a');} + static std::wstring long_name() {return std::wstring(L"atto");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// femto + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else + +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'f');} + static std::string long_name() {return std::string("femto");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'f');} + static std::u16string long_name() {return std::u16string(u"femto");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'f');} + static std::u32string long_name() {return std::u32string(U"femto");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'f');} + static std::wstring long_name() {return std::wstring(L"femto");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// pico + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'p');} + static std::string long_name() {return std::string("pico");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'p');} + static std::u16string long_name() {return std::u16string(u"pico");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'p');} + static std::u32string long_name() {return std::u32string(U"pico");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'p');} + static std::wstring long_name() {return std::wstring(L"pico");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// nano + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'n');} + static std::string long_name() {return std::string("nano");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'n');} + static std::u16string long_name() {return std::u16string(u"nano");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'n');} + static std::u32string long_name() {return std::u32string(U"nano");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'n');} + static std::wstring long_name() {return std::wstring(L"nano");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// micro + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string("\xC2\xB5");} + static std::string long_name() {return std::string("micro");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'\xB5');} + static std::u16string long_name() {return std::u16string(u"micro");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'\xB5');} + static std::u32string long_name() {return std::u32string(U"micro");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'\xB5');} + static std::wstring long_name() {return std::wstring(L"micro");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// milli + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'm');} + static std::string long_name() {return std::string("milli");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'm');} + static std::u16string long_name() {return std::u16string(u"milli");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'm');} + static std::u32string long_name() {return std::u32string(U"milli");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'm');} + static std::wstring long_name() {return std::wstring(L"milli");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// centi + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'c');} + static std::string long_name() {return std::string("centi");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'c');} + static std::u16string long_name() {return std::u16string(u"centi");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'c');} + static std::u32string long_name() {return std::u32string(U"centi");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'c');} + static std::wstring long_name() {return std::wstring(L"centi");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// deci + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else + +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'd');} + static std::string long_name() {return std::string("deci");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'd');} + static std::u16string long_name() {return std::u16string(u"deci");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'd');} + static std::u32string long_name() {return std::u32string(U"deci");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'd');} + static std::wstring long_name() {return std::wstring(L"deci");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// unit + +//template <> +//struct ratio_string_is_localizable > : true_type {}; +// +//template <> +//struct ratio_string_id > : integral_constant {}; +// deca + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string("da");} + static std::string long_name() {return std::string("deca");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(u"da");} + static std::u16string long_name() {return std::u16string(u"deca");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(U"da");} + static std::u32string long_name() {return std::u32string(U"deca");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(L"da");} + static std::wstring long_name() {return std::wstring(L"deca");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// hecto + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'h');} + static std::string long_name() {return std::string("hecto");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'h');} + static std::u16string long_name() {return std::u16string(u"hecto");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'h');} + static std::u32string long_name() {return std::u32string(U"hecto");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'h');} + static std::wstring long_name() {return std::wstring(L"hecto");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// kilo + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'k');} + static std::string long_name() {return std::string("kilo");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'k');} + static std::u16string long_name() {return std::u16string(u"kilo");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'k');} + static std::u32string long_name() {return std::u32string(U"kilo");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'k');} + static std::wstring long_name() {return std::wstring(L"kilo");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// mega + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else + +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'M');} + static std::string long_name() {return std::string("mega");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'M');} + static std::u16string long_name() {return std::u16string(u"mega");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'M');} + static std::u32string long_name() {return std::u32string(U"mega");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'M');} + static std::wstring long_name() {return std::wstring(L"mega");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// giga + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else + +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'G');} + static std::string long_name() {return std::string("giga");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'G');} + static std::u16string long_name() {return std::u16string(u"giga");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'G');} + static std::u32string long_name() {return std::u32string(U"giga");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'G');} + static std::wstring long_name() {return std::wstring(L"giga");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// tera + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'T');} + static std::string long_name() {return std::string("tera");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'T');} + static std::u16string long_name() {return std::u16string(u"tera");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'T');} + static std::u32string long_name() {return std::u32string(U"tera");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'T');} + static std::wstring long_name() {return std::wstring(L"tera");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// peta + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'P');} + static std::string long_name() {return std::string("peta");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'P');} + static std::u16string long_name() {return std::u16string(u"peta");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'P');} + static std::u32string long_name() {return std::u32string(U"peta");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'P');} + static std::wstring long_name() {return std::wstring(L"peta");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +// exa + +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; + +#ifdef BOOST_RATIO_HAS_STATIC_STRING +template +struct ratio_string : + ratio_detail::ratio_string_static +{}; + +#else +template <> +struct ratio_string +{ + static std::string short_name() {return std::string(1, 'E');} + static std::string long_name() {return std::string("exa");} + static std::string symbol() {return short_name();} + static std::string prefix() {return long_name();} +}; + +#if BOOST_RATIO_HAS_UNICODE_SUPPORT + +template <> +struct ratio_string +{ + static std::u16string short_name() {return std::u16string(1, u'E');} + static std::u16string long_name() {return std::u16string(u"exa");} + static std::u16string symbol() {return short_name();} + static std::u16string prefix() {return long_name();} +}; + +template <> +struct ratio_string +{ + static std::u32string short_name() {return std::u32string(1, U'E');} + static std::u32string long_name() {return std::u32string(U"exa");} + static std::u32string symbol() {return short_name();} + static std::u32string prefix() {return long_name();} +}; + +#endif + +#ifndef BOOST_NO_STD_WSTRING +template <> +struct ratio_string +{ + static std::wstring short_name() {return std::wstring(1, L'E');} + static std::wstring long_name() {return std::wstring(L"exa");} + static std::wstring symbol() {return short_name();} + static std::wstring prefix() {return long_name();} +}; +#endif +#endif + +} + +#endif // BOOST_RATIO_RATIO_IO_HPP diff --git a/include/boost/ratio/ratio.hpp b/include/boost/ratio/ratio.hpp index 2e17468..546e8f0 100644 --- a/include/boost/ratio/ratio.hpp +++ b/include/boost/ratio/ratio.hpp @@ -32,7 +32,7 @@ time2_demo contained this comment: #ifndef BOOST_RATIO_RATIO_HPP #define BOOST_RATIO_RATIO_HPP -#include +#include #include #include #include @@ -46,7 +46,7 @@ time2_demo contained this comment: #include #include #include -#ifdef BOOST_RATIO_EXTENSIONS +#ifdef BOOST_RATIO_EXTENSIONS #include #include #endif @@ -72,7 +72,7 @@ namespace boost // 20.6.1 Class template ratio [ratio.ratio] // // // //----------------------------------------------------------------------------// - + template class ratio { @@ -88,12 +88,12 @@ public: BOOST_STATIC_CONSTEXPR boost::intmax_t num = SIGN_N * ABS_N / GCD; BOOST_STATIC_CONSTEXPR boost::intmax_t den = ABS_D / GCD; -#ifdef BOOST_RATIO_EXTENSIONS +#ifdef BOOST_RATIO_EXTENSIONS typedef mpl::rational_c_tag tag; typedef boost::rational value_type; typedef boost::intmax_t num_type; typedef boost::intmax_t den_type; - ratio() + ratio() {} template ratio(const ratio<_N2, _D2>&, @@ -101,7 +101,7 @@ public: < (ratio<_N2, _D2>::num == num && ratio<_N2, _D2>::den == den) - >::type* = 0) + >::type* = 0) {} template @@ -112,14 +112,14 @@ public: ratio& >::type operator=(const ratio<_N2, _D2>&) {return *this;} - + static value_type value() {return value_type(num,den);} value_type operator()() const {return value();} #endif typedef ratio type; }; -#if defined(BOOST_NO_CONSTEXPR) +#if defined(BOOST_NO_CXX11_CONSTEXPR) template const boost::intmax_t ratio::num; template @@ -133,26 +133,26 @@ const boost::intmax_t ratio::den; //----------------------------------------------------------------------------// template -struct ratio_add -: boost::ratio_detail::ratio_add::type +struct ratio_add +: boost::ratio_detail::ratio_add::type { }; template struct ratio_subtract -: boost::ratio_detail::ratio_subtract::type +: boost::ratio_detail::ratio_subtract::type { }; template struct ratio_multiply -: boost::ratio_detail::ratio_multiply::type +: boost::ratio_detail::ratio_multiply::type { }; template struct ratio_divide -: boost::ratio_detail::ratio_divide::type +: boost::ratio_detail::ratio_divide::type { }; @@ -167,46 +167,46 @@ struct ratio_divide template struct ratio_equal : public boost::integral_constant + (R1::num == R2::num && R1::den == R2::den)> {}; template struct ratio_not_equal - : public boost::integral_constant::value> + : public boost::integral_constant::value> {}; // ratio_less template struct ratio_less - : boost::integral_constant::value> + : boost::integral_constant::value> {}; template struct ratio_less_equal - : boost::integral_constant::value> + : boost::integral_constant::value> {}; template struct ratio_greater - : boost::integral_constant::value> + : boost::integral_constant::value> {}; template struct ratio_greater_equal - : boost::integral_constant::value> + : boost::integral_constant::value> {}; template -struct ratio_gcd : +struct ratio_gcd : ratio::value, - mpl::lcm_c::value>::type + mpl::lcm_c::value>::type { }; - -#ifdef BOOST_RATIO_EXTENSIONS + +#ifdef BOOST_RATIO_EXTENSIONS template -struct ratio_negate +struct ratio_negate : ratio<-R::num, R::den>::type { }; @@ -221,12 +221,12 @@ struct ratio_sign { }; template -struct ratio_lcm : +struct ratio_lcm : ratio::value, - mpl::gcd_c::value>::type + mpl::gcd_c::value>::type { }; -#endif +#endif } // namespace boost diff --git a/include/boost/ratio/ratio_fwd.hpp b/include/boost/ratio/ratio_fwd.hpp index 9ce9609..0882e0b 100644 --- a/include/boost/ratio/ratio_fwd.hpp +++ b/include/boost/ratio/ratio_fwd.hpp @@ -32,12 +32,7 @@ time2_demo contained this comment: #ifndef BOOST_RATIO_RATIO_FWD_HPP #define BOOST_RATIO_RATIO_FWD_HPP -#include -#ifdef INTMAX_C -#define BOOST_RATIO_INTMAX_C(a) INTMAX_C(a) -#else -#define BOOST_RATIO_INTMAX_C(a) a##LL -#endif +#include namespace boost { @@ -82,7 +77,7 @@ typedef ratio< BOOST_RATIO_INTMAX_C(1000000000), BOOST_RATIO_INTMAX_C(1) typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000), BOOST_RATIO_INTMAX_C(1)> tera; typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000000), BOOST_RATIO_INTMAX_C(1)> peta; typedef ratio exa; - + } // namespace boost diff --git a/include/boost/ratio/ratio_io.hpp b/include/boost/ratio/ratio_io.hpp index 1b87788..7c0d015 100644 --- a/include/boost/ratio/ratio_io.hpp +++ b/include/boost/ratio/ratio_io.hpp @@ -6,7 +6,7 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt). // -// This code was adapted by Vicente from Howard Hinnant's experimental work +// This code was adapted by Vicente from Howard Hinnant's experimental work // on chrono i/o under lvm/libc++ to Boost #ifndef BOOST_RATIO_RATIO_IO_HPP @@ -25,13 +25,18 @@ namespace boost template struct ratio_string { - static basic_string short_name(); - static basic_string long_name(); + static basic_string prefix(); + static basic_string symbol(); }; } // boost */ +#include + +#ifdef BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0 +#include +#else #include #include @@ -44,31 +49,29 @@ struct ratio_string #include #endif -#if defined(BOOST_NO_UNICODE_LITERALS) || defined(BOOST_NO_CHAR16_T) || defined(BOOST_NO_CHAR32_T) -//~ #define BOOST_RATIO_HAS_UNICODE_SUPPORT +#if defined(BOOST_NO_CXX11_UNICODE_LITERALS) || defined(BOOST_NO_CXX11_CHAR16_T) || defined(BOOST_NO_CXX11_CHAR32_T) +//~ #define BOOST_RATIO_HAS_UNICODE_SUPPORT #else #define BOOST_RATIO_HAS_UNICODE_SUPPORT 1 #endif namespace boost { -template -struct ratio_string_is_localizable : false_type {}; -template -struct ratio_string_id : integral_constant {}; +//template +//struct ratio_string_is_localizable : false_type {}; +//template +//struct ratio_string_id : integral_constant {}; template struct ratio_string { - static std::basic_string short_name() {return long_name();} - static std::basic_string long_name(); - static std::basic_string symbol() {return short_name();} - static std::basic_string prefix() {return long_name();} + static std::basic_string symbol() {return prefix();} + static std::basic_string prefix(); }; template std::basic_string -ratio_string::long_name() +ratio_string::prefix() { std::basic_ostringstream os; os << CharT('[') << Ratio::num << CharT('/') @@ -81,44 +84,40 @@ namespace ratio_detail { template struct ratio_string_static { - static std::string short_name() { + static std::string symbol() { return std::basic_string( static_string::c_str< - typename ratio_static_string::short_name + typename ratio_static_string::symbol >::value); } - static std::string long_name() { + static std::string prefix() { return std::basic_string( static_string::c_str< - typename ratio_static_string::long_name + typename ratio_static_string::prefix >::value); } - static std::basic_string symbol() {return short_name();} - static std::basic_string prefix() {return long_name();} }; } #endif // atto -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; +//template <> +//struct ratio_string_is_localizable : true_type {}; +// +//template <> +//struct ratio_string_id : integral_constant {}; #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'a');} - static std::string long_name() {return std::string("atto");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'a');} + static std::string prefix() {return std::string("atto");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -126,19 +125,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'a');} - static std::u16string long_name() {return std::u16string(u"atto");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'a');} + static std::u16string prefix() {return std::u16string(u"atto");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'a');} - static std::u32string long_name() {return std::u32string(U"atto");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'a');} + static std::u32string prefix() {return std::u32string(U"atto");} }; #endif @@ -147,26 +142,18 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'a');} - static std::wstring long_name() {return std::wstring(L"atto");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'a');} + static std::wstring prefix() {return std::wstring(L"atto");} }; #endif #endif // femto -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else @@ -174,10 +161,8 @@ struct ratio_string : template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'f');} - static std::string long_name() {return std::string("femto");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'f');} + static std::string prefix() {return std::string("femto");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -185,19 +170,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'f');} - static std::u16string long_name() {return std::u16string(u"femto");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'f');} + static std::u16string prefix() {return std::u16string(u"femto");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'f');} - static std::u32string long_name() {return std::u32string(U"femto");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'f');} + static std::u32string prefix() {return std::u32string(U"femto");} }; #endif @@ -206,36 +187,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'f');} - static std::wstring long_name() {return std::wstring(L"femto");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'f');} + static std::wstring prefix() {return std::wstring(L"femto");} }; #endif #endif // pico -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'p');} - static std::string long_name() {return std::string("pico");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'p');} + static std::string prefix() {return std::string("pico");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -243,19 +214,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'p');} - static std::u16string long_name() {return std::u16string(u"pico");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'p');} + static std::u16string prefix() {return std::u16string(u"pico");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'p');} - static std::u32string long_name() {return std::u32string(U"pico");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'p');} + static std::u32string prefix() {return std::u32string(U"pico");} }; #endif @@ -264,36 +231,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'p');} - static std::wstring long_name() {return std::wstring(L"pico");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'p');} + static std::wstring prefix() {return std::wstring(L"pico");} }; #endif #endif // nano -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'n');} - static std::string long_name() {return std::string("nano");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'n');} + static std::string prefix() {return std::string("nano");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -301,19 +258,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'n');} - static std::u16string long_name() {return std::u16string(u"nano");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'n');} + static std::u16string prefix() {return std::u16string(u"nano");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'n');} - static std::u32string long_name() {return std::u32string(U"nano");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'n');} + static std::u32string prefix() {return std::u32string(U"nano");} }; #endif @@ -322,36 +275,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'n');} - static std::wstring long_name() {return std::wstring(L"nano");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'n');} + static std::wstring prefix() {return std::wstring(L"nano");} }; #endif #endif // micro -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string("\xC2\xB5");} - static std::string long_name() {return std::string("micro");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string("\xC2\xB5");} + static std::string prefix() {return std::string("micro");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -359,19 +302,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'\xB5');} - static std::u16string long_name() {return std::u16string(u"micro");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'\xB5');} + static std::u16string prefix() {return std::u16string(u"micro");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'\xB5');} - static std::u32string long_name() {return std::u32string(U"micro");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'\xB5');} + static std::u32string prefix() {return std::u32string(U"micro");} }; #endif @@ -380,36 +319,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'\xB5');} - static std::wstring long_name() {return std::wstring(L"micro");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'\xB5');} + static std::wstring prefix() {return std::wstring(L"micro");} }; #endif #endif // milli -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'm');} - static std::string long_name() {return std::string("milli");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'm');} + static std::string prefix() {return std::string("milli");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -417,19 +346,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'm');} - static std::u16string long_name() {return std::u16string(u"milli");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'm');} + static std::u16string prefix() {return std::u16string(u"milli");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'm');} - static std::u32string long_name() {return std::u32string(U"milli");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'm');} + static std::u32string prefix() {return std::u32string(U"milli");} }; #endif @@ -438,36 +363,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'm');} - static std::wstring long_name() {return std::wstring(L"milli");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'm');} + static std::wstring prefix() {return std::wstring(L"milli");} }; #endif #endif // centi -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'c');} - static std::string long_name() {return std::string("centi");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'c');} + static std::string prefix() {return std::string("centi");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -475,19 +390,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'c');} - static std::u16string long_name() {return std::u16string(u"centi");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'c');} + static std::u16string prefix() {return std::u16string(u"centi");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'c');} - static std::u32string long_name() {return std::u32string(U"centi");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'c');} + static std::u32string prefix() {return std::u32string(U"centi");} }; #endif @@ -496,26 +407,18 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'c');} - static std::wstring long_name() {return std::wstring(L"centi");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'c');} + static std::wstring prefix() {return std::wstring(L"centi");} }; #endif #endif // deci -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else @@ -523,10 +426,8 @@ struct ratio_string : template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'd');} - static std::string long_name() {return std::string("deci");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'd');} + static std::string prefix() {return std::string("deci");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -534,19 +435,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'd');} - static std::u16string long_name() {return std::u16string(u"deci");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'd');} + static std::u16string prefix() {return std::u16string(u"deci");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'd');} - static std::u32string long_name() {return std::u32string(U"deci");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'd');} + static std::u32string prefix() {return std::u32string(U"deci");} }; #endif @@ -555,43 +452,29 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'd');} - static std::wstring long_name() {return std::wstring(L"deci");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'd');} + static std::wstring prefix() {return std::wstring(L"deci");} }; #endif #endif // unit -template <> -struct ratio_string_is_localizable > : true_type {}; - -template <> -struct ratio_string_id > : integral_constant {}; // deca -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string("da");} - static std::string long_name() {return std::string("deca");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string("da");} + static std::string prefix() {return std::string("deca");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -599,19 +482,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(u"da");} - static std::u16string long_name() {return std::u16string(u"deca");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(u"da");} + static std::u16string prefix() {return std::u16string(u"deca");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(U"da");} - static std::u32string long_name() {return std::u32string(U"deca");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(U"da");} + static std::u32string prefix() {return std::u32string(U"deca");} }; #endif @@ -620,37 +499,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(L"da");} - static std::wstring long_name() {return std::wstring(L"deca");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(L"da");} + static std::wstring prefix() {return std::wstring(L"deca");} }; #endif #endif // hecto -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'h');} - static std::string long_name() {return std::string("hecto");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'h');} + static std::string prefix() {return std::string("hecto");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -658,19 +526,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'h');} - static std::u16string long_name() {return std::u16string(u"hecto");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'h');} + static std::u16string prefix() {return std::u16string(u"hecto");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'h');} - static std::u32string long_name() {return std::u32string(U"hecto");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'h');} + static std::u32string prefix() {return std::u32string(U"hecto");} }; #endif @@ -679,36 +543,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'h');} - static std::wstring long_name() {return std::wstring(L"hecto");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'h');} + static std::wstring prefix() {return std::wstring(L"hecto");} }; #endif #endif // kilo -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'k');} - static std::string long_name() {return std::string("kilo");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'k');} + static std::string prefix() {return std::string("kilo");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -716,19 +570,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'k');} - static std::u16string long_name() {return std::u16string(u"kilo");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'k');} + static std::u16string prefix() {return std::u16string(u"kilo");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'k');} - static std::u32string long_name() {return std::u32string(U"kilo");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'k');} + static std::u32string prefix() {return std::u32string(U"kilo");} }; #endif @@ -737,26 +587,18 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'k');} - static std::wstring long_name() {return std::wstring(L"kilo");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'k');} + static std::wstring prefix() {return std::wstring(L"kilo");} }; #endif #endif // mega -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else @@ -764,10 +606,8 @@ struct ratio_string : template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'M');} - static std::string long_name() {return std::string("mega");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'M');} + static std::string prefix() {return std::string("mega");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -775,19 +615,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'M');} - static std::u16string long_name() {return std::u16string(u"mega");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'M');} + static std::u16string prefix() {return std::u16string(u"mega");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'M');} - static std::u32string long_name() {return std::u32string(U"mega");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'M');} + static std::u32string prefix() {return std::u32string(U"mega");} }; #endif @@ -796,26 +632,18 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'M');} - static std::wstring long_name() {return std::wstring(L"mega");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'M');} + static std::wstring prefix() {return std::wstring(L"mega");} }; #endif #endif // giga -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else @@ -823,10 +651,8 @@ struct ratio_string : template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'G');} - static std::string long_name() {return std::string("giga");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'G');} + static std::string prefix() {return std::string("giga");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -834,19 +660,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'G');} - static std::u16string long_name() {return std::u16string(u"giga");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'G');} + static std::u16string prefix() {return std::u16string(u"giga");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'G');} - static std::u32string long_name() {return std::u32string(U"giga");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'G');} + static std::u32string prefix() {return std::u32string(U"giga");} }; #endif @@ -855,36 +677,27 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'G');} - static std::wstring long_name() {return std::wstring(L"giga");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'G');} + static std::wstring prefix() {return std::wstring(L"giga");} }; #endif #endif // tera -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - +//template <> #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'T');} - static std::string long_name() {return std::string("tera");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'T');} + static std::string prefix() {return std::string("tera");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -892,19 +705,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'T');} - static std::u16string long_name() {return std::u16string(u"tera");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'T');} + static std::u16string prefix() {return std::u16string(u"tera");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'T');} - static std::u32string long_name() {return std::u32string(U"tera");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'T');} + static std::u32string prefix() {return std::u32string(U"tera");} }; #endif @@ -913,37 +722,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'T');} - static std::wstring long_name() {return std::wstring(L"tera");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'T');} + static std::wstring prefix() {return std::wstring(L"tera");} }; #endif #endif // peta -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'P');} - static std::string long_name() {return std::string("peta");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'P');} + static std::string prefix() {return std::string("peta");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -951,19 +749,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'P');} - static std::u16string long_name() {return std::u16string(u"peta");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'P');} + static std::u16string prefix() {return std::u16string(u"peta");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'P');} - static std::u32string long_name() {return std::u32string(U"peta");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'P');} + static std::u32string prefix() {return std::u32string(U"peta");} }; #endif @@ -972,36 +766,26 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'P');} - static std::wstring long_name() {return std::wstring(L"peta");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'P');} + static std::wstring prefix() {return std::wstring(L"peta");} }; #endif #endif // exa -template <> -struct ratio_string_is_localizable : true_type {}; - -template <> -struct ratio_string_id : integral_constant {}; - #ifdef BOOST_RATIO_HAS_STATIC_STRING template -struct ratio_string : - ratio_detail::ratio_string_static +struct ratio_string : + ratio_detail::ratio_string_static {}; #else template <> struct ratio_string { - static std::string short_name() {return std::string(1, 'E');} - static std::string long_name() {return std::string("exa");} - static std::string symbol() {return short_name();} - static std::string prefix() {return long_name();} + static std::string symbol() {return std::string(1, 'E');} + static std::string prefix() {return std::string("exa");} }; #if BOOST_RATIO_HAS_UNICODE_SUPPORT @@ -1009,19 +793,15 @@ struct ratio_string template <> struct ratio_string { - static std::u16string short_name() {return std::u16string(1, u'E');} - static std::u16string long_name() {return std::u16string(u"exa");} - static std::u16string symbol() {return short_name();} - static std::u16string prefix() {return long_name();} + static std::u16string symbol() {return std::u16string(1, u'E');} + static std::u16string prefix() {return std::u16string(u"exa");} }; template <> struct ratio_string { - static std::u32string short_name() {return std::u32string(1, U'E');} - static std::u32string long_name() {return std::u32string(U"exa");} - static std::u32string symbol() {return short_name();} - static std::u32string prefix() {return long_name();} + static std::u32string symbol() {return std::u32string(1, U'E');} + static std::u32string prefix() {return std::u32string(U"exa");} }; #endif @@ -1030,14 +810,13 @@ struct ratio_string template <> struct ratio_string { - static std::wstring short_name() {return std::wstring(1, L'E');} - static std::wstring long_name() {return std::wstring(L"exa");} - static std::wstring symbol() {return short_name();} - static std::wstring prefix() {return long_name();} + static std::wstring symbol() {return std::wstring(1, L'E');} + static std::wstring prefix() {return std::wstring(L"exa");} }; #endif #endif } +#endif // BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0 #endif // BOOST_RATIO_RATIO_IO_HPP diff --git a/include/boost/ratio/ratio_static_string.hpp b/include/boost/ratio/ratio_static_string.hpp index 48dbd7c..95bf308 100644 --- a/include/boost/ratio/ratio_static_string.hpp +++ b/include/boost/ratio/ratio_static_string.hpp @@ -5,7 +5,7 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt). // -// This code was adapted by Vicente from Howard Hinnant's experimental work +// This code was adapted by Vicente from Howard Hinnant's experimental work // on chrono i/o under lvm/libc++ to Boost #ifndef BOOST_RATIO_RATIO_STATIC_STRING_HPP @@ -38,14 +38,14 @@ struct ratio_static_string //#include -#if defined(BOOST_NO_UNICODE_LITERALS) || defined(BOOST_NO_CHAR16_T) || defined(BOOST_NO_CHAR32_T) -//~ #define BOOST_RATIO_HAS_UNICODE_SUPPORT +#if defined(BOOST_NO_CXX11_UNICODE_LITERALS) || defined(BOOST_NO_CXX11_CHAR16_T) || defined(BOOST_NO_CXX11_CHAR32_T) +//~ #define BOOST_RATIO_HAS_UNICODE_SUPPORT #else #define BOOST_RATIO_HAS_UNICODE_SUPPORT 1 #endif namespace boost { - + template struct ratio_static_string; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index dad2a29..dd47197 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -26,7 +26,11 @@ project msvc:on BOOST_ENABLE_WARNINGS BOOST_RATIO_USES_MPL_ASSERT + BOOST_RATIO_VERSION=2 BOOST_MPL_NEXT_PRIOR_EXT + #sun:BOOST_COMMON_TYPE_DONT_USE_TYPEOF + #sun:BOOST_TYPEOF_EMULATION + sun:__typeof__=__typeof__ all gcc:-Wextra gcc:-Wno-long-long @@ -118,3 +122,7 @@ project ; + #test-suite "tickets" + # : + # [ run test_6498_pass.cpp ] + # ; diff --git a/test/ratio_arithmetic/ratio_add_fail.cpp b/test/ratio_arithmetic/ratio_add_fail.cpp index 28403d5..80964a2 100644 --- a/test/ratio_arithmetic/ratio_add_fail.cpp +++ b/test/ratio_arithmetic/ratio_add_fail.cpp @@ -18,11 +18,10 @@ #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX boost::integer_traits::const_max -typedef boost::ratio R1; +typedef boost::ratio::const_max, 1> R1; typedef boost::ratio<1, 1> R2; typedef boost::ratio_add::type RT; -BOOST_RATIO_STATIC_ASSERT(RT::num==BOOST_RATIO_INTMAX_T_MAX+1, NOTHING, (RT)); +BOOST_RATIO_STATIC_ASSERT(RT::num==boost::integer_traits::const_max+1, NOTHING, (RT)); BOOST_RATIO_STATIC_ASSERT(RT::den==1, NOTHING, (RT)); diff --git a/test/ratio_arithmetic/ratio_add_pass.cpp b/test/ratio_arithmetic/ratio_add_pass.cpp index cdade4b..736d3df 100644 --- a/test/ratio_arithmetic/ratio_add_pass.cpp +++ b/test/ratio_arithmetic/ratio_add_pass.cpp @@ -71,7 +71,7 @@ void test() BOOST_RATIO_STATIC_ASSERT(R::num == 127970191639601LL && R::den == 5177331081415LL, NOTHING, ()); } { - typedef boost::ratio R1; + typedef boost::ratio R1; typedef boost::ratio<-1, 1> R2; typedef boost::ratio_add::type RT; } diff --git a/test/ratio_arithmetic/ratio_divide_fail.cpp b/test/ratio_arithmetic/ratio_divide_fail.cpp index 46c6907..1ac9551 100644 --- a/test/ratio_arithmetic/ratio_divide_fail.cpp +++ b/test/ratio_arithmetic/ratio_divide_fail.cpp @@ -15,6 +15,6 @@ #include -typedef boost::ratio R1; +typedef boost::ratio R1; typedef boost::ratio<1,2> R2; typedef boost::ratio_divide::type RT; diff --git a/test/ratio_arithmetic/ratio_multiply_fail.cpp b/test/ratio_arithmetic/ratio_multiply_fail.cpp index d377b82..61afafa 100644 --- a/test/ratio_arithmetic/ratio_multiply_fail.cpp +++ b/test/ratio_arithmetic/ratio_multiply_fail.cpp @@ -15,6 +15,6 @@ #include -typedef boost::ratio R1; +typedef boost::ratio R1; typedef boost::ratio<2,1> R2; typedef boost::ratio_multiply::type RT; diff --git a/test/ratio_comparison/ratio_equal_pass.cpp b/test/ratio_comparison/ratio_equal_pass.cpp index 632da48..4298ff6 100644 --- a/test/ratio_comparison/ratio_equal_pass.cpp +++ b/test/ratio_comparison/ratio_equal_pass.cpp @@ -18,7 +18,6 @@ #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_comparison/ratio_greater_equal_pass.cpp b/test/ratio_comparison/ratio_greater_equal_pass.cpp index fcacded..f6b894c 100644 --- a/test/ratio_comparison/ratio_greater_equal_pass.cpp +++ b/test/ratio_comparison/ratio_greater_equal_pass.cpp @@ -16,7 +16,6 @@ #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_comparison/ratio_greater_pass.cpp b/test/ratio_comparison/ratio_greater_pass.cpp index 53d341b..a2111d5 100644 --- a/test/ratio_comparison/ratio_greater_pass.cpp +++ b/test/ratio_comparison/ratio_greater_pass.cpp @@ -15,7 +15,6 @@ #if !defined(BOOST_NO_STATIC_ASSERT) #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_comparison/ratio_less_equal_pass.cpp b/test/ratio_comparison/ratio_less_equal_pass.cpp index 2dc547b..7f5fee4 100644 --- a/test/ratio_comparison/ratio_less_equal_pass.cpp +++ b/test/ratio_comparison/ratio_less_equal_pass.cpp @@ -15,7 +15,6 @@ #if !defined(BOOST_NO_STATIC_ASSERT) #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_comparison/ratio_less_pass.cpp b/test/ratio_comparison/ratio_less_pass.cpp index d5a0f89..9cbc34e 100644 --- a/test/ratio_comparison/ratio_less_pass.cpp +++ b/test/ratio_comparison/ratio_less_pass.cpp @@ -16,7 +16,6 @@ #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { { diff --git a/test/ratio_comparison/ratio_not_equal_pass.cpp b/test/ratio_comparison/ratio_not_equal_pass.cpp index 5afc8bf..d055373 100644 --- a/test/ratio_comparison/ratio_not_equal_pass.cpp +++ b/test/ratio_comparison/ratio_not_equal_pass.cpp @@ -15,7 +15,6 @@ #if !defined(BOOST_NO_STATIC_ASSERT) #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_extensions/mpl_equal_to_pass.cpp b/test/ratio_extensions/mpl_equal_to_pass.cpp index c169a76..704d889 100644 --- a/test/ratio_extensions/mpl_equal_to_pass.cpp +++ b/test/ratio_extensions/mpl_equal_to_pass.cpp @@ -20,7 +20,6 @@ #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_extensions/mpl_greater_equal_pass.cpp b/test/ratio_extensions/mpl_greater_equal_pass.cpp index f54de10..1661003 100644 --- a/test/ratio_extensions/mpl_greater_equal_pass.cpp +++ b/test/ratio_extensions/mpl_greater_equal_pass.cpp @@ -18,7 +18,6 @@ #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_extensions/mpl_greater_pass.cpp b/test/ratio_extensions/mpl_greater_pass.cpp index c56f153..99f4795 100644 --- a/test/ratio_extensions/mpl_greater_pass.cpp +++ b/test/ratio_extensions/mpl_greater_pass.cpp @@ -17,7 +17,6 @@ #if !defined(BOOST_NO_STATIC_ASSERT) #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_extensions/mpl_less_equal_pass.cpp b/test/ratio_extensions/mpl_less_equal_pass.cpp index 7037899..9682ce8 100644 --- a/test/ratio_extensions/mpl_less_equal_pass.cpp +++ b/test/ratio_extensions/mpl_less_equal_pass.cpp @@ -17,7 +17,6 @@ #if !defined(BOOST_NO_STATIC_ASSERT) #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_extensions/mpl_less_pass.cpp b/test/ratio_extensions/mpl_less_pass.cpp index e2b13d8..ed2223d 100644 --- a/test/ratio_extensions/mpl_less_pass.cpp +++ b/test/ratio_extensions/mpl_less_pass.cpp @@ -18,7 +18,6 @@ #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { { diff --git a/test/ratio_extensions/mpl_not_equal_to_pass.cpp b/test/ratio_extensions/mpl_not_equal_to_pass.cpp index 07af608..f9c07ed 100644 --- a/test/ratio_extensions/mpl_not_equal_to_pass.cpp +++ b/test/ratio_extensions/mpl_not_equal_to_pass.cpp @@ -17,7 +17,6 @@ #if !defined(BOOST_NO_STATIC_ASSERT) #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) void test() { diff --git a/test/ratio_extensions/mpl_plus_pass.cpp b/test/ratio_extensions/mpl_plus_pass.cpp index 68008e5..2258083 100644 --- a/test/ratio_extensions/mpl_plus_pass.cpp +++ b/test/ratio_extensions/mpl_plus_pass.cpp @@ -72,7 +72,7 @@ void test() BOOST_RATIO_STATIC_ASSERT(R::num == 127970191639601LL && R::den == 5177331081415LL, NOTHING, ()); } { - typedef boost::ratio R1; + typedef boost::ratio R1; typedef boost::ratio<-1, 1> R2; typedef boost::mpl::int_<0> R3; typedef boost::mpl::plus::type RT; diff --git a/test/ratio_io/ratio_io_fail.cpp b/test/ratio_io/ratio_io_fail.cpp index ff478e7..86f37dc 100644 --- a/test/ratio_io/ratio_io_fail.cpp +++ b/test/ratio_io/ratio_io_fail.cpp @@ -17,6 +17,6 @@ typedef boost::ratio_string R1; void test() { - - std::string str = R1::short_name(); + + std::string str = R1::symbol(); } diff --git a/test/ratio_io/ratio_io_pass.cpp b/test/ratio_io/ratio_io_pass.cpp index c4bc2a8..0c31c7d 100644 --- a/test/ratio_io/ratio_io_pass.cpp +++ b/test/ratio_io/ratio_io_pass.cpp @@ -22,130 +22,130 @@ int main() { BOOST_TEST(( - boost::ratio_string::long_name() == "atto" + boost::ratio_string::prefix() == "atto" )); BOOST_TEST(( - boost::ratio_string::short_name() == "a" + boost::ratio_string::symbol() == "a" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "femto" + boost::ratio_string::prefix() == "femto" )); BOOST_TEST(( - boost::ratio_string::short_name() == "f" + boost::ratio_string::symbol() == "f" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "pico" + boost::ratio_string::prefix() == "pico" )); BOOST_TEST(( - boost::ratio_string::short_name() == "p" + boost::ratio_string::symbol() == "p" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "nano" + boost::ratio_string::prefix() == "nano" )); BOOST_TEST(( - boost::ratio_string::short_name() == "n" + boost::ratio_string::symbol() == "n" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "micro" + boost::ratio_string::prefix() == "micro" )); BOOST_TEST(( - boost::ratio_string::short_name() == "\xC2\xB5" + boost::ratio_string::symbol() == "\xC2\xB5" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "milli" + boost::ratio_string::prefix() == "milli" )); BOOST_TEST(( - boost::ratio_string::short_name() == "m" + boost::ratio_string::symbol() == "m" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "centi" + boost::ratio_string::prefix() == "centi" )); BOOST_TEST(( - boost::ratio_string::short_name() == "c" + boost::ratio_string::symbol() == "c" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "deci" + boost::ratio_string::prefix() == "deci" )); BOOST_TEST(( - boost::ratio_string::short_name() == "d" + boost::ratio_string::symbol() == "d" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "deca" + boost::ratio_string::prefix() == "deca" )); BOOST_TEST(( - boost::ratio_string::short_name() == "da" + boost::ratio_string::symbol() == "da" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "hecto" + boost::ratio_string::prefix() == "hecto" )); BOOST_TEST(( - boost::ratio_string::short_name() == "h" + boost::ratio_string::symbol() == "h" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "kilo" + boost::ratio_string::prefix() == "kilo" )); BOOST_TEST(( - boost::ratio_string::short_name() == "k" + boost::ratio_string::symbol() == "k" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "mega" + boost::ratio_string::prefix() == "mega" )); BOOST_TEST(( - boost::ratio_string::short_name() == "M" + boost::ratio_string::symbol() == "M" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "giga" + boost::ratio_string::prefix() == "giga" )); BOOST_TEST(( - boost::ratio_string::short_name() == "G" + boost::ratio_string::symbol() == "G" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "tera" + boost::ratio_string::prefix() == "tera" )); BOOST_TEST(( - boost::ratio_string::short_name() == "T" + boost::ratio_string::symbol() == "T" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "peta" + boost::ratio_string::prefix() == "peta" )); BOOST_TEST(( - boost::ratio_string::short_name() == "P" + boost::ratio_string::symbol() == "P" )); } { BOOST_TEST(( - boost::ratio_string::long_name() == "exa" + boost::ratio_string::prefix() == "exa" )); BOOST_TEST(( - boost::ratio_string::short_name() == "E" + boost::ratio_string::symbol() == "E" )); } // return 1; diff --git a/test/ratio_ratio/ratio_pass.cpp b/test/ratio_ratio/ratio_pass.cpp index f7ffd5f..2db988a 100644 --- a/test/ratio_ratio/ratio_pass.cpp +++ b/test/ratio_ratio/ratio_pass.cpp @@ -19,7 +19,6 @@ #if !defined(BOOST_NO_STATIC_ASSERT) #define NOTHING "" #endif -#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL) template void test() @@ -46,10 +45,10 @@ int main() test<222, -333, -2, 3>(); test<-222, 333, -2, 3>(); test<-222, -333, 2, 3>(); - test(); - test<-BOOST_RATIO_INTMAX_T_MAX, 127, -72624976668147841LL, 1>(); - test(); - test<-BOOST_RATIO_INTMAX_T_MAX, -127, 72624976668147841LL, 1>(); + //test(); + //test<-BOOST_RATIO_INTMAX_T_MAX, 127, -72624976668147841LL, 1>(); + //test(); + //test<-BOOST_RATIO_INTMAX_T_MAX, -127, 72624976668147841LL, 1>(); //~ test(); //~ test<-BOOST_RATIO_INTMAX_T_MAX, 127, -BOOST_RATIO_INTMAX_T_MAX, 127>(); //~ test(); diff --git a/test/ratio_test.cpp b/test/ratio_test.cpp index a9d8c82..380e137 100644 --- a/test/ratio_test.cpp +++ b/test/ratio_test.cpp @@ -19,7 +19,7 @@ typedef boost::ratio_multiply, boost::nano>::type _5nano; // _5 // Test the case described in library working group issue 948. -typedef boost::ratio R1; +typedef boost::ratio R1; typedef boost::ratio<8, 7> R2; typedef boost::ratio_multiply::type RT;