[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [4781] Add mc_enum<rounding_style> (VS)
From: |
Greg Chicares |
Subject: |
[lmi-commits] [4781] Add mc_enum<rounding_style> (VS) |
Date: |
Fri, 26 Feb 2010 02:32:22 +0000 |
Revision: 4781
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4781
Author: chicares
Date: 2010-02-26 02:32:22 +0000 (Fri, 26 Feb 2010)
Log Message:
-----------
Add mc_enum<rounding_style> (VS)
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/mc_enum_type_enums.hpp
lmi/trunk/mc_enum_types.cpp
lmi/trunk/mc_enum_types.hpp
lmi/trunk/round_to.hpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-02-25 17:49:31 UTC (rev 4780)
+++ lmi/trunk/ChangeLog 2010-02-26 02:32:22 UTC (rev 4781)
@@ -24395,3 +24395,11 @@
mc_enum_test_aux.cpp
Fix a presumptive gcc-4.x issue.
+20100226T0232Z <address@hidden> [762]
+
+ mc_enum_type_enums.hpp
+ mc_enum_types.cpp
+ mc_enum_types.hpp
+ round_to.hpp
+Add mc_enum<rounding_style> (VS).
+
Modified: lmi/trunk/mc_enum_type_enums.hpp
===================================================================
--- lmi/trunk/mc_enum_type_enums.hpp 2010-02-25 17:49:31 UTC (rev 4780)
+++ lmi/trunk/mc_enum_type_enums.hpp 2010-02-26 02:32:22 UTC (rev 4781)
@@ -54,6 +54,25 @@
,mce_emit_custom_0 = 512
};
+/// Rounding styles.
+///
+/// 'r_to_nearest' means bankers rounding, which rounds halfway cases
+/// to even:
+/// x - (x REM 1.0)
+/// as in the C99 remainder() function [7.12.10.2/2], instead of
+/// rounding halfway cases away from zero, as the C99 round()
+/// function does [7.12.9.6/2].
+
+enum rounding_style
+ {r_indeterminate = -1
+ ,r_toward_zero = 0
+ ,r_to_nearest = 1
+ ,r_upward = 2
+ ,r_downward = 3
+ ,r_current = 4
+ ,r_not_at_all = 5
+ };
+
/// Not yet implemented--used only to initialize an unimplemented
/// database entity.
Modified: lmi/trunk/mc_enum_types.cpp
===================================================================
--- lmi/trunk/mc_enum_types.cpp 2010-02-25 17:49:31 UTC (rev 4780)
+++ lmi/trunk/mc_enum_types.cpp 2010-02-26 02:32:22 UTC (rev 4781)
@@ -84,6 +84,26 @@
};
template class mc_enum<mcenum_emission>;
+extern rounding_style const rounding_style_enums[] =
+ {r_indeterminate
+ ,r_toward_zero
+ ,r_to_nearest
+ ,r_upward
+ ,r_downward
+ ,r_current
+ ,r_not_at_all
+ };
+extern char const*const rounding_style_strings[] =
+ {"Indeterminate"
+ ,"Toward zero"
+ ,"To nearest"
+ ,"Upward"
+ ,"Downward"
+ ,"Current"
+ ,"Not at all"
+ };
+template class mc_enum<rounding_style>;
+
#include "mc_enum_types.xpp"
#define MC_DEFINE(TYPE) \
Modified: lmi/trunk/mc_enum_types.hpp
===================================================================
--- lmi/trunk/mc_enum_types.hpp 2010-02-25 17:49:31 UTC (rev 4780)
+++ lmi/trunk/mc_enum_types.hpp 2010-02-26 02:32:22 UTC (rev 4781)
@@ -45,6 +45,12 @@
:public mc_enum_data<mcenum_emission, 11, emission_enums, emission_strings>
{};
typedef mc_enum<mcenum_emission> e_emission;
+extern rounding_style const rounding_style_enums[7];
+extern char const*const rounding_style_strings[7];
+template<> struct mc_enum_key<rounding_style>
+ :public mc_enum_data<rounding_style, 7, rounding_style_enums,
rounding_style_strings> {};
+typedef mc_enum<rounding_style> mce_rounding_style;
+
#define MC_DECLARE(TYPE,NUMBER) \
extern mcenum_##TYPE const TYPE##_enums[NUMBER]; \
extern char const*const TYPE##_strings[NUMBER]; \
Modified: lmi/trunk/round_to.hpp
===================================================================
--- lmi/trunk/round_to.hpp 2010-02-25 17:49:31 UTC (rev 4780)
+++ lmi/trunk/round_to.hpp 2010-02-26 02:32:22 UTC (rev 4781)
@@ -26,6 +26,8 @@
#include "config.hpp"
+#include "mc_enum_type_enums.hpp"
+
#if !defined __BORLANDC__
# include <boost/static_assert.hpp>
# include <boost/type_traits/arithmetic_traits.hpp>
@@ -193,24 +195,6 @@
} // namespace detail
// See HTML documentation.
-enum rounding_style
- {r_indeterminate = -1
- ,r_toward_zero = 0
- ,r_to_nearest = 1 // See note below.
- ,r_upward = 2
- ,r_downward = 3
- ,r_current = 4
- ,r_not_at_all = 5
-
- // Note: 'r_to_nearest' means bankers rounding, which
- // rounds halfway cases to even:
- // x - (x REM 1.0)
- // as in the C99 remainder() function [7.12.10.2/2], instead of
- // rounding halfway cases away from zero, as the C99 round()
- // function does [7.12.9.6/2]. See the HTML documentation.
- };
-
-// See HTML documentation.
inline rounding_style& default_rounding_style()
{
static rounding_style default_style = r_to_nearest;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [4781] Add mc_enum<rounding_style> (VS),
Greg Chicares <=