|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54856 - sandbox/numeric_adaptor/boost/numeric_adaptor
From: bruno.lalande_at_[hidden]
Date: 2009-07-10 09:53:04
Author: bruno.lalande
Date: 2009-07-10 09:53:03 EDT (Fri, 10 Jul 2009)
New Revision: 54856
URL: http://svn.boost.org/trac/boost/changeset/54856
Log:
Initialization, copy and termination of policies and now handled by constructors/destructors rather than functions.
Text files modified:
sandbox/numeric_adaptor/boost/numeric_adaptor/default_policy.hpp | 9 +++++----
sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_policy.hpp | 14 +++++++-------
sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp | 22 ++++------------------
3 files changed, 16 insertions(+), 29 deletions(-)
Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/default_policy.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/default_policy.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/default_policy.hpp 2009-07-10 09:53:03 EDT (Fri, 10 Jul 2009)
@@ -22,12 +22,13 @@
{
typedef T value_type;
- // Default no initialization or pre-destruction is necessary
- static inline void init(T& value) {}
- static inline void destruct(T& value) {}
+ default_policy()
+ {}
// Use the default assignment
- static inline void copy(T const& source, T& dest) { dest = source; }
+ default_policy(default_policy const& source):
+ value(source.value)
+ {}
// The default policy uses the default operators +, -, *, /
static inline void add(default_policy& r, const default_policy& a, const default_policy& b)
Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_policy.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_policy.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_policy.hpp 2009-07-10 09:53:03 EDT (Fri, 10 Jul 2009)
@@ -22,16 +22,21 @@
struct gmp_policy: default_policy<gmp_policy, mpf_t>
{
- static inline void init(value_type& value)
+ gmp_policy()
{
mpf_init(value);
}
- static inline void destruct(value_type& value)
+ ~gmp_policy()
{
mpf_clear(value);
}
+ gmp_policy(gmp_policy const& source)
+ {
+ mpf_set(value, source.value);
+ }
+
template <typename OtherType>
static inline void set(value_type& value, const OtherType& v)
{
@@ -44,11 +49,6 @@
}
- static inline void copy(value_type const& source, value_type& dest)
- {
- mpf_set(dest, source);
- }
-
// TODO should we add specific overloads for function like mpf_add_ui?
static inline void add(gmp_policy& r, gmp_policy const& a, gmp_policy const& b)
Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp 2009-07-10 09:53:03 EDT (Fri, 10 Jul 2009)
@@ -43,27 +43,21 @@
enable_cast<numeric_adaptor<Policy>, long double>
{
inline numeric_adaptor()
- {
- Policy::init(Policy::value);
- }
+ {}
// Copy constructor
- inline numeric_adaptor(numeric_adaptor<Policy> const& v)
- {
- Policy::init(Policy::value);
- Policy::copy(v.value, Policy::value);
- }
+ inline numeric_adaptor(numeric_adaptor<Policy> const& v):
+ Policy(v)
+ {}
// Constructor from a string
inline numeric_adaptor(std::string const& v)
{
- Policy::init(Policy::value);
Policy::set(Policy::value, v);
}
inline numeric_adaptor(const char* v)
{
- Policy::init(Policy::value);
Policy::set(Policy::value, std::string(v));
}
@@ -71,16 +65,9 @@
template <typename FromType>
inline numeric_adaptor(FromType const& v)
{
- Policy::init(Policy::value);
Policy::template set<FromType>(Policy::value, v);
}
-
- virtual ~numeric_adaptor()
- {
- Policy::destruct(Policy::value);
- }
-
// Assignment from other value
inline numeric_adaptor<Policy> operator=(numeric_adaptor<Policy> const& v)
{
@@ -197,7 +184,6 @@
// is necessary for cases where type == OtherType
inline numeric_adaptor<Policy>(typename Policy::value_type const& v, bool)
{
- Policy::init(Policy::value);
Policy::copy(v, Policy::value);
}
};
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk