|
Boost-Commit : |
From: steven_at_[hidden]
Date: 2008-06-28 21:02:43
Author: steven_watanabe
Date: 2008-06-28 21:02:42 EDT (Sat, 28 Jun 2008)
New Revision: 46832
URL: http://svn.boost.org/trac/boost/changeset/46832
Log:
Allow quantities to be constructed from the literal 0
Text files modified:
trunk/boost/units/quantity.hpp | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
Modified: trunk/boost/units/quantity.hpp
==============================================================================
--- trunk/boost/units/quantity.hpp (original)
+++ trunk/boost/units/quantity.hpp 2008-06-28 21:02:42 EDT (Sat, 28 Jun 2008)
@@ -91,6 +91,7 @@
// base units are not the same as units.
BOOST_MPL_ASSERT_NOT((detail::is_base_unit<Unit>));
enum { force_instantiation_of_unit = sizeof(Unit) };
+ typedef void (quantity::*unspecified_null_pointer_constant_type)(int*******);
public:
typedef quantity<Unit,Y> this_type;
@@ -101,6 +102,11 @@
{
BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y);
}
+
+ quantity(unspecified_null_pointer_constant_type) : val_()
+ {
+ BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y);
+ }
quantity(const this_type& source) : val_(source.val_)
{
@@ -275,10 +281,10 @@
this_type& operator/=(const value_type& source) { val_ /= source; return *this; }
/// Construct quantity directly from @c value_type (potentially dangerous).
- static this_type from_value(const value_type& val) { return this_type(val); }
+ static this_type from_value(const value_type& val) { return this_type(val, 0); }
protected:
- explicit quantity(const value_type& val) : val_(val) { }
+ explicit quantity(const value_type& val, int) : val_(val) { }
private:
value_type val_;
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