|
Boost-Commit : |
From: steven_at_[hidden]
Date: 2008-05-13 19:19:40
Author: steven_watanabe
Date: 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
New Revision: 45345
URL: http://svn.boost.org/trac/boost/changeset/45345
Log:
Tweaked reference documentation
Text files modified:
sandbox/units/boost/units/config.hpp | 5 +++++
sandbox/units/boost/units/derived_dimension.hpp | 4 ++++
sandbox/units/boost/units/dim.hpp | 29 ++++++++++++++++++++++++-----
sandbox/units/boost/units/dimensionless_type.hpp | 4 ++++
sandbox/units/boost/units/homogeneous_system.hpp | 8 ++++++++
sandbox/units/boost/units/make_system.hpp | 2 +-
sandbox/units/boost/units/operators.hpp | 4 ++++
sandbox/units/boost/units/scaled_base_unit.hpp | 24 +++++++++++++++++++++++-
sandbox/units/boost/units/static_rational.hpp | 26 ++++++++++++++++++++------
9 files changed, 93 insertions(+), 13 deletions(-)
Modified: sandbox/units/boost/units/config.hpp
==============================================================================
--- sandbox/units/boost/units/config.hpp (original)
+++ sandbox/units/boost/units/config.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -97,6 +97,11 @@
/// compiler is able to handle the library.
#define BOOST_UNITS_NO_COMPILER_CHECK
+/// Enable checking to verify that a homogeneous system
+/// is actually capable of representing all the dimensions
+/// that it is used with. Off by default.
+#define BOOST_UNITS_CHECK_HOMOGENEOUS_UNITS
+
#endif
#endif
Modified: sandbox/units/boost/units/derived_dimension.hpp
==============================================================================
--- sandbox/units/boost/units/derived_dimension.hpp (original)
+++ sandbox/units/boost/units/derived_dimension.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -34,6 +34,9 @@
class DT8 = dimensionless_type,long E8 = 0>
struct derived_dimension
{
+#ifdef BOOST_UNITS_DOXYGEN
+ typedef detail::unspecified type;
+#else
typedef typename
make_dimension_list< mpl::list< dim< DT1,static_rational<E1> >,
dim< DT2,static_rational<E2> >,
@@ -43,6 +46,7 @@
dim< DT6,static_rational<E6> >,
dim< DT7,static_rational<E7> >,
dim< DT8,static_rational<E8> > > >::type type;
+#endif
};
/// INTERNAL ONLY
Modified: sandbox/units/boost/units/dim.hpp
==============================================================================
--- sandbox/units/boost/units/dim.hpp (original)
+++ sandbox/units/boost/units/dim.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -40,11 +40,26 @@
/// The dim class represents a single dimension tag/dimension exponent pair.
/// That is, @c dim<tag_type,value_type> is a pair where @c tag_type represents the
/// fundamental dimension being represented and @c value_type represents the
-/// exponent of that fundamental dimension as a @c static_rational or other type
-/// providing the required compile-time arithmetic operations. @c tag_type must
-/// provide an ordinal value to allow sorting of lists of dims at compile-time.
-/// This can be easily accomplished by inheriting from @c ordinal<N>. Otherwise,
-/// @c tag_type may be any type.
+/// exponent of that fundamental dimension as a @c static_rational. @c tag_type must
+/// be a derived from a specialization of @c base_dimension.
+/// Specialization of the following Boost.MPL metafunctions are provided
+///
+/// @c mpl::plus for two @c dims
+///
+/// @c mpl::minus for two @c dims
+///
+/// @c mpl::negate for a @c dim
+///
+/// These metafunctions all operate on the exponent, and require
+/// that the @c dim operands have the same base dimension tag.
+/// In addition, multiplication and division by @c static_rational
+/// is supported.
+///
+/// @c mpl::times for a @c static_rational and a @c dim in either order
+///
+/// @c mpl::divides for a @c static_rational and a @c dim in either order
+///
+/// These metafunctions likewise operate on the exponent only.
template<typename T,typename V>
struct dim
{
@@ -66,6 +81,8 @@
#endif
+#ifndef BOOST_UNITS_DOXYGEN
+
namespace boost {
namespace mpl {
@@ -148,4 +165,6 @@
} // namespace boost
+#endif
+
#endif // BOOST_UNITS_DIM_HPP
Modified: sandbox/units/boost/units/dimensionless_type.hpp
==============================================================================
--- sandbox/units/boost/units/dimensionless_type.hpp (original)
+++ sandbox/units/boost/units/dimensionless_type.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -31,6 +31,8 @@
} // namespace units
+#ifndef BOOST_UNITS_DOXYGEN
+
namespace mpl {
// INTERNAL ONLY
@@ -38,6 +40,8 @@
} // namespace mpl
+#endif
+
} // namespace boost
#if BOOST_UNITS_HAS_BOOST_TYPEOF
Modified: sandbox/units/boost/units/homogeneous_system.hpp
==============================================================================
--- sandbox/units/boost/units/homogeneous_system.hpp (original)
+++ sandbox/units/boost/units/homogeneous_system.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -29,8 +29,16 @@
namespace units {
+/// A system that can uniquely represent any unit
+/// which can be composed from a linearly independent set
+/// of base units. It is safe to rebind a unit with
+/// such a system to different dimensions.
+///
+/// Do not construct this template directly. Use
+/// make_system instead.
template<class L>
struct homogeneous_system {
+ /// INTERNAL ONLY
typedef L type;
};
Modified: sandbox/units/boost/units/make_system.hpp
==============================================================================
--- sandbox/units/boost/units/make_system.hpp (original)
+++ sandbox/units/boost/units/make_system.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -35,7 +35,7 @@
/// represent any combination of the base units. There must
/// be no way to represent any of the base units in terms
/// of the others. make_system<foot_base_unit, meter_base_unit>::type
-/// is not allowed.
+/// is not allowed, for example.
template<class BaseUnit0, class BaseUnit1, class BaseUnit2, ..., class BaseUnitN>
struct make_system
{
Modified: sandbox/units/boost/units/operators.hpp
==============================================================================
--- sandbox/units/boost/units/operators.hpp (original)
+++ sandbox/units/boost/units/operators.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -31,6 +31,8 @@
#if BOOST_UNITS_HAS_TYPEOF
+#ifndef BOOST_UNITS_DOXYGEN
+
// to avoid need for default constructor and eliminate divide by zero errors
namespace typeof_ {
@@ -39,6 +41,8 @@
} // namespace typeof_
+#endif
+
#if (BOOST_UNITS_HAS_BOOST_TYPEOF)
template<typename X> struct unary_plus_typeof_helper
Modified: sandbox/units/boost/units/scaled_base_unit.hpp
==============================================================================
--- sandbox/units/boost/units/scaled_base_unit.hpp (original)
+++ sandbox/units/boost/units/scaled_base_unit.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -44,15 +44,20 @@
template<class T, class E>
struct heterogeneous_system_dim;
+/// class representing a scaling factor such as 10^3
+/// The exponent should be a static rational.
template<long Base, class Exponent>
struct scale
{
- enum { base = Base };
+ static const long base = Base;
typedef Exponent exponent;
typedef double value_type;
static value_type value() { return(detail::static_rational_power<Exponent>(static_cast<double>(base))); }
};
+template<long Base, class Exponent>
+const long scale<Base, Exponent>::base;
+
/// INTERNAL ONLY
template<long Base>
struct scale<Base, static_rational<0> >
@@ -127,6 +132,13 @@
typedef S system_type;
typedef Scale scale_type;
typedef typename S::dimension_type dimension_type;
+
+#ifdef BOOST_UNITS_DOXYGEN
+
+ typedef detail::unspecified unit_type;
+
+#else
+
typedef unit<
dimension_type,
heterogeneous_system<
@@ -140,6 +152,8 @@
>
> unit_type;
+#endif
+
static std::string symbol()
{
return(Scale::symbol_prefix() + S::symbol());
@@ -236,6 +250,8 @@
} // namespace units
+#ifndef BOOST_UNITS_DOXYGEN
+
namespace mpl {
/// INTERNAL ONLY
@@ -248,6 +264,8 @@
}
+#endif
+
namespace units {
namespace detail {
@@ -289,6 +307,8 @@
} // namespace units
+#ifndef BOOST_UNITS_DOXYGEN
+
namespace mpl {
/// INTERNAL ONLY
@@ -374,6 +394,8 @@
} // namespace mpl
+#endif
+
} // namespace boost
#endif
Modified: sandbox/units/boost/units/static_rational.hpp
==============================================================================
--- sandbox/units/boost/units/static_rational.hpp (original)
+++ sandbox/units/boost/units/static_rational.hpp 2008-05-13 19:19:39 EDT (Tue, 13 May 2008)
@@ -55,11 +55,11 @@
prevents instantiation of zero denominators (i.e. @c static_rational<N,0>). The following compile-time
arithmetic operators are provided for static_rational variables only (no operators are defined between
long and static_rational):
- - @c static_negate
- - @c static_add
- - @c static_subtract
- - @c static_multiply
- - @c static_divide
+ - @c mpl::negate
+ - @c mpl::plus
+ - @c mpl::minus
+ - @c mpl::times
+ - @c mpl::divides
Neither @c static_power nor @c static_root are defined for @c static_rational. This is because template types
may not be floating point values, while powers and roots of rational numbers can produce floating point
@@ -84,6 +84,7 @@
static const integer_type Numerator = N/den,
Denominator = D/den;
+ /// INTERNAL ONLY
typedef static_rational<N,D> this_type;
/// static_rational<N,D> reduced by GCD
@@ -92,6 +93,7 @@
static integer_type numerator() { return Numerator; }
static integer_type denominator() { return Denominator; }
+ // INTERNAL ONLY
static_rational() { }
//~static_rational() { }
@@ -140,6 +142,8 @@
return power_dimof_helper<Y,static_rational<N> >::value(x);
}
+#ifndef BOOST_UNITS_DOXYGEN
+
/// raise @c T to a @c static_rational power
template<class T, long N,long D>
struct power_dimof_helper<T, static_rational<N,D> >
@@ -154,11 +158,13 @@
}
};
-/// raise @c int to a @c static_rational power
+/// raise @c float to a @c static_rational power
template<long N,long D>
struct power_dimof_helper<float, static_rational<N,D> >
: power_dimof_helper<double, static_rational<N,D> > {};
+#endif
+
/// take the @c static_rational root of a value
template<class Rat,class Y>
typename root_typeof_helper<Y,Rat>::type
@@ -175,13 +181,19 @@
return root_typeof_helper<Y,static_rational<N> >::value(x);
}
+#ifndef BOOST_UNITS_DOXYGEN
+
/// take @c static_rational root of an @c T
template<class T, long N,long D>
struct root_typeof_helper<T,static_rational<N,D> >
: power_dimof_helper<T, static_rational<D,N> > {};
+#endif
+
} // namespace units
+#ifndef BOOST_UNITS_DOXYGEN
+
namespace mpl {
template<>
@@ -254,6 +266,8 @@
}
+#endif
+
} // namespace boost
#endif // BOOST_UNITS_STATIC_RATIONAL_HPP
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