mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-07 08:24:53 -04:00
Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
/// \file
|
||||
/// \brief base dimensions (mass, length, time...).
|
||||
/// \details base dimension definition registration.
|
||||
|
||||
#ifndef BOOST_UNITS_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/dim.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/detail/dimension_list.hpp>
|
||||
#include <boost/units/detail/ordinal.hpp>
|
||||
#include <boost/units/detail/prevent_redefinition.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// This must be in namespace boost::units so that ADL
|
||||
/// will work with friend functions defined inline.
|
||||
/// INTERNAL ONLY
|
||||
template<long N> struct base_dimension_ordinal { };
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T, long N> struct base_dimension_pair { };
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T, long N>
|
||||
struct check_base_dimension {
|
||||
enum {
|
||||
value =
|
||||
sizeof(boost_units_is_registered(units::base_dimension_ordinal<N>())) == sizeof(detail::yes) &&
|
||||
sizeof(boost_units_is_registered(units::base_dimension_pair<T, N>())) != sizeof(detail::yes)
|
||||
};
|
||||
};
|
||||
|
||||
/// Defines a base dimension. To define a dimension you need to provide
|
||||
/// the derived class (CRTP) and a unique integer.
|
||||
/// @code
|
||||
/// struct my_dimension : boost::units::base_dimension<my_dimension, 1> {};
|
||||
/// @endcode
|
||||
/// It is designed so that you will get an error message if you try
|
||||
/// to use the same value in multiple definitions.
|
||||
template<class Derived,
|
||||
long N
|
||||
#if !defined(BOOST_UNITS_DOXYGEN) && !defined(__BORLANDC__)
|
||||
,
|
||||
class = typename detail::ordinal_has_already_been_defined<
|
||||
check_base_dimension<Derived, N>::value
|
||||
>::type
|
||||
#endif
|
||||
>
|
||||
class base_dimension :
|
||||
public ordinal<N>
|
||||
{
|
||||
public:
|
||||
/// INTERNAL ONLY
|
||||
typedef base_dimension this_type;
|
||||
/// A convenience typedef. Equivalent to boost::units::derived_dimension<Derived,1>::type.
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
typedef list<dim<Derived,static_rational<1> >, dimensionless_type> dimension_type;
|
||||
#else
|
||||
typedef detail::unspecified dimension_type;
|
||||
#endif
|
||||
/// Provided for mpl compatability.
|
||||
typedef Derived type;
|
||||
|
||||
private:
|
||||
/// Check for C++0x. In C++0x, we have to have identical
|
||||
/// arguments but a different return type to trigger an
|
||||
/// error. Note that this is only needed for clang as
|
||||
/// check_base_dimension will trigger an error earlier
|
||||
/// for compilers with less strict name lookup.
|
||||
/// INTERNAL ONLY
|
||||
friend Derived*
|
||||
check_double_register(const units::base_dimension_ordinal<N>&)
|
||||
{ return(0); }
|
||||
|
||||
/// Register this ordinal
|
||||
/// INTERNAL ONLY
|
||||
friend detail::yes
|
||||
boost_units_is_registered(const units::base_dimension_ordinal<N>&)
|
||||
{ detail::yes result; return(result); }
|
||||
|
||||
/// But make sure we can identify the current instantiation!
|
||||
/// INTERNAL ONLY
|
||||
friend detail::yes
|
||||
boost_units_is_registered(const units::base_dimension_pair<Derived, N>&)
|
||||
{ detail::yes result; return(result); }
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,128 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
/// \file
|
||||
/// \brief base unit (meter, kg, sec...).
|
||||
/// \details base unit definition registration.
|
||||
|
||||
#ifndef BOOST_UNITS_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_BASE_UNIT_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/heterogeneous_system.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/unit.hpp>
|
||||
#include <boost/units/detail/dimension_list.hpp>
|
||||
#include <boost/units/detail/ordinal.hpp>
|
||||
#include <boost/units/detail/prevent_redefinition.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// This must be in namespace boost::units so that ADL
|
||||
/// will work with friend functions defined inline.
|
||||
/// Base dimensions and base units are independent.
|
||||
/// INTERNAL ONLY
|
||||
template<long N> struct base_unit_ordinal { };
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T, long N> struct base_unit_pair { };
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T, long N>
|
||||
struct check_base_unit {
|
||||
enum {
|
||||
value =
|
||||
sizeof(boost_units_unit_is_registered(units::base_unit_ordinal<N>())) == sizeof(detail::yes) &&
|
||||
sizeof(boost_units_unit_is_registered(units::base_unit_pair<T, N>())) != sizeof(detail::yes)
|
||||
};
|
||||
};
|
||||
|
||||
/// Defines a base unit. To define a unit you need to provide
|
||||
/// the derived class (CRTP), a dimension list and a unique integer.
|
||||
/// @code
|
||||
/// struct my_unit : boost::units::base_unit<my_unit, length_dimension, 1> {};
|
||||
/// @endcode
|
||||
/// It is designed so that you will get an error message if you try
|
||||
/// to use the same value in multiple definitions.
|
||||
template<class Derived,
|
||||
class Dim,
|
||||
long N
|
||||
#if !defined(BOOST_UNITS_DOXYGEN) && !defined(__BORLANDC__)
|
||||
,
|
||||
class = typename detail::ordinal_has_already_been_defined<
|
||||
check_base_unit<Derived, N>::value
|
||||
>::type
|
||||
#endif
|
||||
>
|
||||
class base_unit :
|
||||
public ordinal<N>
|
||||
{
|
||||
public:
|
||||
/// INTERNAL ONLY
|
||||
typedef void boost_units_is_base_unit_type;
|
||||
/// INTERNAL ONLY
|
||||
typedef base_unit this_type;
|
||||
/// The dimensions of this base unit.
|
||||
typedef Dim dimension_type;
|
||||
|
||||
/// Provided for mpl compatability.
|
||||
typedef Derived type;
|
||||
|
||||
/// The unit corresponding to this base unit.
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
typedef unit<
|
||||
Dim,
|
||||
heterogeneous_system<
|
||||
heterogeneous_system_impl<
|
||||
list<
|
||||
heterogeneous_system_dim<Derived,static_rational<1> >,
|
||||
dimensionless_type
|
||||
>,
|
||||
Dim,
|
||||
no_scale
|
||||
>
|
||||
>
|
||||
> unit_type;
|
||||
#else
|
||||
typedef detail::unspecified unit_type;
|
||||
#endif
|
||||
|
||||
private:
|
||||
/// Check for C++0x. In C++0x, we have to have identical
|
||||
/// arguments but a different return type to trigger an
|
||||
/// error. Note that this is only needed for clang as
|
||||
/// check_base_unit will trigger an error earlier
|
||||
/// for compilers with less strict name lookup.
|
||||
/// INTERNAL ONLY
|
||||
friend Derived*
|
||||
check_double_register(const units::base_unit_ordinal<N>&)
|
||||
{ return(0); }
|
||||
|
||||
/// Register this ordinal
|
||||
/// INTERNAL ONLY
|
||||
friend detail::yes
|
||||
boost_units_unit_is_registered(const units::base_unit_ordinal<N>&)
|
||||
{ detail::yes result; return(result); }
|
||||
|
||||
/// But make sure we can identify the current instantiation!
|
||||
/// INTERNAL ONLY
|
||||
friend detail::yes
|
||||
boost_units_unit_is_registered(const units::base_unit_pair<Derived, N>&)
|
||||
{ detail::yes result; return(result); }
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,48 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ANGLE_RADIAN_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_ANGLE_RADIAN_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/plane_angle.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace angle {
|
||||
|
||||
struct radian_base_unit : public base_unit<radian_base_unit, plane_angle_dimension, -2>
|
||||
{
|
||||
static std::string name() { return("radian"); }
|
||||
static std::string symbol() { return("rad"); }
|
||||
};
|
||||
|
||||
} // namespace angle
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::angle::radian_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/angle/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_ANGLE_RADIAN_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,48 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ANGLE_STERADIAN_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_ANGLE_STERADIAN_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/solid_angle.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace angle {
|
||||
|
||||
struct steradian_base_unit : public base_unit<steradian_base_unit, solid_angle_dimension, -1>
|
||||
{
|
||||
static std::string name() { return("steradian"); }
|
||||
static std::string symbol() { return("sr"); }
|
||||
};
|
||||
|
||||
} // namespace angle
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::angle::steradian_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/angle/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_ANGLE_STERADIAN_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_CGS_GRAM_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_CGS_GRAM_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/scaled_base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace cgs {
|
||||
|
||||
struct gram_base_unit : public base_unit<gram_base_unit, mass_dimension, -8>
|
||||
{
|
||||
static std::string name() { return("gram"); }
|
||||
static std::string symbol() { return("g"); }
|
||||
};
|
||||
|
||||
} // namespace cgs
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::cgs::gram_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/detail/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_CGS_GRAM_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,48 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_AMPERE_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_SI_AMPERE_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
struct ampere_base_unit : public base_unit<ampere_base_unit, current_dimension, -6>
|
||||
{
|
||||
static std::string name() { return("ampere"); }
|
||||
static std::string symbol() { return("A"); }
|
||||
};
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::si::ampere_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/detail/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_SI_AMPERE_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,48 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_CANDELA_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_SI_CANDELA_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/luminous_intensity.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
struct candela_base_unit : public base_unit<candela_base_unit, luminous_intensity_dimension, -3>
|
||||
{
|
||||
static std::string name() { return("candela"); }
|
||||
static std::string symbol() { return("cd"); }
|
||||
};
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::si::candela_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/detail/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_SI_CANDELA_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,48 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_KELVIN_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_SI_KELVIN_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/temperature.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
struct kelvin_base_unit : public base_unit<kelvin_base_unit, temperature_dimension, -5>
|
||||
{
|
||||
static std::string name() { return("kelvin"); }
|
||||
static std::string symbol() { return("K"); }
|
||||
};
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::si::kelvin_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/detail/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_SI_KELVIN_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,31 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_KILOGRAM_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_SI_KILOGRAM_BASE_UNIT_HPP
|
||||
|
||||
#include <boost/units/scaled_base_unit.hpp>
|
||||
#include <boost/units/base_units/cgs/gram.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
typedef scaled_base_unit<boost::units::cgs::gram_base_unit, scale<10, static_rational<3> > > kilogram_base_unit;
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_SI_KILOGRAM_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,50 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_METER_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_SI_METER_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/scaled_base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
struct meter_base_unit : public base_unit<meter_base_unit, length_dimension, -9>
|
||||
{
|
||||
static std::string name() { return("meter"); }
|
||||
static std::string symbol() { return("m"); }
|
||||
};
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::si::meter_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/detail/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_SI_METER_BASE_UNIT_HPP
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_MOLE_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_SI_MOLE_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/amount.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
struct mole_base_unit : public base_unit<mole_base_unit, amount_dimension, -4>
|
||||
{
|
||||
static std::string name() { return("mole"); }
|
||||
static std::string symbol() { return("mol"); }
|
||||
};
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::si::mole_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/detail/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_SI_MOLE_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,48 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_SECOND_BASE_UNIT_HPP
|
||||
#define BOOST_UNITS_SI_SECOND_BASE_UNIT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_unit.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
struct second_base_unit : public base_unit<second_base_unit, time_dimension, -7>
|
||||
{
|
||||
static std::string name() { return("second"); }
|
||||
static std::string symbol() { return("s"); }
|
||||
};
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::si::second_base_unit)
|
||||
|
||||
#endif
|
||||
|
||||
//#include <boost/units/base_units/detail/conversions.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_SI_SECOND_BASE_UNIT_HPP
|
||||
@@ -0,0 +1,98 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_CONFIG_HPP
|
||||
#define BOOST_UNITS_CONFIG_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#ifndef BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
#if (BOOST_VERSION >= 103400)
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_HAS_BOOST_TYPEOF 1
|
||||
#else
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_HAS_BOOST_TYPEOF 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (BOOST_UNITS_HAS_BOOST_TYPEOF)
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_HAS_TYPEOF 1
|
||||
#else
|
||||
#if (__GNUC__ && __cplusplus)
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_HAS_TYPEOF 1
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_HAS_GNU_TYPEOF 1
|
||||
#elif defined(__MWERKS__)
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_HAS_TYPEOF 1
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_HAS_MWERKS_TYPEOF 1
|
||||
#else
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_HAS_TYPEOF 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// uncomment this to test without typeof support at all
|
||||
//#undef BOOST_UNITS_HAS_TYPEOF
|
||||
//#define BOOST_UNITS_HAS_TYPEOF 0
|
||||
|
||||
#ifndef BOOST_UNITS_NO_COMPILER_CHECK
|
||||
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATES
|
||||
#error Boost.Units requires member template
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_KEYWORD
|
||||
#error Boost.Units requires member template keyword
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
#error Boost.Units requires in class member initialization
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#error Boost.Units requires function template partial ordering
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_UNITS_REQUIRE_LAYOUT_COMPATIBILITY
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(a, b) BOOST_STATIC_ASSERT((sizeof(a) == sizeof(b)))
|
||||
#else
|
||||
///INTERNAL ONLY
|
||||
#define BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(a, b) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_UNITS_DOXYGEN
|
||||
|
||||
/// If defined will trigger a static assertion if quantity<Unit, T>
|
||||
/// is not layout compatible with T
|
||||
#define BOOST_UNITS_REQUIRE_LAYOUT_COMPATIBILITY
|
||||
|
||||
/// If defined will disable a preprocessor check that the
|
||||
/// 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
|
||||
@@ -0,0 +1,185 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_CONVERSION_HPP
|
||||
#define BOOST_UNITS_CONVERSION_HPP
|
||||
|
||||
/// \file
|
||||
/// \brief Template for defining conversions between quantities.
|
||||
|
||||
#include <boost/units/detail/conversion_impl.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class From, class To>
|
||||
struct conversion_helper;
|
||||
|
||||
#ifdef BOOST_UNITS_DOXYGEN
|
||||
|
||||
/// Template for defining conversions between
|
||||
/// quantities. This template should be specialized
|
||||
/// for every quantity that allows conversions.
|
||||
/// For example, if you have a two units
|
||||
/// called pair and dozen you would write
|
||||
/// @code
|
||||
/// namespace boost {
|
||||
/// namespace units {
|
||||
/// template<class T0, class T1>
|
||||
/// struct conversion_helper<quantity<dozen, T0>, quantity<pair, T1> >
|
||||
/// {
|
||||
/// static quantity<pair, T1> convert(const quantity<dozen, T0>& source)
|
||||
/// {
|
||||
/// return(quantity<pair, T1>::from_value(6 * source.value()));
|
||||
/// }
|
||||
/// };
|
||||
/// }
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
/// In most cases, the predefined specializations for @c unit
|
||||
/// and @c absolute should be sufficient, so users should rarely
|
||||
/// need to use this.
|
||||
template<class From, class To>
|
||||
struct conversion_helper
|
||||
{
|
||||
static To convert(const From&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/// Defines the conversion factor from a base unit to any unit
|
||||
/// or to another base unit with the correct dimensions. Uses
|
||||
/// of this macro must appear at global scope.
|
||||
/// If the destination unit is a base unit or a unit that contains
|
||||
/// only one base unit which is raised to the first power (e.g. feet->meters)
|
||||
/// the reverse (meters->feet in this example) need not be defined explicitly.
|
||||
#define BOOST_UNITS_DEFINE_CONVERSION_FACTOR(Source, Destination, type_, value_) \
|
||||
namespace boost { \
|
||||
namespace units { \
|
||||
template<> \
|
||||
struct select_base_unit_converter< \
|
||||
unscale<Source>::type, \
|
||||
unscale<reduce_unit<Destination::unit_type>::type>::type \
|
||||
> \
|
||||
{ \
|
||||
typedef Source source_type; \
|
||||
typedef reduce_unit<Destination::unit_type>::type destination_type; \
|
||||
}; \
|
||||
template<> \
|
||||
struct base_unit_converter<Source, reduce_unit<Destination::unit_type>::type> \
|
||||
{ \
|
||||
static const bool is_defined = true; \
|
||||
typedef type_ type; \
|
||||
static type value() { return(value_); } \
|
||||
}; \
|
||||
} \
|
||||
} \
|
||||
void boost_units_require_semicolon()
|
||||
|
||||
/// Defines the conversion factor from a base unit to any other base
|
||||
/// unit with the same dimensions. Params should be a Boost.Preprocessor
|
||||
/// Seq of template parameters, such as (class T1)(class T2)
|
||||
/// All uses of must appear at global scope. The reverse conversion will
|
||||
/// be defined automatically. This macro is a little dangerous, because,
|
||||
/// unlike the non-template form, it will silently fail if either base
|
||||
/// unit is scaled. This is probably not an issue if both the source
|
||||
/// and destination types depend on the template parameters, but be aware
|
||||
/// that a generic conversion to kilograms is not going to work.
|
||||
#define BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE(Params, Source, Destination, type_, value_) \
|
||||
namespace boost { \
|
||||
namespace units { \
|
||||
template<BOOST_PP_SEQ_ENUM(Params)> \
|
||||
struct base_unit_converter< \
|
||||
Source, \
|
||||
BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Destination, typename Source::dimension_type)\
|
||||
> \
|
||||
{ \
|
||||
static const bool is_defined = true; \
|
||||
typedef type_ type; \
|
||||
static type value() { return(value_); } \
|
||||
}; \
|
||||
} \
|
||||
} \
|
||||
void boost_units_require_semicolon()
|
||||
|
||||
/// Specifies the default conversion to be applied when
|
||||
/// no direct conversion is available.
|
||||
/// Source is a base unit. Dest is any unit with the
|
||||
/// same dimensions.
|
||||
#define BOOST_UNITS_DEFAULT_CONVERSION(Source, Dest) \
|
||||
namespace boost { \
|
||||
namespace units { \
|
||||
template<> \
|
||||
struct unscaled_get_default_conversion<unscale<Source>::type> \
|
||||
{ \
|
||||
static const bool is_defined = true; \
|
||||
typedef Dest::unit_type type; \
|
||||
}; \
|
||||
} \
|
||||
} \
|
||||
void boost_units_require_semicolon()
|
||||
|
||||
/// Specifies the default conversion to be applied when
|
||||
/// no direct conversion is available.
|
||||
/// Params is a PP Sequence of template arguments.
|
||||
/// Source is a base unit. Dest is any unit with the
|
||||
/// same dimensions. The source must not be a scaled
|
||||
/// base unit.
|
||||
#define BOOST_UNITS_DEFAULT_CONVERSION_TEMPLATE(Params, Source, Dest) \
|
||||
namespace boost { \
|
||||
namespace units { \
|
||||
template<BOOST_PP_SEQ_ENUM(Params)> \
|
||||
struct unscaled_get_default_conversion<Source> \
|
||||
{ \
|
||||
static const bool is_defined = true; \
|
||||
typedef typename Dest::unit_type type; \
|
||||
}; \
|
||||
} \
|
||||
} \
|
||||
void boost_units_require_semicolon()
|
||||
|
||||
/// INTERNAL ONLY
|
||||
/// Users should not create their units in namespace boost::units.
|
||||
/// If we want to make this public it needs to allow better control over
|
||||
/// the namespaces. --SJW.
|
||||
/// template that defines a base_unit and conversion to another dimensionally-consistent unit
|
||||
#define BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(namespace_, name_, name_string_, symbol_string_, factor, unit, id)\
|
||||
namespace boost { \
|
||||
namespace units { \
|
||||
namespace namespace_ { \
|
||||
struct name_ ## _base_unit \
|
||||
: base_unit<name_ ## _base_unit, unit::dimension_type, id> { \
|
||||
static const char* name() { return(name_string_); } \
|
||||
static const char* symbol() { return(symbol_string_); } \
|
||||
}; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
BOOST_UNITS_DEFINE_CONVERSION_FACTOR(namespace_::name_ ## _base_unit, unit, double, factor); \
|
||||
BOOST_UNITS_DEFAULT_CONVERSION(namespace_::name_ ## _base_unit, unit)
|
||||
|
||||
/// Find the conversion factor between two units.
|
||||
template<class FromUnit,class ToUnit>
|
||||
inline
|
||||
typename one_to_double_type<
|
||||
typename detail::conversion_factor_helper<FromUnit, ToUnit>::type
|
||||
>::type
|
||||
conversion_factor(const FromUnit&,const ToUnit&)
|
||||
{
|
||||
return(one_to_double(detail::conversion_factor_helper<FromUnit, ToUnit>::value()));
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_CONVERSION_HPP
|
||||
@@ -0,0 +1,208 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/dim.hpp>
|
||||
#include <boost/units/dimension.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/detail/dimension_list.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// A utility class for defining composite dimensions with integer powers.
|
||||
template<class DT1 = dimensionless_type,long E1 = 0,
|
||||
class DT2 = dimensionless_type,long E2 = 0,
|
||||
class DT3 = dimensionless_type,long E3 = 0,
|
||||
class DT4 = dimensionless_type,long E4 = 0,
|
||||
class DT5 = dimensionless_type,long E5 = 0,
|
||||
class DT6 = dimensionless_type,long E6 = 0,
|
||||
class DT7 = dimensionless_type,long E7 = 0,
|
||||
class DT8 = dimensionless_type,long E8 = 0>
|
||||
struct derived_dimension
|
||||
{
|
||||
#ifdef BOOST_UNITS_DOXYGEN
|
||||
typedef detail::unspecified type;
|
||||
#else
|
||||
typedef typename
|
||||
make_dimension_list< list< dim< DT1,static_rational<E1> >,
|
||||
list< dim< DT2,static_rational<E2> >,
|
||||
list< dim< DT3,static_rational<E3> >,
|
||||
list< dim< DT4,static_rational<E4> >,
|
||||
list< dim< DT5,static_rational<E5> >,
|
||||
list< dim< DT6,static_rational<E6> >,
|
||||
list< dim< DT7,static_rational<E7> >,
|
||||
list< dim< DT8,static_rational<E8> >, dimensionless_type > > > > > > > > >::type type;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class DT1,long E1>
|
||||
struct derived_dimension<
|
||||
DT1, E1,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0>
|
||||
{
|
||||
typedef typename
|
||||
make_dimension_list< list< dim< DT1,static_rational<E1> >, dimensionless_type > >::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class DT1,long E1,
|
||||
class DT2,long E2>
|
||||
struct derived_dimension<
|
||||
DT1, E1,
|
||||
DT2, E2,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0>
|
||||
{
|
||||
typedef typename
|
||||
make_dimension_list< list< dim< DT1,static_rational<E1> >,
|
||||
list< dim< DT2,static_rational<E2> >, dimensionless_type > > >::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class DT1,long E1,
|
||||
class DT2,long E2,
|
||||
class DT3,long E3>
|
||||
struct derived_dimension<
|
||||
DT1, E1,
|
||||
DT2, E2,
|
||||
DT3, E3,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0>
|
||||
{
|
||||
typedef typename
|
||||
make_dimension_list< list< dim< DT1,static_rational<E1> >,
|
||||
list< dim< DT2,static_rational<E2> >,
|
||||
list< dim< DT3,static_rational<E3> >, dimensionless_type > > > >::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class DT1,long E1,
|
||||
class DT2,long E2,
|
||||
class DT3,long E3,
|
||||
class DT4,long E4>
|
||||
struct derived_dimension<
|
||||
DT1, E1,
|
||||
DT2, E2,
|
||||
DT3, E3,
|
||||
DT4, E4,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0>
|
||||
{
|
||||
typedef typename
|
||||
make_dimension_list< list< dim< DT1,static_rational<E1> >,
|
||||
list< dim< DT2,static_rational<E2> >,
|
||||
list< dim< DT3,static_rational<E3> >,
|
||||
list< dim< DT4,static_rational<E4> >, dimensionless_type > > > > >::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class DT1,long E1,
|
||||
class DT2,long E2,
|
||||
class DT3,long E3,
|
||||
class DT4,long E4,
|
||||
class DT5,long E5>
|
||||
struct derived_dimension<
|
||||
DT1, E1,
|
||||
DT2, E2,
|
||||
DT3, E3,
|
||||
DT4, E4,
|
||||
DT5, E5,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0>
|
||||
{
|
||||
typedef typename
|
||||
make_dimension_list< list< dim< DT1,static_rational<E1> >,
|
||||
list< dim< DT2,static_rational<E2> >,
|
||||
list< dim< DT3,static_rational<E3> >,
|
||||
list< dim< DT4,static_rational<E4> >,
|
||||
list< dim< DT5,static_rational<E5> >, dimensionless_type > > > > > >::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class DT1,long E1,
|
||||
class DT2,long E2,
|
||||
class DT3,long E3,
|
||||
class DT4,long E4,
|
||||
class DT5,long E5,
|
||||
class DT6,long E6>
|
||||
struct derived_dimension<
|
||||
DT1, E1,
|
||||
DT2, E2,
|
||||
DT3, E3,
|
||||
DT4, E4,
|
||||
DT5, E5,
|
||||
DT6, E6,
|
||||
dimensionless_type,0,
|
||||
dimensionless_type,0>
|
||||
{
|
||||
typedef typename
|
||||
make_dimension_list< list< dim< DT1,static_rational<E1> >,
|
||||
list< dim< DT2,static_rational<E2> >,
|
||||
list< dim< DT3,static_rational<E3> >,
|
||||
list< dim< DT4,static_rational<E4> >,
|
||||
list< dim< DT5,static_rational<E5> >,
|
||||
list< dim< DT6,static_rational<E6> >, dimensionless_type > > > > > > >::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class DT1,long E1,
|
||||
class DT2,long E2,
|
||||
class DT3,long E3,
|
||||
class DT4,long E4,
|
||||
class DT5,long E5,
|
||||
class DT6,long E6,
|
||||
class DT7,long E7>
|
||||
struct derived_dimension<
|
||||
DT1, E1,
|
||||
DT2, E2,
|
||||
DT3, E3,
|
||||
DT4, E4,
|
||||
DT5, E5,
|
||||
DT6, E6,
|
||||
DT7, E7,
|
||||
dimensionless_type,0>
|
||||
{
|
||||
typedef typename
|
||||
make_dimension_list< list< dim< DT1,static_rational<E1> >,
|
||||
list< dim< DT2,static_rational<E2> >,
|
||||
list< dim< DT3,static_rational<E3> >,
|
||||
list< dim< DT4,static_rational<E4> >,
|
||||
list< dim< DT5,static_rational<E5> >,
|
||||
list< dim< DT6,static_rational<E6> >,
|
||||
list< dim< DT7,static_rational<E7> >, dimensionless_type > > > > > > > >::type type;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,458 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_CONVERSION_IMPL_HPP
|
||||
#define BOOST_UNITS_DETAIL_CONVERSION_IMPL_HPP
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/divides.hpp>
|
||||
#include <boost/preprocessor/seq/enum.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/units/heterogeneous_system.hpp>
|
||||
#include <boost/units/homogeneous_system.hpp>
|
||||
#include <boost/units/reduce_unit.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/detail/dimension_list.hpp>
|
||||
#include <boost/units/detail/heterogeneous_conversion.hpp>
|
||||
#include <boost/units/detail/one.hpp>
|
||||
#include <boost/units/detail/static_rational_power.hpp>
|
||||
#include <boost/units/detail/unscale.hpp>
|
||||
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class Source, class Dest>
|
||||
struct conversion_factor_helper;
|
||||
|
||||
template<class Source, class Dest>
|
||||
struct call_base_unit_converter;
|
||||
|
||||
}
|
||||
|
||||
/// INTERNAL ONLY
|
||||
struct undefined_base_unit_converter_base {
|
||||
static const bool is_defined = false;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
struct no_default_conversion {
|
||||
static const bool is_defined = false;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class BaseUnit>
|
||||
struct unscaled_get_default_conversion : no_default_conversion { };
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<bool is_defined>
|
||||
struct unscaled_get_default_conversion_impl;
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct unscaled_get_default_conversion_impl<true>
|
||||
{
|
||||
template<class T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename unscaled_get_default_conversion<typename unscale<T>::type>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct unscaled_get_default_conversion_impl<false>
|
||||
{
|
||||
template<class T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename T::unit_type type;
|
||||
};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class BaseUnit>
|
||||
struct get_default_conversion
|
||||
{
|
||||
typedef typename unscaled_get_default_conversion_impl<
|
||||
unscaled_get_default_conversion<typename unscale<BaseUnit>::type>::is_defined
|
||||
>::template apply<BaseUnit>::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Source, class Destination>
|
||||
struct select_base_unit_converter
|
||||
{
|
||||
typedef Source source_type;
|
||||
typedef Destination destination_type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Source, class Dest>
|
||||
struct base_unit_converter_base : undefined_base_unit_converter_base {
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Source>
|
||||
struct base_unit_converter_base<Source, BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Source, typename Source::dimension_type)>
|
||||
{
|
||||
static const bool is_defined = true;
|
||||
typedef one type;
|
||||
static type value() {
|
||||
one result;
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Source, class Dest>
|
||||
struct base_unit_converter : base_unit_converter_base<Source, Dest> { };
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class Source, class Dest>
|
||||
struct do_call_base_unit_converter {
|
||||
typedef select_base_unit_converter<typename unscale<Source>::type, typename unscale<Dest>::type> selector;
|
||||
typedef typename selector::source_type source_type;
|
||||
typedef typename selector::destination_type destination_type;
|
||||
typedef base_unit_converter<source_type, destination_type> converter;
|
||||
typedef typename mpl::divides<typename get_scale_list<Source>::type, typename get_scale_list<source_type>::type>::type source_factor;
|
||||
typedef typename mpl::divides<typename get_scale_list<Dest>::type, typename get_scale_list<destination_type>::type>::type destination_factor;
|
||||
typedef typename mpl::divides<source_factor, destination_factor>::type factor;
|
||||
typedef eval_scale_list<factor> eval_factor;
|
||||
typedef typename multiply_typeof_helper<typename converter::type, typename eval_factor::type>::type type;
|
||||
static type value()
|
||||
{
|
||||
return(converter::value() * eval_factor::value());
|
||||
}
|
||||
};
|
||||
|
||||
template<bool forward_is_defined, bool reverse_is_defined>
|
||||
struct call_base_unit_converter_base_unit_impl;
|
||||
|
||||
template<>
|
||||
struct call_base_unit_converter_base_unit_impl<true, true>
|
||||
{
|
||||
template<class Source, class Dest>
|
||||
struct apply
|
||||
: do_call_base_unit_converter<Source, typename Dest::unit_type>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct call_base_unit_converter_base_unit_impl<true, false>
|
||||
{
|
||||
template<class Source, class Dest>
|
||||
struct apply
|
||||
: do_call_base_unit_converter<Source, typename Dest::unit_type>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct call_base_unit_converter_base_unit_impl<false, true>
|
||||
{
|
||||
template<class Source, class Dest>
|
||||
struct apply
|
||||
{
|
||||
typedef do_call_base_unit_converter<Dest, typename Source::unit_type> converter;
|
||||
typedef typename divide_typeof_helper<one, typename converter::type>::type type;
|
||||
static type value() {
|
||||
one numerator;
|
||||
return(numerator / converter::value());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct call_base_unit_converter_base_unit_impl<false, false>
|
||||
{
|
||||
template<class Source, class Dest>
|
||||
struct apply
|
||||
{
|
||||
typedef typename reduce_unit<typename get_default_conversion<Source>::type>::type new_source;
|
||||
typedef typename reduce_unit<typename get_default_conversion<Dest>::type>::type new_dest;
|
||||
typedef call_base_unit_converter<Source, new_source> start;
|
||||
typedef detail::conversion_factor_helper<
|
||||
new_source,
|
||||
new_dest
|
||||
> conversion;
|
||||
typedef call_base_unit_converter<Dest, new_dest> end;
|
||||
typedef typename divide_typeof_helper<
|
||||
typename multiply_typeof_helper<
|
||||
typename start::type,
|
||||
typename conversion::type
|
||||
>::type,
|
||||
typename end::type
|
||||
>::type type;
|
||||
static type value() {
|
||||
return(start::value() * conversion::value() / end::value());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct get_default_conversion_impl
|
||||
{
|
||||
template<class Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Begin::item source_pair;
|
||||
typedef typename source_pair::value_type exponent;
|
||||
typedef typename source_pair::tag_type source;
|
||||
typedef typename reduce_unit<typename get_default_conversion<source>::type>::type new_source;
|
||||
typedef typename get_default_conversion_impl<N-1>::template apply<typename Begin::next> next_iteration;
|
||||
typedef typename multiply_typeof_helper<typename power_typeof_helper<new_source, exponent>::type, typename next_iteration::unit_type>::type unit_type;
|
||||
typedef call_base_unit_converter<source, new_source> conversion;
|
||||
typedef typename multiply_typeof_helper<typename conversion::type, typename next_iteration::type>::type type;
|
||||
static type value() {
|
||||
return(static_rational_power<exponent>(conversion::value()) * next_iteration::value());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_default_conversion_impl<0>
|
||||
{
|
||||
template<class Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef unit<dimensionless_type, heterogeneous_system<heterogeneous_system_impl<dimensionless_type, dimensionless_type, no_scale> > > unit_type;
|
||||
typedef one type;
|
||||
static one value() {
|
||||
one result;
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<bool is_defined>
|
||||
struct call_base_unit_converter_impl;
|
||||
|
||||
template<>
|
||||
struct call_base_unit_converter_impl<true>
|
||||
{
|
||||
template<class Source, class Dest>
|
||||
struct apply
|
||||
: do_call_base_unit_converter<Source, Dest>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct call_base_unit_converter_impl<false>
|
||||
{
|
||||
template<class Source, class Dest>
|
||||
struct apply {
|
||||
typedef typename reduce_unit<typename get_default_conversion<Source>::type>::type new_source;
|
||||
typedef typename Dest::system_type::type system_list;
|
||||
typedef typename get_default_conversion_impl<system_list::size::value>::template apply<system_list> impl;
|
||||
typedef typename impl::unit_type new_dest;
|
||||
typedef call_base_unit_converter<Source, new_source> start;
|
||||
typedef conversion_factor_helper<new_source, new_dest> conversion;
|
||||
typedef typename divide_typeof_helper<
|
||||
typename multiply_typeof_helper<
|
||||
typename start::type,
|
||||
typename conversion::type
|
||||
>::type,
|
||||
typename impl::type
|
||||
>::type type;
|
||||
static type value() {
|
||||
return(start::value() * conversion::value() / impl::value());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#define BOOST_UNITS_DETAIL_BASE_UNIT_CONVERTER_IS_DEFINED(Source, Dest)\
|
||||
base_unit_converter<\
|
||||
typename select_base_unit_converter<typename unscale<Source>::type, typename unscale<Dest>::type>::source_type,\
|
||||
typename select_base_unit_converter<typename unscale<Source>::type, typename unscale<Dest>::type>::destination_type\
|
||||
>::is_defined
|
||||
|
||||
template<class Source, class Dest>
|
||||
struct call_base_unit_converter : call_base_unit_converter_impl<BOOST_UNITS_DETAIL_BASE_UNIT_CONVERTER_IS_DEFINED(Source, Dest)>::template apply<Source, Dest>
|
||||
{
|
||||
};
|
||||
|
||||
template<class Source, class Dest>
|
||||
struct call_base_unit_converter<Source, BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Dest, typename Source::dimension_type)> :
|
||||
call_base_unit_converter_base_unit_impl<
|
||||
BOOST_UNITS_DETAIL_BASE_UNIT_CONVERTER_IS_DEFINED(Source, typename Dest::unit_type),
|
||||
BOOST_UNITS_DETAIL_BASE_UNIT_CONVERTER_IS_DEFINED(Dest, typename Source::unit_type)
|
||||
>::template apply<Source, Dest>
|
||||
{
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct conversion_impl
|
||||
{
|
||||
template<class Begin, class DestinationSystem>
|
||||
struct apply
|
||||
{
|
||||
typedef typename conversion_impl<N-1>::template apply<
|
||||
typename Begin::next,
|
||||
DestinationSystem
|
||||
> next_iteration;
|
||||
typedef typename Begin::item unit_pair;
|
||||
typedef typename unit_pair::tag_type unit;
|
||||
typedef typename unit::dimension_type dimensions;
|
||||
typedef typename reduce_unit<units::unit<dimensions, DestinationSystem> >::type reduced_unit;
|
||||
typedef detail::call_base_unit_converter<unit, reduced_unit> converter;
|
||||
typedef typename multiply_typeof_helper<typename converter::type, typename next_iteration::type>::type type;
|
||||
static type value() { return(static_rational_power<typename unit_pair::value_type>(converter::value()) * next_iteration::value()); }
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct conversion_impl<0>
|
||||
{
|
||||
template<class Begin, class DestinationSystem>
|
||||
struct apply
|
||||
{
|
||||
typedef one type;
|
||||
static type value() { one result; return(result); }
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// forward to conversion_factor (intentionally allowing ADL)
|
||||
/// INTERNAL ONLY
|
||||
template<class Unit1, class T1, class Unit2, class T2>
|
||||
struct conversion_helper<quantity<Unit1, T1>, quantity<Unit2, T2> >
|
||||
{
|
||||
/// INTERNAL ONLY
|
||||
typedef quantity<Unit2, T2> destination_type;
|
||||
static destination_type convert(const quantity<Unit1, T1>& source)
|
||||
{
|
||||
Unit1 u1;
|
||||
Unit2 u2;
|
||||
return(destination_type::from_value(static_cast<T2>(source.value() * conversion_factor(u1, u2))));
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class Source, class Dest>
|
||||
struct conversion_factor_helper;
|
||||
|
||||
template<class D, class L1, class L2>
|
||||
struct conversion_factor_helper<unit<D, homogeneous_system<L1> >, unit<D, homogeneous_system<L2> > >
|
||||
: conversion_factor_helper<
|
||||
typename reduce_unit<unit<D, homogeneous_system<L1> > >::type,
|
||||
typename reduce_unit<unit<D, homogeneous_system<L2> > >::type
|
||||
>
|
||||
{
|
||||
//typedef typename reduce_unit<unit<D, homogeneous_system<L1> > >::type source_unit;
|
||||
//typedef typename source_unit::system_type::type unit_list;
|
||||
//typedef typename detail::conversion_impl<unit_list::size::value>::template apply<
|
||||
// unit_list,
|
||||
// homogeneous_system<L2>
|
||||
//> impl;
|
||||
//typedef typename impl::type type;
|
||||
//static type value()
|
||||
//{
|
||||
// return(impl::value());
|
||||
//}
|
||||
};
|
||||
|
||||
template<class D, class L1, class L2>
|
||||
struct conversion_factor_helper<unit<D, heterogeneous_system<L1> >, unit<D, homogeneous_system<L2> > >
|
||||
: conversion_factor_helper<
|
||||
typename reduce_unit<unit<D, heterogeneous_system<L1> > >::type,
|
||||
typename reduce_unit<unit<D, homogeneous_system<L2> > >::type
|
||||
>
|
||||
{
|
||||
//typedef typename detail::conversion_impl<L1::type::size::value>::template apply<
|
||||
// typename L1::type,
|
||||
// homogeneous_system<L2>
|
||||
//> impl;
|
||||
//typedef eval_scale_list<typename L1::scale> scale;
|
||||
//typedef typename multiply_typeof_helper<typename impl::type, typename scale::type>::type type;
|
||||
//static type value()
|
||||
//{
|
||||
// return(impl::value() * scale::value());
|
||||
//}
|
||||
};
|
||||
|
||||
// There is no simple algorithm for doing this conversion
|
||||
// other than just defining it as the reverse of the
|
||||
// heterogeneous->homogeneous case
|
||||
template<class D, class L1, class L2>
|
||||
struct conversion_factor_helper<unit<D, homogeneous_system<L1> >, unit<D, heterogeneous_system<L2> > >
|
||||
: conversion_factor_helper<
|
||||
typename reduce_unit<unit<D, homogeneous_system<L1> > >::type,
|
||||
typename reduce_unit<unit<D, heterogeneous_system<L2> > >::type
|
||||
>
|
||||
{
|
||||
//typedef typename detail::conversion_impl<L2::type::size::value>::template apply<
|
||||
// typename L2::type,
|
||||
// homogeneous_system<L1>
|
||||
//> impl;
|
||||
//typedef eval_scale_list<typename L2::scale> scale;
|
||||
//typedef typename multiply_typeof_helper<typename impl::type, typename scale::type>::type type;
|
||||
//static type value()
|
||||
//{
|
||||
// one numerator;
|
||||
// return(numerator / (impl::value() * scale::value()));
|
||||
//}
|
||||
};
|
||||
|
||||
/// Requires that all possible conversions
|
||||
/// between base units are defined.
|
||||
template<class D, class S1, class S2>
|
||||
struct conversion_factor_helper<unit<D, heterogeneous_system<S1> >, unit<D, heterogeneous_system<S2> > >
|
||||
{
|
||||
/// INTERNAL ONLY
|
||||
typedef typename detail::extract_base_units<S1::type::size::value>::template apply<
|
||||
typename S1::type,
|
||||
dimensionless_type
|
||||
>::type from_base_units;
|
||||
/// INTERNAL ONLY
|
||||
typedef typename detail::extract_base_units<S2::type::size::value>::template apply<
|
||||
typename S2::type,
|
||||
from_base_units
|
||||
>::type all_base_units;
|
||||
/// INTERNAL ONLY
|
||||
typedef typename detail::make_homogeneous_system<all_base_units>::type system;
|
||||
typedef typename detail::conversion_impl<S1::type::size::value>::template apply<
|
||||
typename S1::type,
|
||||
system
|
||||
> conversion1;
|
||||
typedef typename detail::conversion_impl<S2::type::size::value>::template apply<
|
||||
typename S2::type,
|
||||
system
|
||||
> conversion2;
|
||||
typedef eval_scale_list<typename mpl::divides<typename S1::scale, typename S2::scale>::type> scale;
|
||||
typedef typename multiply_typeof_helper<
|
||||
typename conversion1::type,
|
||||
typename divide_typeof_helper<typename scale::type, typename conversion2::type>::type
|
||||
>::type type;
|
||||
static type value()
|
||||
{
|
||||
return(conversion1::value() * (scale::value() / conversion2::value()));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_CONVERSION_IMPL_HPP
|
||||
@@ -0,0 +1,90 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DIM_IMPL_HPP
|
||||
#define BOOST_UNITS_DIM_IMPL_HPP
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
|
||||
/// \file
|
||||
/// \brief Class encapsulating a dimension tag/value pair
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct dim_tag;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace mpl {
|
||||
|
||||
/// Less than comparison for sorting @c dim.
|
||||
template<>
|
||||
struct less_impl<boost::units::detail::dim_tag, boost::units::detail::dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply : mpl::less<typename T0::tag_type, typename T1::tag_type> {};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class Tag, class Exponent>
|
||||
struct dim;
|
||||
|
||||
template<long N, long D>
|
||||
class static_rational;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/// Extract @c tag_type from a @c dim.
|
||||
template<typename T>
|
||||
struct get_tag
|
||||
{
|
||||
typedef typename T::tag_type type;
|
||||
};
|
||||
|
||||
/// Extract @c value_type from a @c dim.
|
||||
template<typename T>
|
||||
struct get_value
|
||||
{
|
||||
typedef typename T::value_type type;
|
||||
};
|
||||
|
||||
/// Determine if a @c dim is empty (has a zero exponent).
|
||||
template<class T>
|
||||
struct is_empty_dim;
|
||||
|
||||
template<typename T>
|
||||
struct is_empty_dim< dim<T, static_rational<0, 1> > > :
|
||||
mpl::true_
|
||||
{ };
|
||||
|
||||
template<typename T, typename V>
|
||||
struct is_empty_dim< dim<T, V> > :
|
||||
mpl::false_
|
||||
{ };
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_DIM_IMPL_HPP
|
||||
@@ -0,0 +1,347 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DIMENSION_IMPL_HPP
|
||||
#define BOOST_UNITS_DIMENSION_IMPL_HPP
|
||||
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/list.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/dimensionless_type.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/detail/dimension_list.hpp>
|
||||
#include <boost/units/detail/push_front_if.hpp>
|
||||
#include <boost/units/detail/push_front_or_add.hpp>
|
||||
|
||||
/// \file
|
||||
/// \brief Core class and metaprogramming utilities for compile-time dimensional analysis.
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<int N>
|
||||
struct insertion_sort_dims_insert;
|
||||
|
||||
template<bool is_greater>
|
||||
struct insertion_sort_dims_comparison_impl;
|
||||
|
||||
// have to recursively add the element to the next sequence.
|
||||
template<>
|
||||
struct insertion_sort_dims_comparison_impl<true> {
|
||||
template<class Begin, int N, class T>
|
||||
struct apply {
|
||||
typedef list<
|
||||
typename Begin::item,
|
||||
typename insertion_sort_dims_insert<N - 1>::template apply<
|
||||
typename Begin::next,
|
||||
T
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
// either prepend the current element or join it to
|
||||
// the first remaining element of the sequence.
|
||||
template<>
|
||||
struct insertion_sort_dims_comparison_impl<false> {
|
||||
template<class Begin, int N, class T>
|
||||
struct apply {
|
||||
typedef typename push_front_or_add<Begin, T>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct insertion_sort_dims_insert {
|
||||
template<class Begin, class T>
|
||||
struct apply {
|
||||
typedef typename insertion_sort_dims_comparison_impl<mpl::less<typename Begin::item, T>::value>::template apply<
|
||||
Begin,
|
||||
N,
|
||||
T
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct insertion_sort_dims_insert<0> {
|
||||
template<class Begin, class T>
|
||||
struct apply {
|
||||
typedef list<T, dimensionless_type> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct insertion_sort_dims_mpl_sequence {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef typename insertion_sort_dims_mpl_sequence<N - 1>::template apply<typename mpl::next<Begin>::type>::type next;
|
||||
typedef typename insertion_sort_dims_insert<(next::size::value)>::template apply<next, typename mpl::deref<Begin>::type>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct insertion_sort_dims_mpl_sequence<0> {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct insertion_sort_dims_impl {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef typename insertion_sort_dims_impl<N - 1>::template apply<typename Begin::next>::type next;
|
||||
typedef typename insertion_sort_dims_insert<(next::size::value)>::template apply<next, typename Begin::item>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct insertion_sort_dims_impl<0> {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct sort_dims
|
||||
{
|
||||
typedef typename insertion_sort_dims_mpl_sequence<mpl::size<T>::value>::template apply<typename mpl::begin<T>::type>::type type;
|
||||
};
|
||||
|
||||
|
||||
template<class T, class Next>
|
||||
struct sort_dims<list<T, Next> >
|
||||
{
|
||||
typedef typename insertion_sort_dims_impl<list<T, Next>::size::value>::template apply<list<T, Next> >::type type;
|
||||
};
|
||||
|
||||
/// sorted sequences can be merged in linear time
|
||||
template<bool less, bool greater>
|
||||
struct merge_dimensions_func;
|
||||
|
||||
template<int N1, int N2>
|
||||
struct merge_dimensions_impl;
|
||||
|
||||
template<>
|
||||
struct merge_dimensions_func<true, false>
|
||||
{
|
||||
template<typename Begin1, typename Begin2, int N1, int N2>
|
||||
struct apply
|
||||
{
|
||||
typedef list<
|
||||
typename Begin1::item,
|
||||
typename merge_dimensions_impl<N1 - 1, N2>::template apply<
|
||||
typename Begin1::next,
|
||||
Begin2
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct merge_dimensions_func<false, true> {
|
||||
template<typename Begin1, typename Begin2, int N1, int N2>
|
||||
struct apply
|
||||
{
|
||||
typedef list<
|
||||
typename Begin2::item,
|
||||
typename merge_dimensions_impl<N2 - 1, N1>::template apply<
|
||||
typename Begin2::next,
|
||||
Begin1
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct merge_dimensions_func<false, false> {
|
||||
template<typename Begin1, typename Begin2, int N1, int N2>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::plus<typename Begin1::item, typename Begin2::item>::type combined;
|
||||
typedef typename push_front_if<!is_empty_dim<combined>::value>::template apply<
|
||||
typename merge_dimensions_impl<N1 - 1, N2 - 1>::template apply<
|
||||
typename Begin1::next,
|
||||
typename Begin2::next
|
||||
>::type,
|
||||
combined
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N1, int N2>
|
||||
struct merge_dimensions_impl {
|
||||
template<typename Begin1, typename Begin2>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Begin1::item dim1;
|
||||
typedef typename Begin2::item dim2;
|
||||
|
||||
typedef typename merge_dimensions_func<(mpl::less<dim1,dim2>::value == true),
|
||||
(mpl::less<dim2,dim1>::value == true)>::template apply<
|
||||
Begin1,
|
||||
Begin2,
|
||||
N1,
|
||||
N2
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Sequence1, typename Sequence2>
|
||||
struct merge_dimensions
|
||||
{
|
||||
typedef typename detail::merge_dimensions_impl<Sequence1::size::value,
|
||||
Sequence2::size::value>::template
|
||||
apply<
|
||||
Sequence1,
|
||||
Sequence2
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct iterator_to_list
|
||||
{
|
||||
template<typename Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef list<
|
||||
typename Begin::item,
|
||||
typename iterator_to_list<N - 1>::template apply<
|
||||
typename Begin::next
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct iterator_to_list<0>
|
||||
{
|
||||
template<typename Begin>
|
||||
struct apply {
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct merge_dimensions_impl<N, 0>
|
||||
{
|
||||
template<typename Begin1, typename Begin2>
|
||||
struct apply
|
||||
{
|
||||
typedef typename iterator_to_list<N>::template apply<Begin1>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct merge_dimensions_impl<0, N>
|
||||
{
|
||||
template<typename Begin1, typename Begin2>
|
||||
struct apply
|
||||
{
|
||||
typedef typename iterator_to_list<N>::template apply<Begin2>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct merge_dimensions_impl<0, 0>
|
||||
{
|
||||
template<typename Begin1, typename Begin2>
|
||||
struct apply
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct static_inverse_impl
|
||||
{
|
||||
template<typename Begin>
|
||||
struct apply {
|
||||
typedef list<
|
||||
typename mpl::negate<typename Begin::item>::type,
|
||||
typename static_inverse_impl<N - 1>::template apply<
|
||||
typename Begin::next
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct static_inverse_impl<0>
|
||||
{
|
||||
template<typename Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct static_power_impl
|
||||
{
|
||||
template<typename Begin, typename Ex>
|
||||
struct apply
|
||||
{
|
||||
typedef list<
|
||||
typename mpl::times<typename Begin::item, Ex>::type,
|
||||
typename detail::static_power_impl<N - 1>::template apply<typename Begin::next, Ex>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct static_power_impl<0>
|
||||
{
|
||||
template<typename Begin, typename Ex>
|
||||
struct apply
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct static_root_impl {
|
||||
template<class Begin, class Ex>
|
||||
struct apply {
|
||||
typedef list<
|
||||
typename mpl::divides<typename Begin::item, Ex>::type,
|
||||
typename detail::static_root_impl<N - 1>::template apply<typename Begin::next, Ex>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct static_root_impl<0> {
|
||||
template<class Begin, class Ex>
|
||||
struct apply
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_DIMENSION_IMPL_HPP
|
||||
@@ -0,0 +1,133 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DIMENSION_LIST_HPP
|
||||
#define BOOST_UNITS_DIMENSION_LIST_HPP
|
||||
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/push_front_fwd.hpp>
|
||||
#include <boost/mpl/pop_front_fwd.hpp>
|
||||
#include <boost/mpl/size_fwd.hpp>
|
||||
#include <boost/mpl/begin_end_fwd.hpp>
|
||||
#include <boost/mpl/front_fwd.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimensionless_type;
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct dimension_list_tag { };
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class Item, class Next>
|
||||
struct list
|
||||
{
|
||||
typedef detail::dimension_list_tag tag;
|
||||
typedef list type;
|
||||
typedef Item item;
|
||||
typedef Next next;
|
||||
typedef typename mpl::next<typename Next::size>::type size;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
namespace mpl {
|
||||
|
||||
// INTERNAL ONLY
|
||||
template<>
|
||||
struct size_impl<units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class L> struct apply : public L::size { };
|
||||
};
|
||||
|
||||
// INTERNAL ONLY
|
||||
template<>
|
||||
struct begin_impl<units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class L>
|
||||
struct apply
|
||||
{
|
||||
typedef L type;
|
||||
};
|
||||
};
|
||||
|
||||
// INTERNAL ONLY
|
||||
template<>
|
||||
struct end_impl<units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class L>
|
||||
struct apply
|
||||
{
|
||||
typedef units::dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
// INTERNAL ONLY
|
||||
template<>
|
||||
struct push_front_impl<units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class L, class T>
|
||||
struct apply
|
||||
{
|
||||
typedef units::list<T, L> type;
|
||||
};
|
||||
};
|
||||
|
||||
// INTERNAL ONLY
|
||||
template<>
|
||||
struct pop_front_impl<units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class L>
|
||||
struct apply
|
||||
{
|
||||
typedef typename L::next type;
|
||||
};
|
||||
};
|
||||
|
||||
// INTERNAL ONLY
|
||||
template<>
|
||||
struct front_impl<units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class L>
|
||||
struct apply
|
||||
{
|
||||
typedef typename L::item type;
|
||||
};
|
||||
};
|
||||
|
||||
// INTERNAL ONLY
|
||||
template<class Item, class Next>
|
||||
struct deref<units::list<Item, Next> >
|
||||
{
|
||||
typedef Item type;
|
||||
};
|
||||
|
||||
} // namespace mpl
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::list, 2)
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/units/dimensionless_type.hpp>
|
||||
|
||||
#endif // BOOST_UNITS_DIMENSION_LIST_HPP
|
||||
@@ -0,0 +1,88 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_DIMENSIONLESS_UNIT_HPP
|
||||
#define BOOST_UNITS_DETAIL_DIMENSIONLESS_UNIT_HPP
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace units {
|
||||
|
||||
template<class T>
|
||||
struct heterogeneous_system;
|
||||
|
||||
template<class T>
|
||||
struct homogeneous_system;
|
||||
|
||||
template<class T1, class T2, class Scale>
|
||||
struct heterogeneous_system_impl;
|
||||
|
||||
typedef boost::units::heterogeneous_system<
|
||||
boost::units::heterogeneous_system_impl<
|
||||
boost::units::dimensionless_type,
|
||||
boost::units::dimensionless_type,
|
||||
boost::units::dimensionless_type
|
||||
>
|
||||
> heterogeneous_dimensionless_system;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class System>
|
||||
struct void_if_dimensionless {
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct void_if_dimensionless<boost::units::homogeneous_system<T> > {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct void_if_dimensionless<heterogeneous_dimensionless_system> {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class System, class Test = void>
|
||||
struct void_if_heterogeneous {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class System>
|
||||
struct void_if_heterogeneous<System, typename void_if_dimensionless<System>::type> {
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template<class System, class Enable=void>
|
||||
struct is_dimensionless_system : mpl::false_ {};
|
||||
|
||||
template<class System>
|
||||
struct is_dimensionless_system<System, typename void_if_dimensionless<System>::type> : mpl::true_ {};
|
||||
|
||||
#define BOOST_UNITS_DIMENSIONLESS_UNIT(T)\
|
||||
boost::units::unit<\
|
||||
boost::units::dimensionless_type,\
|
||||
T,\
|
||||
typename ::boost::units::detail::void_if_dimensionless<T>::type\
|
||||
>
|
||||
|
||||
#define BOOST_UNITS_HETEROGENEOUS_DIMENSIONLESS_UNIT(T)\
|
||||
boost::units::unit<\
|
||||
boost::units::dimensionless_type,\
|
||||
T,\
|
||||
typename ::boost::units::detail::void_if_heterogeneous<T>::type\
|
||||
>
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,309 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_HETEROGENEOUS_CONVERSION_HPP
|
||||
#define BOOST_UNITS_DETAIL_HETEROGENEOUS_CONVERSION_HPP
|
||||
|
||||
#include <boost/mpl/minus.hpp>
|
||||
#include <boost/mpl/times.hpp>
|
||||
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/homogeneous_system.hpp>
|
||||
#include <boost/units/detail/linear_algebra.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct solve_end {
|
||||
template<class Begin, class Y>
|
||||
struct apply {
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
struct no_solution {};
|
||||
|
||||
template<class X1, class X2, class Next>
|
||||
struct solve_normal {
|
||||
template<class Begin, class Y>
|
||||
struct apply {
|
||||
typedef typename Begin::next next;
|
||||
typedef list<
|
||||
typename mpl::minus<
|
||||
typename mpl::times<X1, Y>::type,
|
||||
typename mpl::times<X2, typename Begin::item>::type
|
||||
>::type,
|
||||
typename Next::template apply<next, Y>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class Next>
|
||||
struct solve_leading_zeroes {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef list<
|
||||
typename Begin::item,
|
||||
typename Next::template apply<typename Begin::next>::type
|
||||
> type;
|
||||
};
|
||||
typedef solve_leading_zeroes type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct solve_leading_zeroes<no_solution> {
|
||||
typedef no_solution type;
|
||||
};
|
||||
|
||||
template<class Next>
|
||||
struct solve_first_non_zero {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef typename Next::template apply<
|
||||
typename Begin::next,
|
||||
typename Begin::item
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class Next>
|
||||
struct solve_internal_zero {
|
||||
template<class Begin, class Y>
|
||||
struct apply {
|
||||
typedef list<
|
||||
typename Begin::item,
|
||||
typename Next::template apply<typename Begin::next, Y>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct make_solve_list_internal_zero {
|
||||
template<class Next, class X>
|
||||
struct apply {
|
||||
typedef solve_normal<T, X, Next> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_solve_list_internal_zero<static_rational<0> > {
|
||||
template<class Next, class X>
|
||||
struct apply {
|
||||
typedef solve_internal_zero<Next> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct make_solve_list_normal {
|
||||
template<class Begin, class X>
|
||||
struct apply {
|
||||
typedef typename make_solve_list_internal_zero<
|
||||
typename Begin::item
|
||||
>::template apply<
|
||||
typename make_solve_list_normal<N-1>::template apply<typename Begin::next, X>::type,
|
||||
X
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_solve_list_normal<0> {
|
||||
template<class Begin, class X>
|
||||
struct apply {
|
||||
typedef solve_end type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct make_solve_list_leading_zeroes;
|
||||
|
||||
template<class T>
|
||||
struct make_solve_list_first_non_zero {
|
||||
template<class Begin, int N>
|
||||
struct apply {
|
||||
typedef solve_first_non_zero<
|
||||
typename make_solve_list_normal<N-1>::template apply<
|
||||
typename Begin::next,
|
||||
typename Begin::item
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_solve_list_first_non_zero<static_rational<0> > {
|
||||
template<class Begin, int N>
|
||||
struct apply {
|
||||
typedef typename solve_leading_zeroes<
|
||||
typename make_solve_list_leading_zeroes<N-1>::template apply<
|
||||
typename Begin::next
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct make_solve_list_leading_zeroes {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef typename make_solve_list_first_non_zero<typename Begin::item>::template apply<Begin, N>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_solve_list_leading_zeroes<0> {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef no_solution type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct try_add_unit_impl {
|
||||
template<class Begin, class L>
|
||||
struct apply {
|
||||
typedef typename try_add_unit_impl<N-1>::template apply<typename Begin::next, L>::type next;
|
||||
typedef typename Begin::item::template apply<next>::type type;
|
||||
BOOST_STATIC_ASSERT((next::size::value - 1 == type::size::value));
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct try_add_unit_impl<0> {
|
||||
template<class Begin, class L>
|
||||
struct apply {
|
||||
typedef L type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct make_homogeneous_system_impl;
|
||||
|
||||
template<class T, bool is_done>
|
||||
struct make_homogeneous_system_func;
|
||||
|
||||
template<class T>
|
||||
struct make_homogeneous_system_func<T, false> {
|
||||
template<class Begin, class Current, class Units, class Dimensions, int N>
|
||||
struct apply {
|
||||
typedef typename make_homogeneous_system_impl<N-1>::template apply<
|
||||
typename Begin::next,
|
||||
list<T, Current>,
|
||||
list<typename Begin::item, Units>,
|
||||
Dimensions
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct make_homogeneous_system_func<T, true> {
|
||||
template<class Begin, class Current, class Units, class Dimensions, int N>
|
||||
struct apply {
|
||||
typedef list<typename Begin::item, Units> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_homogeneous_system_func<no_solution, false> {
|
||||
template<class Begin, class Current, class Units, class Dimensions, int N>
|
||||
struct apply {
|
||||
typedef typename make_homogeneous_system_impl<N-1>::template apply<
|
||||
typename Begin::next,
|
||||
Current,
|
||||
Units,
|
||||
Dimensions
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_homogeneous_system_func<no_solution, true> {
|
||||
template<class Begin, class Current, class Units, class Dimensions, int N>
|
||||
struct apply {
|
||||
typedef typename make_homogeneous_system_impl<N-1>::template apply<
|
||||
typename Begin::next,
|
||||
Current,
|
||||
Units,
|
||||
Dimensions
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct make_homogeneous_system_impl {
|
||||
template<class Begin, class Current, class Units, class Dimensions>
|
||||
struct apply {
|
||||
typedef typename expand_dimensions<Dimensions::size::value>::template apply<
|
||||
Dimensions,
|
||||
typename Begin::item::dimension_type
|
||||
>::type dimensions;
|
||||
typedef typename try_add_unit_impl<Current::size::value>::template apply<Current, dimensions>::type new_element;
|
||||
typedef typename make_solve_list_leading_zeroes<new_element::size::value>::template apply<new_element>::type new_func;
|
||||
typedef typename make_homogeneous_system_func<
|
||||
new_func,
|
||||
((Current::size::value)+1) == (Dimensions::size::value)
|
||||
>::template apply<Begin, Current, Units, Dimensions, N>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_homogeneous_system_impl<0> {
|
||||
template<class Begin, class Current, class Units, class Dimensions>
|
||||
struct apply {
|
||||
typedef Units type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class Units>
|
||||
struct make_homogeneous_system {
|
||||
typedef typename find_base_dimensions<Units>::type base_dimensions;
|
||||
typedef homogeneous_system<
|
||||
typename insertion_sort<
|
||||
typename make_homogeneous_system_impl<
|
||||
Units::size::value
|
||||
>::template apply<
|
||||
Units,
|
||||
dimensionless_type,
|
||||
dimensionless_type,
|
||||
base_dimensions
|
||||
>::type
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct extract_base_units {
|
||||
template<class Begin, class T>
|
||||
struct apply {
|
||||
typedef list<
|
||||
typename Begin::item::tag_type,
|
||||
typename extract_base_units<N-1>::template apply<typename Begin::next, T>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct extract_base_units<0> {
|
||||
template<class Begin, class T>
|
||||
struct apply {
|
||||
typedef T type;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,120 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_ONE_HPP
|
||||
#define BOOST_UNITS_DETAIL_ONE_HPP
|
||||
|
||||
#include <boost/units/operators.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
struct one { one() {} };
|
||||
|
||||
// workaround for pathscale.
|
||||
inline one make_one() {
|
||||
one result;
|
||||
return(result);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
struct multiply_typeof_helper<one, T>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct multiply_typeof_helper<T, one>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct multiply_typeof_helper<one, one>
|
||||
{
|
||||
typedef one type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline T operator*(const one&, const T& t)
|
||||
{
|
||||
return(t);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T operator*(const T& t, const one&)
|
||||
{
|
||||
return(t);
|
||||
}
|
||||
|
||||
inline one operator*(const one&, const one&)
|
||||
{
|
||||
one result;
|
||||
return(result);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
struct divide_typeof_helper<T, one>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct divide_typeof_helper<one, T>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct divide_typeof_helper<one, one>
|
||||
{
|
||||
typedef one type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline T operator/(const T& t, const one&)
|
||||
{
|
||||
return(t);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T operator/(const one&, const T& t)
|
||||
{
|
||||
return(1/t);
|
||||
}
|
||||
|
||||
inline one operator/(const one&, const one&)
|
||||
{
|
||||
one result;
|
||||
return(result);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator>(const boost::units::one&, const T& t) {
|
||||
return(1 > t);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T one_to_double(const T& t) { return t; }
|
||||
|
||||
inline double one_to_double(const one&) { return 1.0; }
|
||||
|
||||
template<class T>
|
||||
struct one_to_double_type { typedef T type; };
|
||||
|
||||
template<>
|
||||
struct one_to_double_type<one> { typedef double type; };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_ORDINAL_HPP_INCLUDED
|
||||
#define BOOST_UNITS_DETAIL_ORDINAL_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct ordinal_tag {};
|
||||
|
||||
}
|
||||
|
||||
template<int N>
|
||||
struct ordinal {
|
||||
typedef detail::ordinal_tag tag;
|
||||
static const long value = N;
|
||||
};
|
||||
|
||||
template<int N>
|
||||
const long ordinal<N>::value;
|
||||
|
||||
}
|
||||
|
||||
namespace mpl {
|
||||
|
||||
template<>
|
||||
struct less_impl<units::detail::ordinal_tag, units::detail::ordinal_tag> {
|
||||
template<class T1, class T2>
|
||||
struct apply : bool_<(T1::value) < (T2::value)> {};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_PREVENT_REDEFINITION_HPP
|
||||
#define BOOST_UNITS_DETAIL_PREVENT_REDEFINITION_HPP
|
||||
|
||||
#include <boost/mpl/long.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct no { no() {} char dummy; };
|
||||
struct yes { no dummy[2]; };
|
||||
|
||||
template<bool> struct ordinal_has_already_been_defined;
|
||||
|
||||
template<>
|
||||
struct ordinal_has_already_been_defined<true> { };
|
||||
|
||||
template<>
|
||||
struct ordinal_has_already_been_defined<false> { typedef void type; };
|
||||
|
||||
}
|
||||
|
||||
/// This must be in namespace boost::units so that ADL
|
||||
/// will work. we need a mangled name because it must
|
||||
/// be found by ADL
|
||||
/// INTERNAL ONLY
|
||||
template<class T>
|
||||
detail::no
|
||||
boost_units_is_registered(const T&)
|
||||
{ detail::no result; return(result); }
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T>
|
||||
detail::no
|
||||
boost_units_unit_is_registered(const T&)
|
||||
{ detail::no result; return(result); }
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_PREVENT_ORDINAL_REDEFINITION_IMPL_HPP
|
||||
@@ -0,0 +1,48 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_PUSH_FRONT_IF_HPP
|
||||
#define BOOST_UNITS_DETAIL_PUSH_FRONT_IF_HPP
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class T, class Next>
|
||||
struct list;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<bool>
|
||||
struct push_front_if;
|
||||
|
||||
template<>
|
||||
struct push_front_if<true> {
|
||||
template<class L, class T>
|
||||
struct apply {
|
||||
typedef list<T, L> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct push_front_if<false> {
|
||||
template<class L, class T>
|
||||
struct apply {
|
||||
typedef L type;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
|
||||
#define BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
|
||||
|
||||
#include <boost/mpl/plus.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/push_front.hpp>
|
||||
#include <boost/mpl/pop_front.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/detail/push_front_if.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class Item, class Next>
|
||||
struct list;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct is_empty_dim;
|
||||
|
||||
/// add an instantiation of dim to Sequence.
|
||||
template<bool>
|
||||
struct push_front_or_add_impl;
|
||||
|
||||
template<>
|
||||
struct push_front_or_add_impl<true>
|
||||
{
|
||||
template<typename Sequence, typename T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::plus<T, typename Sequence::item>::type item;
|
||||
typedef typename push_front_if<!is_empty_dim<item>::value>::template apply<
|
||||
typename Sequence::next,
|
||||
item
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct push_front_or_add_impl<false>
|
||||
{
|
||||
template<typename Sequence, typename T>
|
||||
struct apply
|
||||
{
|
||||
typedef list<T, Sequence> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Sequence, typename T>
|
||||
struct push_front_or_add
|
||||
{
|
||||
typedef typename push_front_or_add_impl<boost::is_same<typename T::tag_type, typename Sequence::item::tag_type>::value>::template apply<
|
||||
Sequence,
|
||||
T
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct push_front_or_add<dimensionless_type, T>
|
||||
{
|
||||
typedef list<T, dimensionless_type> type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,109 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_SORT_HPP
|
||||
#define BOOST_UNITS_DETAIL_SORT_HPP
|
||||
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/mpl/begin.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/push_front.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
|
||||
#include <boost/units/dimensionless_type.hpp>
|
||||
#include <boost/units/detail/dimension_list.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<int N>
|
||||
struct insertion_sort_insert;
|
||||
|
||||
template<bool is_greater>
|
||||
struct insertion_sort_comparison_impl;
|
||||
|
||||
// have to recursively add the element to the next sequence.
|
||||
template<>
|
||||
struct insertion_sort_comparison_impl<true> {
|
||||
template<class Begin, int N, class T>
|
||||
struct apply {
|
||||
typedef list<
|
||||
typename Begin::item,
|
||||
typename insertion_sort_insert<N - 1>::template apply<
|
||||
typename Begin::next,
|
||||
T
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
// prepend the current element
|
||||
template<>
|
||||
struct insertion_sort_comparison_impl<false> {
|
||||
template<class Begin, int N, class T>
|
||||
struct apply {
|
||||
typedef list<T, Begin> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct insertion_sort_insert {
|
||||
template<class Begin, class T>
|
||||
struct apply {
|
||||
typedef typename insertion_sort_comparison_impl<mpl::less<typename Begin::item, T>::value>::template apply<
|
||||
Begin,
|
||||
N,
|
||||
T
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct insertion_sort_insert<0> {
|
||||
template<class Begin, class T>
|
||||
struct apply {
|
||||
typedef list<T, dimensionless_type> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct insertion_sort_impl {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef typename insertion_sort_impl<N - 1>::template apply<typename Begin::next>::type next;
|
||||
typedef typename insertion_sort_insert<(next::size::value)>::template apply<next, typename Begin::item>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct insertion_sort_impl<0> {
|
||||
template<class Begin>
|
||||
struct apply {
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct insertion_sort
|
||||
{
|
||||
typedef typename insertion_sort_impl<T::size::value>::template apply<T>::type type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,206 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_STATIC_RATIONAL_POWER_HPP
|
||||
#define BOOST_UNITS_DETAIL_STATIC_RATIONAL_POWER_HPP
|
||||
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
|
||||
#include <boost/units/detail/one.hpp>
|
||||
#include <boost/units/operators.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<long N,long D>
|
||||
class static_rational;
|
||||
|
||||
namespace detail {
|
||||
|
||||
namespace typeof_pow_adl_barrier {
|
||||
|
||||
using std::pow;
|
||||
|
||||
template<class Y>
|
||||
struct typeof_pow
|
||||
{
|
||||
#if defined(BOOST_UNITS_HAS_BOOST_TYPEOF)
|
||||
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, pow(typeof_::make<Y>(), 0.0))
|
||||
typedef typename nested::type type;
|
||||
#elif defined(BOOST_UNITS_HAS_MWERKS_TYPEOF)
|
||||
typedef __typeof__(pow(typeof_::make<Y>(), 0.0)) type;
|
||||
#elif defined(BOOST_UNITS_HAS_GNU_TYPEOF)
|
||||
typedef typeof(pow(typeof_::make<Y>(), 0.0)) type;
|
||||
#else
|
||||
typedef Y type;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<class R, class Y>
|
||||
struct static_rational_power_impl
|
||||
{
|
||||
typedef typename typeof_pow_adl_barrier::typeof_pow<Y>::type type;
|
||||
static type call(const Y& y)
|
||||
{
|
||||
using std::pow;
|
||||
return(pow(y, static_cast<double>(R::Numerator) / static_cast<double>(R::Denominator)));
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
struct static_rational_power_impl<R, one>
|
||||
{
|
||||
typedef one type;
|
||||
static one call(const one&)
|
||||
{
|
||||
one result;
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template<long N>
|
||||
struct static_rational_power_impl<static_rational<N, 1>, one>
|
||||
{
|
||||
typedef one type;
|
||||
static one call(const one&)
|
||||
{
|
||||
one result;
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template<long N, bool = (N % 2 == 0)>
|
||||
struct static_int_power_impl;
|
||||
|
||||
template<long N>
|
||||
struct static_int_power_impl<N, true>
|
||||
{
|
||||
template<class Y, class R>
|
||||
struct apply
|
||||
{
|
||||
typedef typename multiply_typeof_helper<Y, Y>::type square_type;
|
||||
typedef typename static_int_power_impl<(N >> 1)>::template apply<square_type, R> next;
|
||||
typedef typename next::type type;
|
||||
static type call(const Y& y, const R& r)
|
||||
{
|
||||
const square_type square = y * y;
|
||||
return(next::call(square, r));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<long N>
|
||||
struct static_int_power_impl<N, false>
|
||||
{
|
||||
template<class Y, class R>
|
||||
struct apply
|
||||
{
|
||||
typedef typename multiply_typeof_helper<Y, Y>::type square_type;
|
||||
typedef typename multiply_typeof_helper<Y, R>::type new_r;
|
||||
typedef typename static_int_power_impl<(N >> 1)>::template apply<square_type, new_r> next;
|
||||
typedef typename next::type type;
|
||||
static type call(const Y& y, const R& r)
|
||||
{
|
||||
const Y square = y * y;
|
||||
return(next::call(square, y * r));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct static_int_power_impl<1, false>
|
||||
{
|
||||
template<class Y, class R>
|
||||
struct apply
|
||||
{
|
||||
typedef typename multiply_typeof_helper<Y, R>::type type;
|
||||
static type call(const Y& y, const R& r)
|
||||
{
|
||||
return(y * r);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct static_int_power_impl<0, true>
|
||||
{
|
||||
template<class Y, class R>
|
||||
struct apply
|
||||
{
|
||||
typedef R type;
|
||||
static R call(const Y&, const R& r)
|
||||
{
|
||||
return(r);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<int N, bool = (N < 0)>
|
||||
struct static_int_power_sign_impl;
|
||||
|
||||
template<int N>
|
||||
struct static_int_power_sign_impl<N, false>
|
||||
{
|
||||
template<class Y>
|
||||
struct apply
|
||||
{
|
||||
typedef typename static_int_power_impl<N>::template apply<Y, one> impl;
|
||||
typedef typename impl::type type;
|
||||
static type call(const Y& y)
|
||||
{
|
||||
one result;
|
||||
return(impl::call(y, result));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct static_int_power_sign_impl<N, true>
|
||||
{
|
||||
template<class Y>
|
||||
struct apply
|
||||
{
|
||||
typedef typename static_int_power_impl<-N>::template apply<Y, one> impl;
|
||||
typedef typename divide_typeof_helper<one, typename impl::type>::type type;
|
||||
static type call(const Y& y)
|
||||
{
|
||||
one result;
|
||||
return(result/impl::call(y, result));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<long N, class Y>
|
||||
struct static_rational_power_impl<static_rational<N, 1>, Y>
|
||||
{
|
||||
typedef typename static_int_power_sign_impl<N>::template apply<Y> impl;
|
||||
typedef typename impl::type type;
|
||||
static type call(const Y& y)
|
||||
{
|
||||
return(impl::call(y));
|
||||
}
|
||||
};
|
||||
|
||||
template<class R, class Y>
|
||||
typename detail::static_rational_power_impl<R, Y>::type static_rational_power(const Y& y)
|
||||
{
|
||||
return(detail::static_rational_power_impl<R, Y>::call(y));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,234 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DETAIL_UNSCALE_HPP_INCLUDED
|
||||
#define BOOST_UNITS_DETAIL_UNSCALE_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/mpl/begin.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/plus.hpp>
|
||||
#include <boost/mpl/times.hpp>
|
||||
#include <boost/mpl/negate.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/dimension.hpp>
|
||||
#include <boost/units/scale.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/detail/one.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class T>
|
||||
struct heterogeneous_system;
|
||||
|
||||
template<class T, class D, class Scale>
|
||||
struct heterogeneous_system_impl;
|
||||
|
||||
template<class T, class E>
|
||||
struct heterogeneous_system_dim;
|
||||
|
||||
template<class S, class Scale>
|
||||
struct scaled_base_unit;
|
||||
|
||||
/// removes all scaling from a unit or a base unit.
|
||||
template<class T>
|
||||
struct unscale
|
||||
{
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
typedef T type;
|
||||
#else
|
||||
typedef detail::unspecified type;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class S, class Scale>
|
||||
struct unscale<scaled_base_unit<S, Scale> >
|
||||
{
|
||||
typedef typename unscale<S>::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class D, class S>
|
||||
struct unscale<unit<D, S> >
|
||||
{
|
||||
typedef unit<D, typename unscale<S>::type> type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Scale>
|
||||
struct scale_list_dim;
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T>
|
||||
struct get_scale_list
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class S, class Scale>
|
||||
struct get_scale_list<scaled_base_unit<S, Scale> >
|
||||
{
|
||||
typedef typename mpl::times<list<scale_list_dim<Scale>, dimensionless_type>, typename get_scale_list<S>::type>::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class D, class S>
|
||||
struct get_scale_list<unit<D, S> >
|
||||
{
|
||||
typedef typename get_scale_list<S>::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
struct scale_dim_tag {};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Scale>
|
||||
struct scale_list_dim : Scale
|
||||
{
|
||||
typedef scale_dim_tag tag;
|
||||
typedef scale_list_dim type;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
|
||||
namespace mpl {
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct less_impl<boost::units::scale_dim_tag, boost::units::scale_dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply : mpl::bool_<((T0::base) < (T1::base))> {};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class Scale>
|
||||
struct is_empty_dim<scale_list_dim<Scale> > : mpl::false_ {};
|
||||
|
||||
template<long N>
|
||||
struct is_empty_dim<scale_list_dim<scale<N, static_rational<0, 1> > > > : mpl::true_ {};
|
||||
|
||||
template<int N>
|
||||
struct eval_scale_list_impl
|
||||
{
|
||||
template<class Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef typename eval_scale_list_impl<N-1>::template apply<typename Begin::next> next_iteration;
|
||||
typedef typename multiply_typeof_helper<typename next_iteration::type, typename Begin::item::value_type>::type type;
|
||||
static type value()
|
||||
{
|
||||
return(next_iteration::value() * Begin::item::value());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct eval_scale_list_impl<0>
|
||||
{
|
||||
template<class Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef one type;
|
||||
static one value()
|
||||
{
|
||||
one result;
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T>
|
||||
struct eval_scale_list : detail::eval_scale_list_impl<T::size::value>::template apply<T> {};
|
||||
|
||||
} // namespace units
|
||||
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
|
||||
namespace mpl {
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct plus_impl<boost::units::scale_dim_tag, boost::units::scale_dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::scale_list_dim<
|
||||
boost::units::scale<
|
||||
(T0::base),
|
||||
typename mpl::plus<typename T0::exponent, typename T1::exponent>::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct negate_impl<boost::units::scale_dim_tag>
|
||||
{
|
||||
template<class T0>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::scale_list_dim<
|
||||
boost::units::scale<
|
||||
(T0::base),
|
||||
typename mpl::negate<typename T0::exponent>::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct times_impl<boost::units::scale_dim_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::scale_list_dim<
|
||||
boost::units::scale<
|
||||
(T0::base),
|
||||
typename mpl::times<typename T0::exponent, T1>::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace mpl
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_UTILITY_HPP
|
||||
#define BOOST_UNITS_UTILITY_HPP
|
||||
|
||||
#include <typeinfo>
|
||||
#include <string>
|
||||
#include <boost/core/demangle.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
inline
|
||||
std::string
|
||||
demangle(const char* name)
|
||||
{
|
||||
std::string demangled = core::demangle(name);
|
||||
|
||||
const std::string::size_type prefix_len = sizeof("boost::units::") - 1;
|
||||
std::string::size_type i = 0;
|
||||
for (;;)
|
||||
{
|
||||
std::string::size_type pos = demangled.find("boost::units::", i, prefix_len);
|
||||
if (pos == std::string::npos)
|
||||
break;
|
||||
|
||||
demangled.erase(pos, prefix_len);
|
||||
i = pos;
|
||||
}
|
||||
|
||||
return demangled;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L>
|
||||
inline std::string simplify_typename(const L& /*source*/)
|
||||
{
|
||||
return detail::demangle(typeid(L).name());
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_UTILITY_HPP
|
||||
@@ -0,0 +1,167 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DIM_HPP
|
||||
#define BOOST_UNITS_DIM_HPP
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/mpl/arithmetic.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/detail/dim_impl.hpp>
|
||||
|
||||
/// \file dim.hpp
|
||||
/// \brief Handling of fundamental dimension/exponent pairs.
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct dim_tag { };
|
||||
|
||||
}
|
||||
|
||||
/// \brief Dimension tag/exponent pair for a single fundamental dimension.
|
||||
///
|
||||
/// \details
|
||||
/// 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. @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
|
||||
{
|
||||
typedef dim type;
|
||||
typedef detail::dim_tag tag;
|
||||
typedef T tag_type;
|
||||
typedef V value_type;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dim, 2)
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace mpl {
|
||||
|
||||
// define MPL operators acting on dim<T,V>
|
||||
|
||||
template<>
|
||||
struct plus_impl<boost::units::detail::dim_tag,boost::units::detail::dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
BOOST_STATIC_ASSERT((boost::is_same<typename T0::tag_type,typename T1::tag_type>::value == true));
|
||||
typedef boost::units::dim<typename T0::tag_type, typename mpl::plus<typename T0::value_type, typename T1::value_type>::type> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct minus_impl<boost::units::detail::dim_tag,boost::units::detail::dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
BOOST_STATIC_ASSERT((boost::is_same<typename T0::tag_type,typename T1::tag_type>::value == true));
|
||||
typedef boost::units::dim<typename T0::tag_type, typename mpl::minus<typename T0::value_type, typename T1::value_type>::type> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct times_impl<boost::units::detail::dim_tag,boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::dim<typename T0::tag_type, typename mpl::times<typename T0::value_type, T1>::type> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct times_impl<boost::units::detail::static_rational_tag,boost::units::detail::dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::dim<typename T1::tag_type, typename mpl::times<T0, typename T1::value_type>::type> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct divides_impl<boost::units::detail::dim_tag,boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::dim<typename T0::tag_type, typename mpl::divides<typename T0::value_type, T1>::type> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct divides_impl<boost::units::detail::static_rational_tag,boost::units::detail::dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::dim<typename T1::tag_type, typename mpl::divides<T0, typename T1::value_type>::type> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct negate_impl<boost::units::detail::dim_tag>
|
||||
{
|
||||
template<class T0>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::dim<typename T0::tag_type,typename mpl::negate<typename T0::value_type>::type> type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace mpl
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_UNITS_DIM_HPP
|
||||
@@ -0,0 +1,150 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DIMENSION_HPP
|
||||
#define BOOST_UNITS_DIMENSION_HPP
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/mpl/arithmetic.hpp>
|
||||
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/detail/dimension_list.hpp>
|
||||
#include <boost/units/detail/dimension_impl.hpp>
|
||||
|
||||
/// \file
|
||||
/// \brief Core metaprogramming utilities for compile-time dimensional analysis.
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// Reduce dimension list to cardinal form. This algorithm collapses duplicate
|
||||
/// base dimension tags and sorts the resulting list by the tag ordinal value.
|
||||
/// Dimension lists that resolve to the same dimension are guaranteed to be
|
||||
/// represented by an identical type.
|
||||
///
|
||||
/// The argument should be an MPL forward sequence containing instances
|
||||
/// of the @c dim template.
|
||||
///
|
||||
/// The result is also an MPL forward sequence. It also supports the
|
||||
/// following metafunctions to allow use as a dimension.
|
||||
///
|
||||
/// - @c mpl::plus is defined only on two equal dimensions and returns the argument unchanged.
|
||||
/// - @c mpl::minus is defined only for two equal dimensions and returns the argument unchanged.
|
||||
/// - @c mpl::negate will return its argument unchanged.
|
||||
/// - @c mpl::times is defined for any dimensions and adds corresponding exponents.
|
||||
/// - @c mpl::divides is defined for any dimensions and subtracts the exponents of the
|
||||
/// right had argument from the corresponding exponents of the left had argument.
|
||||
/// Missing base dimension tags are assumed to have an exponent of zero.
|
||||
/// - @c static_power takes a dimension and a static_rational and multiplies all
|
||||
/// the exponents of the dimension by the static_rational.
|
||||
/// - @c static_root takes a dimension and a static_rational and divides all
|
||||
/// the exponents of the dimension by the static_rational.
|
||||
template<typename Seq>
|
||||
struct make_dimension_list
|
||||
{
|
||||
typedef typename detail::sort_dims<Seq>::type type;
|
||||
};
|
||||
|
||||
/// Raise a dimension list to a scalar power.
|
||||
template<typename DL,typename Ex>
|
||||
struct static_power
|
||||
{
|
||||
typedef typename detail::static_power_impl<DL::size::value>::template apply<
|
||||
DL,
|
||||
Ex
|
||||
>::type type;
|
||||
};
|
||||
|
||||
/// Take a scalar root of a dimension list.
|
||||
template<typename DL,typename Rt>
|
||||
struct static_root
|
||||
{
|
||||
typedef typename detail::static_root_impl<DL::size::value>::template apply<
|
||||
DL,
|
||||
Rt
|
||||
>::type type;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
|
||||
namespace mpl {
|
||||
|
||||
template<>
|
||||
struct plus_impl<boost::units::detail::dimension_list_tag,boost::units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
BOOST_STATIC_ASSERT((boost::is_same<T0,T1>::value == true));
|
||||
typedef T0 type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct minus_impl<boost::units::detail::dimension_list_tag,boost::units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
BOOST_STATIC_ASSERT((boost::is_same<T0,T1>::value == true));
|
||||
typedef T0 type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct times_impl<boost::units::detail::dimension_list_tag,boost::units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef typename boost::units::detail::merge_dimensions<T0,T1>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct divides_impl<boost::units::detail::dimension_list_tag,boost::units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef typename boost::units::detail::merge_dimensions<
|
||||
T0,
|
||||
typename boost::units::detail::static_inverse_impl<
|
||||
T1::size::value
|
||||
>::template apply<
|
||||
T1
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct negate_impl<boost::units::detail::dimension_list_tag>
|
||||
{
|
||||
template<class T0>
|
||||
struct apply
|
||||
{
|
||||
typedef T0 type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace mpl
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_DIMENSION_HPP
|
||||
@@ -0,0 +1,55 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DIMENSIONLESS_TYPE_HPP
|
||||
#define BOOST_UNITS_DIMENSIONLESS_TYPE_HPP
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// \brief Dimension lists in which all exponents resolve to zero reduce to @c dimensionless_type.
|
||||
///
|
||||
|
||||
#include <boost/mpl/long.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/arithmetic.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct dimension_list_tag;
|
||||
|
||||
}
|
||||
|
||||
/// Dimension lists in which all exponents resolve to zero reduce to @c dimensionless_type.
|
||||
struct dimensionless_type
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
typedef detail::dimension_list_tag tag;
|
||||
typedef mpl::long_<0> size;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::dimensionless_type)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_UNITS_DIMENSIONLESS_TYPE_HPP
|
||||
@@ -0,0 +1,54 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_GET_DIMENSION_HPP
|
||||
#define BOOST_UNITS_GET_DIMENSION_HPP
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// \brief Get the dimension of a unit, absolute unit and quantity.
|
||||
/// \details
|
||||
///
|
||||
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class T>
|
||||
struct get_dimension {};
|
||||
|
||||
/// Get the dimension of a unit.
|
||||
template<class Dim,class System>
|
||||
struct get_dimension< unit<Dim,System> >
|
||||
{
|
||||
typedef Dim type;
|
||||
};
|
||||
|
||||
/// Get the dimension of an absolute unit.
|
||||
template<class Unit>
|
||||
struct get_dimension< absolute<Unit> >
|
||||
{
|
||||
typedef typename get_dimension<Unit>::type type;
|
||||
};
|
||||
|
||||
/// Get the dimension of a quantity.
|
||||
template<class Unit,class Y>
|
||||
struct get_dimension< quantity<Unit,Y> >
|
||||
{
|
||||
typedef typename get_dimension<Unit>::type type;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_GET_DIMENSION_HPP
|
||||
@@ -0,0 +1,51 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_GET_SYSTEM_HPP
|
||||
#define BOOST_UNITS_GET_SYSTEM_HPP
|
||||
|
||||
/// \file
|
||||
/// \brief Get the system of a unit, absolute unit or quantity.
|
||||
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class T>
|
||||
struct get_system {};
|
||||
|
||||
/// Get the system of a unit.
|
||||
template<class Dim,class System>
|
||||
struct get_system< unit<Dim,System> >
|
||||
{
|
||||
typedef System type;
|
||||
};
|
||||
|
||||
/// Get the system of an absolute unit.
|
||||
template<class Unit>
|
||||
struct get_system< absolute<Unit> >
|
||||
{
|
||||
typedef typename get_system<Unit>::type type;
|
||||
};
|
||||
|
||||
/// Get the system of a quantity.
|
||||
template<class Unit,class Y>
|
||||
struct get_system< quantity<Unit,Y> >
|
||||
{
|
||||
typedef typename get_system<Unit>::type type;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_GET_SYSTEM_HPP
|
||||
@@ -0,0 +1,428 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_HETEROGENEOUS_SYSTEM_HPP
|
||||
#define BOOST_UNITS_HETEROGENEOUS_SYSTEM_HPP
|
||||
|
||||
/// \file
|
||||
/// \brief A heterogeneous system is a sorted list of base unit/exponent pairs.
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/plus.hpp>
|
||||
#include <boost/mpl/times.hpp>
|
||||
#include <boost/mpl/divides.hpp>
|
||||
#include <boost/mpl/negate.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/mpl/begin.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/push_front.hpp>
|
||||
#include <boost/mpl/pop_front.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/dimension.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/detail/push_front_if.hpp>
|
||||
#include <boost/units/detail/push_front_or_add.hpp>
|
||||
#include <boost/units/detail/linear_algebra.hpp>
|
||||
#include <boost/units/detail/unscale.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// A normal system is a sorted list of base units.
|
||||
// A heterogeneous system is a sorted list of base unit/exponent pairs.
|
||||
// As long as we don't need to convert heterogeneous systems
|
||||
// directly everything is cool.
|
||||
|
||||
template<class T>
|
||||
struct is_zero : mpl::false_ {};
|
||||
|
||||
template<>
|
||||
struct is_zero<static_rational<0> > : mpl::true_ {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class L, class Dimensions, class Scale>
|
||||
struct heterogeneous_system_impl
|
||||
{
|
||||
typedef L type;
|
||||
typedef Dimensions dimensions;
|
||||
typedef Scale scale;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
typedef dimensionless_type no_scale;
|
||||
|
||||
/// A system that can represent any possible combination
|
||||
/// of units at the expense of not preserving information
|
||||
/// about how it was created. Do not create specializations
|
||||
/// of this template directly. Instead use @c reduce_unit and
|
||||
/// @c base_unit<...>::unit_type.
|
||||
template<class T>
|
||||
struct heterogeneous_system : T {};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
struct heterogeneous_system_dim_tag {};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Unit, class Exponent>
|
||||
struct heterogeneous_system_dim
|
||||
{
|
||||
typedef heterogeneous_system_dim_tag tag;
|
||||
typedef heterogeneous_system_dim type;
|
||||
typedef Unit tag_type;
|
||||
typedef Exponent value_type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
#define BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(BaseUnit, Dimensions) \
|
||||
boost::units::unit< \
|
||||
Dimensions, \
|
||||
boost::units::heterogeneous_system< \
|
||||
boost::units::heterogeneous_system_impl< \
|
||||
boost::units::list< \
|
||||
boost::units::heterogeneous_system_dim< \
|
||||
BaseUnit, \
|
||||
boost::units::static_rational<1> \
|
||||
>, \
|
||||
boost::units::dimensionless_type \
|
||||
>, \
|
||||
Dimensions, \
|
||||
boost::units::no_scale \
|
||||
> \
|
||||
> \
|
||||
>
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::heterogeneous_system_impl, (class)(class)(class))
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::heterogeneous_system, (class))
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::heterogeneous_system_dim, (class)(class))
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace mpl {
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct less_impl<boost::units::heterogeneous_system_dim_tag, boost::units::heterogeneous_system_dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply : mpl::less<typename T0::tag_type, typename T1::tag_type> {};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class Unit1, class Exponent1>
|
||||
struct is_empty_dim<heterogeneous_system_dim<Unit1,Exponent1> > : detail::is_zero<Exponent1> {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
namespace mpl {
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct plus_impl<boost::units::heterogeneous_system_dim_tag, boost::units::heterogeneous_system_dim_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::heterogeneous_system_dim<
|
||||
typename T0::tag_type,
|
||||
typename mpl::plus<typename T0::value_type,typename T1::value_type>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct times_impl<boost::units::heterogeneous_system_dim_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::heterogeneous_system_dim<
|
||||
typename T0::tag_type,
|
||||
typename mpl::times<typename T0::value_type,T1>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct divides_impl<boost::units::heterogeneous_system_dim_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::heterogeneous_system_dim<
|
||||
typename T0::tag_type,
|
||||
typename mpl::divides<typename T0::value_type,T1>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct negate_impl<boost::units::heterogeneous_system_dim_tag>
|
||||
{
|
||||
template<class T>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::units::heterogeneous_system_dim<typename T::tag_type, typename mpl::negate<typename T::value_type>::type> type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace mpl
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<int N>
|
||||
struct make_heterogeneous_system_impl
|
||||
{
|
||||
template<class UnitsBegin, class ExponentsBegin>
|
||||
struct apply
|
||||
{
|
||||
typedef typename push_front_if<!(is_zero<typename ExponentsBegin::item>::value)>::template apply<
|
||||
typename make_heterogeneous_system_impl<N-1>::template apply<
|
||||
typename UnitsBegin::next,
|
||||
typename ExponentsBegin::next
|
||||
>::type,
|
||||
heterogeneous_system_dim<typename UnitsBegin::item, typename ExponentsBegin::item>
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_heterogeneous_system_impl<0>
|
||||
{
|
||||
template<class UnitsBegin, class ExponentsBegin>
|
||||
struct apply
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class Dimensions, class System>
|
||||
struct make_heterogeneous_system
|
||||
{
|
||||
typedef typename calculate_base_unit_exponents<typename System::type, Dimensions>::type exponents;
|
||||
BOOST_MPL_ASSERT_MSG((!boost::is_same<exponents, inconsistent>::value), the_specified_dimension_is_not_representible_in_the_given_system, (types<Dimensions, System>));
|
||||
typedef typename make_heterogeneous_system_impl<System::type::size::value>::template apply<
|
||||
typename System::type,
|
||||
exponents
|
||||
>::type unit_list;
|
||||
typedef heterogeneous_system<heterogeneous_system_impl<unit_list, Dimensions, no_scale> > type;
|
||||
};
|
||||
|
||||
template<class Dimensions, class T>
|
||||
struct make_heterogeneous_system<Dimensions, heterogeneous_system<T> >
|
||||
{
|
||||
typedef heterogeneous_system<T> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1>
|
||||
struct multiply_systems
|
||||
{
|
||||
typedef heterogeneous_system<
|
||||
heterogeneous_system_impl<
|
||||
typename mpl::times<typename T0::type, typename T1::type>::type,
|
||||
typename mpl::times<typename T0::dimensions, typename T1::dimensions>::type,
|
||||
typename mpl::times<typename T0::scale, typename T1::scale>::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1>
|
||||
struct divide_systems
|
||||
{
|
||||
typedef heterogeneous_system<
|
||||
heterogeneous_system_impl<
|
||||
typename mpl::divides<typename T0::type, typename T1::type>::type,
|
||||
typename mpl::divides<typename T0::dimensions, typename T1::dimensions>::type,
|
||||
typename mpl::divides<typename T0::scale, typename T1::scale>::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class S, long N, long D>
|
||||
struct static_power<heterogeneous_system<S>, static_rational<N,D> >
|
||||
{
|
||||
typedef heterogeneous_system<
|
||||
heterogeneous_system_impl<
|
||||
typename static_power<typename S::type, static_rational<N,D> >::type,
|
||||
typename static_power<typename S::dimensions, static_rational<N,D> >::type,
|
||||
typename static_power<typename S::scale, static_rational<N,D> >::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class S, long N, long D>
|
||||
struct static_root<heterogeneous_system<S>, static_rational<N,D> >
|
||||
{
|
||||
typedef heterogeneous_system<
|
||||
heterogeneous_system_impl<
|
||||
typename static_root<typename S::type, static_rational<N,D> >::type,
|
||||
typename static_root<typename S::dimensions, static_rational<N,D> >::type,
|
||||
typename static_root<typename S::scale, static_rational<N,D> >::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<int N>
|
||||
struct unscale_heterogeneous_system_impl
|
||||
{
|
||||
template<class Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef typename push_front_or_add<
|
||||
typename unscale_heterogeneous_system_impl<N-1>::template apply<
|
||||
typename Begin::next
|
||||
>::type,
|
||||
typename unscale<typename Begin::item>::type
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct unscale_heterogeneous_system_impl<0>
|
||||
{
|
||||
template<class Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Unscale all the base units. e.g
|
||||
/// km s -> m s
|
||||
/// cm km -> m^2
|
||||
/// INTERNAL ONLY
|
||||
template<class T>
|
||||
struct unscale<heterogeneous_system<T> >
|
||||
{
|
||||
typedef heterogeneous_system<
|
||||
heterogeneous_system_impl<
|
||||
typename detail::unscale_heterogeneous_system_impl<
|
||||
T::type::size::value
|
||||
>::template apply<
|
||||
typename T::type
|
||||
>::type,
|
||||
typename T::dimensions,
|
||||
no_scale
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Unit, class Exponent>
|
||||
struct unscale<heterogeneous_system_dim<Unit, Exponent> >
|
||||
{
|
||||
typedef heterogeneous_system_dim<typename unscale<Unit>::type, Exponent> type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<int N>
|
||||
struct get_scale_list_of_heterogeneous_system_impl
|
||||
{
|
||||
template<class Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::times<
|
||||
typename get_scale_list_of_heterogeneous_system_impl<N-1>::template apply<
|
||||
typename Begin::next
|
||||
>::type,
|
||||
typename get_scale_list<typename Begin::item>::type
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_scale_list_of_heterogeneous_system_impl<0>
|
||||
{
|
||||
template<class Begin>
|
||||
struct apply
|
||||
{
|
||||
typedef dimensionless_type type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T>
|
||||
struct get_scale_list<heterogeneous_system<T> >
|
||||
{
|
||||
typedef typename mpl::times<
|
||||
typename detail::get_scale_list_of_heterogeneous_system_impl<
|
||||
T::type::size::value
|
||||
>::template apply<typename T::type>::type,
|
||||
typename T::scale
|
||||
>::type type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Unit, class Exponent>
|
||||
struct get_scale_list<heterogeneous_system_dim<Unit, Exponent> >
|
||||
{
|
||||
typedef typename static_power<typename get_scale_list<Unit>::type, Exponent>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class System, class Dimension>
|
||||
struct check_system : mpl::false_ {};
|
||||
|
||||
template<class System, class Dimension, class Scale>
|
||||
struct check_system<heterogeneous_system<heterogeneous_system_impl<System, Dimension, Scale> >, Dimension> : mpl::true_ {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,105 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_HOMOGENEOUS_SYSTEM_HPP_INCLUDED
|
||||
#define BOOST_UNITS_HOMOGENEOUS_SYSTEM_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
|
||||
#ifdef BOOST_UNITS_CHECK_HOMOGENEOUS_UNITS
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
#include <boost/units/detail/linear_algebra.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
template<class T, class E>
|
||||
struct static_power;
|
||||
|
||||
template<class T, class R>
|
||||
struct static_root;
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class L, long N, long D>
|
||||
struct static_power<homogeneous_system<L>, static_rational<N,D> >
|
||||
{
|
||||
typedef homogeneous_system<L> type;
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class L, long N, long D>
|
||||
struct static_root<homogeneous_system<L>, static_rational<N,D> >
|
||||
{
|
||||
typedef homogeneous_system<L> type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class System, class Dimensions>
|
||||
struct check_system;
|
||||
|
||||
#ifdef BOOST_UNITS_CHECK_HOMOGENEOUS_UNITS
|
||||
|
||||
template<class L, class Dimensions>
|
||||
struct check_system<homogeneous_system<L>, Dimensions> :
|
||||
boost::mpl::not_<
|
||||
boost::is_same<
|
||||
typename calculate_base_unit_exponents<
|
||||
L,
|
||||
Dimensions
|
||||
>::type,
|
||||
inconsistent
|
||||
>
|
||||
> {};
|
||||
|
||||
#else
|
||||
|
||||
template<class L, class Dimensions>
|
||||
struct check_system<homogeneous_system<L>, Dimensions> : mpl::true_ {};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::homogeneous_system, (class))
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1070
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_IS_DIMENSION_LIST_HPP
|
||||
#define BOOST_UNITS_IS_DIMENSION_LIST_HPP
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// \brief Check that a type is a valid dimension list.
|
||||
///
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// Check that a type is a valid dimension list.
|
||||
template<typename Seq>
|
||||
struct is_dimension_list :
|
||||
public mpl::false_
|
||||
{ };
|
||||
|
||||
template<typename Item, typename Next>
|
||||
struct is_dimension_list<list<Item, Next> > :
|
||||
public mpl::true_
|
||||
{ };
|
||||
|
||||
template<>
|
||||
struct is_dimension_list<dimensionless_type> :
|
||||
public mpl::true_
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_IS_DIMENSION_LIST_HPP
|
||||
@@ -0,0 +1,60 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MAKE_SCALED_UNIT_HPP_INCLUDED
|
||||
#define BOOST_UNITS_MAKE_SCALED_UNIT_HPP_INCLUDED
|
||||
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/heterogeneous_system.hpp>
|
||||
#include <boost/units/unit.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace units {
|
||||
|
||||
template<class Unit, class Scale>
|
||||
struct make_scaled_unit {
|
||||
typedef typename make_scaled_unit<typename reduce_unit<Unit>::type, Scale>::type type;
|
||||
};
|
||||
|
||||
template<class Dimension, class UnitList, class OldScale, class Scale>
|
||||
struct make_scaled_unit<unit<Dimension, heterogeneous_system<heterogeneous_system_impl<UnitList, Dimension, OldScale> > >, Scale> {
|
||||
typedef unit<
|
||||
Dimension,
|
||||
heterogeneous_system<
|
||||
heterogeneous_system_impl<
|
||||
UnitList,
|
||||
Dimension,
|
||||
typename mpl::times<
|
||||
OldScale,
|
||||
list<scale_list_dim<Scale>, dimensionless_type>
|
||||
>::type
|
||||
>
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
template<class Dimension, class UnitList, class OldScale, long Base>
|
||||
struct make_scaled_unit<unit<Dimension, heterogeneous_system<heterogeneous_system_impl<UnitList, Dimension, OldScale> > >, scale<Base, static_rational<0> > > {
|
||||
typedef unit<
|
||||
Dimension,
|
||||
heterogeneous_system<
|
||||
heterogeneous_system_impl<
|
||||
UnitList,
|
||||
Dimension,
|
||||
OldScale
|
||||
>
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,145 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MAKE_SYSTEM_HPP
|
||||
#define BOOST_UNITS_MAKE_SYSTEM_HPP
|
||||
|
||||
/// \file
|
||||
/// \brief Metafunction returning a homogeneous system that can
|
||||
/// represent any combination of the base units.
|
||||
/// \details
|
||||
/// Metafunction make_system returning a homogeneous system that can
|
||||
/// 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, for example.
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/dimensionless_type.hpp>
|
||||
#include <boost/units/homogeneous_system.hpp>
|
||||
#include <boost/units/detail/dimension_list.hpp>
|
||||
#include <boost/units/detail/sort.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
#ifdef BOOST_UNITS_DOXYGEN
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct unspecified {};
|
||||
|
||||
}
|
||||
|
||||
/// Metafunction returning a homogeneous system that can
|
||||
/// 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, for example.
|
||||
template<class BaseUnit0, class BaseUnit1, class BaseUnit2, ..., class BaseUnitN>
|
||||
struct make_system
|
||||
{
|
||||
typedef homogeneous_system<detail::unspecified> type;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
struct na {};
|
||||
|
||||
template<
|
||||
class U0 = na,
|
||||
class U1 = na,
|
||||
class U2 = na,
|
||||
class U3 = na,
|
||||
class U4 = na,
|
||||
class U5 = na,
|
||||
class U6 = na,
|
||||
class U7 = na,
|
||||
class U8 = na,
|
||||
class U9 = na
|
||||
>
|
||||
struct make_system;
|
||||
|
||||
template<>
|
||||
struct make_system<>
|
||||
{
|
||||
typedef homogeneous_system<dimensionless_type> type;
|
||||
};
|
||||
|
||||
// Codewarrior 9.2 doesn't like using the defaults. Need
|
||||
// to specify na explicitly.
|
||||
template<class T0>
|
||||
struct make_system<T0, na, na, na, na, na, na, na, na, na>
|
||||
{
|
||||
typedef homogeneous_system<list<T0, dimensionless_type> > type;
|
||||
};
|
||||
|
||||
template<class T0, class T1>
|
||||
struct make_system<T0, T1, na, na, na, na, na, na, na, na>
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, dimensionless_type> > >::type> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1, class T2>
|
||||
struct make_system<T0, T1, T2, na, na, na, na, na, na, na>
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, list<T2, dimensionless_type> > > >::type> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1, class T2, class T3>
|
||||
struct make_system<T0, T1, T2, T3, na, na, na, na, na, na>
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, list<T2, list<T3, dimensionless_type> > > > >::type> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1, class T2, class T3, class T4>
|
||||
struct make_system<T0, T1, T2, T3, T4, na, na, na, na, na>
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, list<T2, list<T3, list<T4, dimensionless_type> > > > > >::type> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1, class T2, class T3, class T4, class T5>
|
||||
struct make_system<T0, T1, T2, T3, T4, T5, na, na, na, na>
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, list<T2, list<T3, list<T4, list<T5, dimensionless_type> > > > > > >::type> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
struct make_system<T0, T1, T2, T3, T4, T5, T6, na, na, na>
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, list<T2, list<T3, list<T4, list<T5, list<T6, dimensionless_type> > > > > > > >::type> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
||||
struct make_system<T0, T1, T2, T3, T4, T5, T6, T7, na, na>
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, list<T2, list<T3, list<T4, list<T5, list<T6, list<T7, dimensionless_type> > > > > > > > >::type> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
||||
struct make_system<T0, T1, T2, T3, T4, T5, T6, T7, T8, na>
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, list<T2, list<T3, list<T4, list<T5, list<T6, list<T7, list<T8, dimensionless_type> > > > > > > > > >::type> type;
|
||||
};
|
||||
|
||||
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9>
|
||||
struct make_system
|
||||
{
|
||||
typedef homogeneous_system<typename detail::insertion_sort<list<T0, list<T1, list<T2, list<T3, list<T4, list<T5, list<T6, list<T7, list<T8, list<T9, dimensionless_type> > > > > > > > > > >::type> type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,164 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_OPERATORS_HPP
|
||||
#define BOOST_UNITS_OPERATORS_HPP
|
||||
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// \brief Compile time operators and typeof helper classes.
|
||||
/// \details
|
||||
/// These operators declare the compile-time operators needed to support dimensional
|
||||
/// analysis algebra. They require the use of Boost.Typeof, emulation or native.
|
||||
/// Typeof helper classes define result type for heterogeneous operators on value types.
|
||||
/// These must be defined through specialization for powers and roots.
|
||||
///
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace units {
|
||||
|
||||
#if BOOST_UNITS_HAS_TYPEOF
|
||||
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
|
||||
// to avoid need for default constructor and eliminate divide by zero errors.
|
||||
namespace typeof_ {
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class T> T make();
|
||||
|
||||
} // namespace typeof_
|
||||
|
||||
#endif
|
||||
|
||||
#if (BOOST_UNITS_HAS_BOOST_TYPEOF)
|
||||
|
||||
template<typename X> struct unary_plus_typeof_helper
|
||||
{
|
||||
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (+typeof_::make<X>()))
|
||||
typedef typename nested::type type;
|
||||
};
|
||||
|
||||
template<typename X> struct unary_minus_typeof_helper
|
||||
{
|
||||
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (-typeof_::make<X>()))
|
||||
typedef typename nested::type type;
|
||||
};
|
||||
|
||||
template<typename X,typename Y> struct add_typeof_helper
|
||||
{
|
||||
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (typeof_::make<X>()+typeof_::make<Y>()))
|
||||
typedef typename nested::type type;
|
||||
};
|
||||
|
||||
template<typename X,typename Y> struct subtract_typeof_helper
|
||||
{
|
||||
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (typeof_::make<X>()-typeof_::make<Y>()))
|
||||
typedef typename nested::type type;
|
||||
};
|
||||
|
||||
template<typename X,typename Y> struct multiply_typeof_helper
|
||||
{
|
||||
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (typeof_::make<X>()*typeof_::make<Y>()))
|
||||
typedef typename nested::type type;
|
||||
};
|
||||
|
||||
template<typename X,typename Y> struct divide_typeof_helper
|
||||
{
|
||||
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (typeof_::make<X>()/typeof_::make<Y>()))
|
||||
typedef typename nested::type type;
|
||||
};
|
||||
|
||||
#elif (BOOST_UNITS_HAS_MWERKS_TYPEOF)
|
||||
|
||||
template<typename X> struct unary_plus_typeof_helper { typedef __typeof__((+typeof_::make<X>())) type; };
|
||||
template<typename X> struct unary_minus_typeof_helper { typedef __typeof__((-typeof_::make<X>())) type; };
|
||||
|
||||
template<typename X,typename Y> struct add_typeof_helper { typedef __typeof__((typeof_::make<X>()+typeof_::make<Y>())) type; };
|
||||
template<typename X,typename Y> struct subtract_typeof_helper { typedef __typeof__((typeof_::make<X>()-typeof_::make<Y>())) type; };
|
||||
template<typename X,typename Y> struct multiply_typeof_helper { typedef __typeof__((typeof_::make<X>()*typeof_::make<Y>())) type; };
|
||||
template<typename X,typename Y> struct divide_typeof_helper { typedef __typeof__((typeof_::make<X>()/typeof_::make<Y>())) type; };
|
||||
|
||||
#elif (BOOST_UNITS_HAS_GNU_TYPEOF) || defined(BOOST_UNITS_DOXYGEN)
|
||||
|
||||
template<typename X> struct unary_plus_typeof_helper { typedef typeof((+typeof_::make<X>())) type; };
|
||||
template<typename X> struct unary_minus_typeof_helper { typedef typeof((-typeof_::make<X>())) type; };
|
||||
|
||||
template<typename X,typename Y> struct add_typeof_helper { typedef typeof((typeof_::make<X>()+typeof_::make<Y>())) type; };
|
||||
template<typename X,typename Y> struct subtract_typeof_helper { typedef typeof((typeof_::make<X>()-typeof_::make<Y>())) type; };
|
||||
template<typename X,typename Y> struct multiply_typeof_helper { typedef typeof((typeof_::make<X>()*typeof_::make<Y>())) type; };
|
||||
template<typename X,typename Y> struct divide_typeof_helper { typedef typeof((typeof_::make<X>()/typeof_::make<Y>())) type; };
|
||||
|
||||
#endif
|
||||
|
||||
#else // BOOST_UNITS_HAS_TYPEOF
|
||||
|
||||
template<typename X> struct unary_plus_typeof_helper { typedef X type; };
|
||||
template<typename X> struct unary_minus_typeof_helper { typedef X type; };
|
||||
|
||||
template<typename X,typename Y> struct add_typeof_helper { BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
|
||||
template<typename X,typename Y> struct subtract_typeof_helper { BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
|
||||
template<typename X,typename Y> struct multiply_typeof_helper { BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
|
||||
template<typename X,typename Y> struct divide_typeof_helper { BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
|
||||
|
||||
#endif // BOOST_UNITS_HAS_TYPEOF
|
||||
|
||||
template<typename X,typename Y> struct power_typeof_helper;
|
||||
template<typename X,typename Y> struct root_typeof_helper;
|
||||
|
||||
#ifdef BOOST_UNITS_DOXYGEN
|
||||
|
||||
/// A helper used by @c pow to raise
|
||||
/// a runtime object to a compile time
|
||||
/// known exponent. This template is intended to
|
||||
/// be specialized. All specializations must
|
||||
/// conform to the interface shown here.
|
||||
/// @c Exponent will be either the exponent
|
||||
/// passed to @c pow or @c static_rational<N>
|
||||
/// for and integer argument, N.
|
||||
template<typename BaseType, typename Exponent>
|
||||
struct power_typeof_helper
|
||||
{
|
||||
/// specifies the result type
|
||||
typedef detail::unspecified type;
|
||||
/// Carries out the runtime calculation.
|
||||
static type value(const BaseType& base);
|
||||
};
|
||||
|
||||
/// A helper used by @c root to take a root
|
||||
/// of a runtime object using a compile time
|
||||
/// known index. This template is intended to
|
||||
/// be specialized. All specializations must
|
||||
/// conform to the interface shown here.
|
||||
/// @c Index will be either the type
|
||||
/// passed to @c pow or @c static_rational<N>
|
||||
/// for and integer argument, N.
|
||||
template<typename Radicand, typename Index>
|
||||
struct root_typeof_helper
|
||||
{
|
||||
/// specifies the result type
|
||||
typedef detail::unspecified type;
|
||||
/// Carries out the runtime calculation.
|
||||
static type value(const Radicand& base);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_OPERATORS_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ABSORBED_DOSE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ABSORBED_DOSE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for absorbed dose : L^2 T^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
time_base_dimension,-2>::type absorbed_dose_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ABSORBED_DOSE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ACCELERATION_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ACCELERATION_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for acceleration : L T^-2
|
||||
typedef derived_dimension<length_base_dimension,1,
|
||||
time_base_dimension,-2>::type acceleration_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ACCELERATION_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ACTION_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ACTION_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for action : L^2 M T^-1
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-1>::type action_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ACTION_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,28 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ACTIVITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ACTIVITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for activity : T^-1
|
||||
typedef derived_dimension<time_base_dimension,-1>::type activity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ACTIVITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_AMOUNT_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_AMOUNT_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of amount
|
||||
struct amount_base_dimension :
|
||||
boost::units::base_dimension<amount_base_dimension,-4>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::amount_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// dimension of amount of substance (N)
|
||||
typedef amount_base_dimension::dimension_type amount_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_AMOUNT_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ANGULAR_ACCELERATION_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ANGULAR_ACCELERATION_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/plane_angle.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for angular acceleration : T^-2 QP
|
||||
typedef derived_dimension<time_base_dimension,-2,
|
||||
plane_angle_base_dimension,1>::type angular_acceleration_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ANGULAR_ACCELERATION_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ANGULAR_MOMENTUM_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ANGULAR_MOMENTUM_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/plane_angle.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for angular momentum : L^2 M T^-1 QP^-1
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-1,
|
||||
plane_angle_base_dimension,-1>::type angular_momentum_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ANGULAR_MOMENTUM_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ANGULAR_VELOCITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ANGULAR_VELOCITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/plane_angle.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for angular velocity : T^-1 QP
|
||||
typedef derived_dimension<time_base_dimension,-1,
|
||||
plane_angle_base_dimension,1>::type angular_velocity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ANGULAR_VELOCITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,28 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_AREA_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_AREA_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for area : L^2
|
||||
typedef derived_dimension<length_base_dimension,2>::type area_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_AREA_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_CAPACITANCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_CAPACITANCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for capacitance : L^-2 M^-1 T^4 I^2
|
||||
typedef derived_dimension<length_base_dimension,-2,
|
||||
mass_base_dimension,-1,
|
||||
time_base_dimension,4,
|
||||
current_base_dimension,2>::type capacitance_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_CAPACITANCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_CONDUCTANCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_CONDUCTANCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for conductance : L^-2 M^-1 T^3 I^2
|
||||
typedef derived_dimension<length_base_dimension,-2,
|
||||
mass_base_dimension,-1,
|
||||
time_base_dimension,3,
|
||||
current_base_dimension,2>::type conductance_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_CONDUCTANCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_CONDUCTIVITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_CONDUCTIVITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for conductivity : L^-3 M^-1 T^3 I^2
|
||||
typedef derived_dimension<length_base_dimension,-3,
|
||||
mass_base_dimension,-1,
|
||||
time_base_dimension,3,
|
||||
current_base_dimension,2>::type conductivity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_CONDUCTIVITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_CURRENT_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_CURRENT_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of current
|
||||
struct current_base_dimension :
|
||||
boost::units::base_dimension<current_base_dimension,-6>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::current_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// dimension of electric current (I)
|
||||
typedef current_base_dimension::dimension_type current_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_CURRENT_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DOSE_EQUIVALENT_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_DOSE_EQUIVALENT_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for dose equivalent : L^2 T^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
time_base_dimension,-2>::type dose_equivalent_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_DOSE_EQUIVALENT_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_DYNAMIC_VISCOSITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_DYNAMIC_VISCOSITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for dynamic viscosity : M L^-1 T^-1
|
||||
typedef derived_dimension<mass_base_dimension,1,
|
||||
length_base_dimension,-1,
|
||||
time_base_dimension,-1>::type dynamic_viscosity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_DYNAMIC_VISCOSITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ELECTRIC_CHARGE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ELECTRIC_CHARGE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for electric charge : T^1 I^1
|
||||
typedef derived_dimension<time_base_dimension,1,
|
||||
current_base_dimension,1>::type electric_charge_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ELECTRIC_CHARGE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ELECTRIC_POTENTIAL_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ELECTRIC_POTENTIAL_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for electric potential : L^2 M T^-3 I^-1
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-3,
|
||||
current_base_dimension,-1>::type electric_potential_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ELECTRIC_POTENTIAL_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ENERGY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ENERGY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for energy : L^2 M T^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-2>::type energy_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ENERGY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_FORCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_FORCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for force : L M T^-2
|
||||
typedef derived_dimension<length_base_dimension,1,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-2>::type force_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_FORCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,28 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_FREQUENCY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_FREQUENCY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for frequency : T^-1
|
||||
typedef derived_dimension<time_base_dimension,-1>::type frequency_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_FREQUENCY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_ILLUMINANCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ILLUMINANCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/luminous_intensity.hpp>
|
||||
#include <boost/units/physical_dimensions/solid_angle.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for illuminance : L^-2 I QS
|
||||
typedef derived_dimension<length_base_dimension,-2,
|
||||
luminous_intensity_base_dimension,1,
|
||||
solid_angle_base_dimension,1>::type illuminance_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ILLUMINANCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_IMPEDANCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_IMPEDANCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for impedance : L^2 M T^-3 I^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-3,
|
||||
current_base_dimension,-2>::type impedance_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_IMPEDANCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_INDUCTANCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_INDUCTANCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for inductance : L^2 M T^-2 I^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-2,
|
||||
current_base_dimension,-2>::type inductance_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_INDUCTANCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_KINEMATIC_VISCOSITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_KINEMATIC_VISCOSITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for kinematic viscosity : L^2 T^-1
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
time_base_dimension,-1>::type kinematic_viscosity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_KINEMATIC_VISCOSITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_LENGTH_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_LENGTH_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of length
|
||||
struct length_base_dimension :
|
||||
boost::units::base_dimension<length_base_dimension, -9>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::length_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// dimension of length (L)
|
||||
typedef length_base_dimension::dimension_type length_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_LENGTH_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_LUMINOUS_FLUX_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_LUMINOUS_FLUX_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/luminous_intensity.hpp>
|
||||
#include <boost/units/physical_dimensions/solid_angle.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for luminous flux : I QS
|
||||
typedef derived_dimension<luminous_intensity_base_dimension,1,
|
||||
solid_angle_base_dimension,1>::type luminous_flux_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_LUMINOUS_FLUX_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_LUMINOUS_INTENSITY_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_LUMINOUS_INTENSITY_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of luminous intensity
|
||||
struct luminous_intensity_base_dimension :
|
||||
boost::units::base_dimension<luminous_intensity_base_dimension,-3>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::luminous_intensity_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// dimension of luminous intensity (J)
|
||||
typedef luminous_intensity_base_dimension::dimension_type luminous_intensity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_LUMINOUS_INTENSITY_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MAGNETIC_FIELD_INTENSITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_MAGNETIC_FIELD_INTENSITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for magnetic field intensity : L^-1 I
|
||||
typedef derived_dimension<length_base_dimension,-1,
|
||||
current_base_dimension,1>::type magnetic_field_intensity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_MAGNETIC_FIELD_INTENSITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MAGNETIC_FLUX_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_MAGNETIC_FLUX_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for magnetic flux : L^2 M T^-2 I^-1
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-2,
|
||||
current_base_dimension,-1>::type magnetic_flux_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_MAGNETIC_FLUX_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MAGNETIC_FLUX_DENSITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_MAGNETIC_FLUX_DENSITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for magnetic flux density : M T^-2 I^-1
|
||||
typedef derived_dimension<mass_base_dimension,1,
|
||||
time_base_dimension,-2,
|
||||
current_base_dimension,-1>::type magnetic_flux_density_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_MAGNETIC_FLUX_DENSITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MASS_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_MASS_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of mass
|
||||
struct mass_base_dimension :
|
||||
boost::units::base_dimension<mass_base_dimension,-8>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::mass_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// dimension of mass (M)
|
||||
typedef mass_base_dimension::dimension_type mass_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_MASS_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MASS_DENSITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_MASS_DENSITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for mass density : L^-3 M
|
||||
typedef derived_dimension<length_base_dimension,-3,
|
||||
mass_base_dimension,1>::type mass_density_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_MASS_DENSITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MOMENT_OF_INERTIA_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_MOMENT_OF_INERTIA_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/plane_angle.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for moment of inertia : L^2 M QP^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
plane_angle_base_dimension,-2>::type moment_of_inertia_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_MOMENT_OF_INERTIA_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_MOMENTUM_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_MOMENTUM_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for linear momentum : L M T^-1
|
||||
typedef derived_dimension<length_base_dimension,1,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-1>::type momentum_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_MOMENTUM_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_PERMEABILITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_PERMEABILITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for permeability : L M T^-2 I^-2
|
||||
typedef derived_dimension<length_base_dimension,1,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-2,
|
||||
current_base_dimension,-2>::type permeability_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_PERMEABILITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_PERMITTIVITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_PERMITTIVITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for permittivity : L^-3 M^-1 T^4 I^2
|
||||
typedef derived_dimension<length_base_dimension,-3,
|
||||
mass_base_dimension,-1,
|
||||
time_base_dimension,4,
|
||||
current_base_dimension,2>::type permittivity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_PERMITTIVITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_PLANE_ANGLE_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_PLANE_ANGLE_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of plane angle
|
||||
struct plane_angle_base_dimension :
|
||||
boost::units::base_dimension<plane_angle_base_dimension,-2>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::plane_angle_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of plane angle (QP)
|
||||
typedef plane_angle_base_dimension::dimension_type plane_angle_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_PLANE_ANGLE_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_POWER_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_POWER_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for power : L^2 M T^-3
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-3>::type power_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_POWER_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_PRESSURE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_PRESSURE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for pressure : L^-1 M T^-2
|
||||
typedef derived_dimension<length_base_dimension,-1,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-2>::type pressure_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_PRESSURE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_RELUCTANCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_RELUCTANCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for reluctance : L^-2 M^-1 T^2 I^2
|
||||
typedef derived_dimension<length_base_dimension,-2,
|
||||
mass_base_dimension,-1,
|
||||
time_base_dimension,2,
|
||||
current_base_dimension,2>::type reluctance_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_RELUCTANCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_RESISTANCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_RESISTANCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for resistance : L^2 M T^-3 I^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-3,
|
||||
current_base_dimension,-2>::type resistance_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_RESISTANCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_RESISTIVITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_RESISTIVITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for resistivity : L^3 M T^-3 I^-2
|
||||
typedef derived_dimension<length_base_dimension,3,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-3,
|
||||
current_base_dimension,-2>::type resistivity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_RESISTIVITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SOLID_ANGLE_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_SOLID_ANGLE_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of solid angle
|
||||
struct solid_angle_base_dimension :
|
||||
boost::units::base_dimension<solid_angle_base_dimension,-1>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::solid_angle_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of solid angle (QS)
|
||||
typedef solid_angle_base_dimension::dimension_type solid_angle_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_SOLID_ANGLE_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SURFACE_DENSITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_SURFACE_DENSITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for surface density : L^-2 M
|
||||
typedef derived_dimension<length_base_dimension,-2,
|
||||
mass_base_dimension,1>::type surface_density_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_SURFACE_DENSITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,31 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SURFACE_TENSION_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_SURFACE_TENSION_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for surface tension : M T^-2
|
||||
typedef derived_dimension<mass_base_dimension,1,
|
||||
time_base_dimension,-2>::type surface_tension_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_SURFACE_TENSION_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_TEMPERATURE_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_TEMPERATURE_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of temperature
|
||||
struct temperature_base_dimension :
|
||||
boost::units::base_dimension<temperature_base_dimension,-5>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::temperature_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// dimension of temperature (Theta)
|
||||
typedef temperature_base_dimension::dimension_type temperature_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_TEMPERATURE_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_TIME_BASE_DIMENSION_HPP
|
||||
#define BOOST_UNITS_TIME_BASE_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/base_dimension.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// base dimension of time
|
||||
struct time_base_dimension :
|
||||
boost::units::base_dimension<time_base_dimension,-7>
|
||||
{ };
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TYPE(boost::units::time_base_dimension)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// dimension of time (T)
|
||||
typedef time_base_dimension::dimension_type time_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_TIME_BASE_DIMENSION_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_TORQUE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_TORQUE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/plane_angle.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for torque : L^2 M T^-2 QP^-1
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-2,
|
||||
plane_angle_base_dimension,-1>::type torque_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_TORQUE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_VELOCITY_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_VELOCITY_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for velocity : L T^-1
|
||||
typedef derived_dimension<length_base_dimension,1,
|
||||
time_base_dimension,-1>::type velocity_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_VELOCITY_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,28 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_VOLUME_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_VOLUME_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for volume : l^3
|
||||
typedef derived_dimension<length_base_dimension,3>::type volume_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_VOLUME_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,28 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_WAVENUMBER_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_WAVENUMBER_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for wavenumber : L^-1
|
||||
typedef derived_dimension<length_base_dimension,-1>::type wavenumber_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_WAVENUMBER_DERIVED_DIMENSION_HPP
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_REDUCE_UNIT_HPP_INCLUDED
|
||||
#define BOOST_UNITS_REDUCE_UNIT_HPP_INCLUDED
|
||||
|
||||
/// \file
|
||||
/// \brief Returns a unique type for every unit.
|
||||
|
||||
namespace boost {
|
||||
namespace units {
|
||||
|
||||
#ifdef BOOST_UNITS_DOXYGEN
|
||||
|
||||
/// Returns a unique type for every unit.
|
||||
template<class Unit>
|
||||
struct reduce_unit {
|
||||
typedef detail::unspecified type;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
// default implementation: return Unit unchanged.
|
||||
template<class Unit>
|
||||
struct reduce_unit {
|
||||
typedef Unit type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,145 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2007-2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SCALE_HPP_INCLUDED
|
||||
#define BOOST_UNITS_SCALE_HPP_INCLUDED
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// \brief 10^3 Engineering & 2^10 binary scaling factors for autoprefixing.
|
||||
/// \details
|
||||
///
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
#include <boost/units/detail/one.hpp>
|
||||
#include <boost/units/detail/static_rational_power.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class S, class Scale>
|
||||
struct scaled_base_unit;
|
||||
|
||||
/// class representing a scaling factor such as 10^3
|
||||
/// The exponent must be a static rational.
|
||||
template<long Base, class Exponent>
|
||||
struct scale
|
||||
{
|
||||
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))); }
|
||||
// These need to be defined in specializations for
|
||||
// printing to work.
|
||||
// static std::string name();
|
||||
// static std::string symbol();
|
||||
};
|
||||
|
||||
template<long Base, class Exponent>
|
||||
const long scale<Base, Exponent>::base;
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<long Base>
|
||||
struct scale<Base, static_rational<0> >
|
||||
{
|
||||
static const long base = Base;
|
||||
typedef static_rational<0> exponent;
|
||||
typedef one value_type;
|
||||
static one value() { one result; return(result); }
|
||||
static std::string name() { return(""); }
|
||||
static std::string symbol() { return(""); }
|
||||
};
|
||||
|
||||
template<long Base>
|
||||
const long scale<Base, static_rational<0> >::base;
|
||||
|
||||
template<long Base,class Exponent>
|
||||
std::string symbol_string(const scale<Base,Exponent>&)
|
||||
{
|
||||
return scale<Base,Exponent>::symbol();
|
||||
}
|
||||
|
||||
template<long Base,class Exponent>
|
||||
std::string name_string(const scale<Base,Exponent>&)
|
||||
{
|
||||
return scale<Base,Exponent>::name();
|
||||
}
|
||||
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
|
||||
#define BOOST_UNITS_SCALE_SPECIALIZATION(base_,exponent_,val_,name_,symbol_) \
|
||||
template<> \
|
||||
struct scale<base_, exponent_ > \
|
||||
{ \
|
||||
static const long base = base_; \
|
||||
typedef exponent_ exponent; \
|
||||
typedef double value_type; \
|
||||
static value_type value() { return(val_); } \
|
||||
static std::string name() { return(#name_); } \
|
||||
static std::string symbol() { return(#symbol_); } \
|
||||
}
|
||||
|
||||
#define BOOST_UNITS_SCALE_DEF(exponent_,value_,name_,symbol_) \
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(10,static_rational<exponent_>,value_, name_, symbol_)
|
||||
|
||||
BOOST_UNITS_SCALE_DEF(-24, 1e-24, yocto, y);
|
||||
BOOST_UNITS_SCALE_DEF(-21, 1e-21, zepto, z);
|
||||
BOOST_UNITS_SCALE_DEF(-18, 1e-18, atto, a);
|
||||
BOOST_UNITS_SCALE_DEF(-15, 1e-15, femto, f);
|
||||
BOOST_UNITS_SCALE_DEF(-12, 1e-12, pico, p);
|
||||
BOOST_UNITS_SCALE_DEF(-9, 1e-9, nano, n);
|
||||
BOOST_UNITS_SCALE_DEF(-6, 1e-6, micro, u);
|
||||
BOOST_UNITS_SCALE_DEF(-3, 1e-3, milli, m);
|
||||
BOOST_UNITS_SCALE_DEF(-2, 1e-2, centi, c);
|
||||
BOOST_UNITS_SCALE_DEF(-1, 1e-1, deci, d);
|
||||
|
||||
BOOST_UNITS_SCALE_DEF(1, 1e1, deka, da);
|
||||
BOOST_UNITS_SCALE_DEF(2, 1e2, hecto, h);
|
||||
BOOST_UNITS_SCALE_DEF(3, 1e3, kilo, k);
|
||||
BOOST_UNITS_SCALE_DEF(6, 1e6, mega, M);
|
||||
BOOST_UNITS_SCALE_DEF(9, 1e9, giga, G);
|
||||
BOOST_UNITS_SCALE_DEF(12, 1e12, tera, T);
|
||||
BOOST_UNITS_SCALE_DEF(15, 1e15, peta, P);
|
||||
BOOST_UNITS_SCALE_DEF(18, 1e18, exa, E);
|
||||
BOOST_UNITS_SCALE_DEF(21, 1e21, zetta, Z);
|
||||
BOOST_UNITS_SCALE_DEF(24, 1e24, yotta, Y);
|
||||
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(2, static_rational<10>, 1024.0, kibi, Ki);
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(2, static_rational<20>, 1048576.0, mebi, Mi);
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(2, static_rational<30>, 1073741824.0, gibi, Gi);
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(2, static_rational<40>, 1099511627776.0, tebi, Ti);
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(2, static_rational<50>, 1125899906842624.0, pebi, Pi);
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(2, static_rational<60>, 1152921504606846976.0, exbi, Ei);
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(2, static_rational<70>, 1180591620717411303424.0, zebi, Zi);
|
||||
BOOST_UNITS_SCALE_SPECIALIZATION(2, static_rational<80>, 1208925819614629174706176.0, yobi, Yi);
|
||||
|
||||
#undef BOOST_UNITS_SCALE_DEF
|
||||
#undef BOOST_UNITS_SCALE_SPECIALIZATION
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::scale, (long)(class))
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,144 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_SCALED_BASE_UNIT_HPP_INCLUDED
|
||||
#define BOOST_UNITS_SCALED_BASE_UNIT_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/dimension.hpp>
|
||||
#include <boost/units/static_rational.hpp>
|
||||
#include <boost/units/units_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
template<class T>
|
||||
struct heterogeneous_system;
|
||||
|
||||
template<class T, class D, class Scale>
|
||||
struct heterogeneous_system_impl;
|
||||
|
||||
template<class T, class E>
|
||||
struct heterogeneous_system_dim;
|
||||
|
||||
template<class T>
|
||||
struct base_unit_info;
|
||||
|
||||
/// INTERNAL ONLY
|
||||
struct scaled_base_unit_tag {};
|
||||
|
||||
template<class S, class Scale>
|
||||
struct scaled_base_unit
|
||||
{
|
||||
/// INTERNAL ONLY
|
||||
typedef void boost_units_is_base_unit_type;
|
||||
typedef scaled_base_unit type;
|
||||
typedef scaled_base_unit_tag tag;
|
||||
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<
|
||||
heterogeneous_system_impl<
|
||||
list<
|
||||
heterogeneous_system_dim<scaled_base_unit,static_rational<1> >,
|
||||
dimensionless_type
|
||||
>,
|
||||
dimension_type,
|
||||
dimensionless_type
|
||||
>
|
||||
>
|
||||
> unit_type;
|
||||
|
||||
#endif
|
||||
|
||||
static std::string symbol()
|
||||
{
|
||||
return(Scale::symbol() + base_unit_info<S>::symbol());
|
||||
}
|
||||
static std::string name()
|
||||
{
|
||||
return(Scale::name() + base_unit_info<S>::name());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::scaled_base_unit, (class)(class))
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
|
||||
namespace mpl {
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Tag>
|
||||
struct less_impl<boost::units::scaled_base_unit_tag, Tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply : mpl::bool_<
|
||||
mpl::less<typename T0::system_type, T1>::value ||
|
||||
(boost::is_same<typename T0::system_type, T1>::value && ((T0::scale_type::exponent::Numerator) < 0)) > {};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<class Tag>
|
||||
struct less_impl<Tag, boost::units::scaled_base_unit_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply : mpl::bool_<
|
||||
mpl::less<T0, typename T1::system_type>::value ||
|
||||
(boost::is_same<T0, typename T1::system_type>::value && ((T1::scale_type::exponent::Numerator) > 0)) > {};
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
template<>
|
||||
struct less_impl<boost::units::scaled_base_unit_tag, boost::units::scaled_base_unit_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply : mpl::bool_<
|
||||
mpl::less<typename T0::system_type, typename T1::system_type>::value ||
|
||||
((boost::is_same<typename T0::system_type, typename T1::system_type>::value) &&
|
||||
((T0::scale_type::base) < (T1::scale_type::base) ||
|
||||
((T0::scale_type::base) == (T1::scale_type::base) &&
|
||||
mpl::less<typename T0::scale_type::exponent, typename T1::scale_type::exponent>::value))) > {};
|
||||
};
|
||||
|
||||
} // namespace mpl
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_STATIC_CONSTANT_HPP
|
||||
#define BOOST_UNITS_STATIC_CONSTANT_HPP
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
|
||||
/// A convenience macro that allows definition of static
|
||||
/// constants in headers in an ODR-safe way.
|
||||
#define BOOST_UNITS_STATIC_CONSTANT(name, type) \
|
||||
template<bool b> \
|
||||
struct name##_instance_t \
|
||||
{ \
|
||||
static const type instance; \
|
||||
}; \
|
||||
\
|
||||
namespace \
|
||||
{ \
|
||||
static const type& name = name##_instance_t<true>::instance; \
|
||||
} \
|
||||
\
|
||||
template<bool b> \
|
||||
const type name##_instance_t<b>::instance
|
||||
|
||||
/// A convenience macro for static constants with auto
|
||||
/// type deduction.
|
||||
#if BOOST_UNITS_HAS_TYPEOF
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
|
||||
BOOST_TYPEOF_NESTED_TYPEDEF(name##_nested_t, value) \
|
||||
BOOST_UNITS_STATIC_CONSTANT(name, name##_nested_t::type) = (value)
|
||||
|
||||
#elif BOOST_UNITS_HAS_MWERKS_TYPEOF
|
||||
|
||||
#define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
|
||||
BOOST_UNITS_STATIC_CONSTANT(name, __typeof__(value)) = (value)
|
||||
|
||||
#elif BOOST_UNITS_HAS_GNU_TYPEOF
|
||||
|
||||
#define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
|
||||
BOOST_UNITS_STATIC_CONSTANT(name, typeof(value)) = (value)
|
||||
|
||||
#endif // BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#endif // BOOST_UNITS_HAS_TYPEOF
|
||||
|
||||
#endif // BOOST_UNITS_STATIC_CONSTANT_HPP
|
||||
@@ -0,0 +1,349 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_UNITS_STATIC_RATIONAL_HPP
|
||||
#define BOOST_UNITS_STATIC_RATIONAL_HPP
|
||||
|
||||
#include <boost/integer/common_factor_ct.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/mpl/arithmetic.hpp>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/integral_c.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/units/config.hpp>
|
||||
#include <boost/units/operators.hpp>
|
||||
|
||||
/// \file
|
||||
/// \brief Compile-time rational numbers and operators.
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct static_rational_tag {};
|
||||
|
||||
}
|
||||
|
||||
typedef long integer_type;
|
||||
|
||||
/// Compile time absolute value.
|
||||
template<integer_type Value>
|
||||
struct static_abs
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(integer_type,value = Value < 0 ? -Value : Value);
|
||||
};
|
||||
|
||||
// Compile time rational number.
|
||||
/**
|
||||
This is an implementation of a compile time rational number, where @c static_rational<N,D> represents
|
||||
a rational number with numerator @c N and denominator @c D. Because of the potential for ambiguity arising
|
||||
from multiple equivalent values of @c static_rational (e.g. @c static_rational<6,2>==static_rational<3>),
|
||||
static rationals should always be accessed through @c static_rational<N,D>::type. Template specialization
|
||||
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 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
|
||||
values.
|
||||
*/
|
||||
#ifdef __BORLANDC__
|
||||
|
||||
template<integer_type X>
|
||||
struct make_integral_c {
|
||||
typedef boost::mpl::integral_c<integer_type, X> type;
|
||||
};
|
||||
|
||||
template<integer_type N,integer_type D = 1>
|
||||
class static_rational
|
||||
{
|
||||
public:
|
||||
|
||||
typedef static_rational this_type;
|
||||
|
||||
typedef boost::mpl::integral_c<integer_type, N> N_type;
|
||||
typedef boost::mpl::integral_c<integer_type, D> D_type;
|
||||
|
||||
typedef typename make_integral_c<
|
||||
(::boost::integer::static_gcd<
|
||||
::boost::units::static_abs<N>::value,
|
||||
::boost::units::static_abs<D>::value
|
||||
>::value)>::type gcd_type;
|
||||
typedef typename boost::mpl::eval_if<
|
||||
boost::mpl::less<
|
||||
D_type,
|
||||
boost::mpl::integral_c<integer_type, 0>
|
||||
>,
|
||||
boost::mpl::negate<gcd_type>,
|
||||
gcd_type
|
||||
>::type den_type;
|
||||
|
||||
public:
|
||||
// for mpl arithmetic support
|
||||
typedef detail::static_rational_tag tag;
|
||||
|
||||
BOOST_STATIC_CONSTANT(integer_type, Numerator =
|
||||
(::boost::mpl::divides<N_type, den_type>::value));
|
||||
BOOST_STATIC_CONSTANT(integer_type, Denominator =
|
||||
(::boost::mpl::divides<D_type, den_type>::value));
|
||||
|
||||
/// INTERNAL ONLY
|
||||
typedef static_rational<N,D> this_type;
|
||||
|
||||
/// static_rational<N,D> reduced by GCD
|
||||
typedef static_rational<
|
||||
(::boost::mpl::divides<N_type, den_type>::value),
|
||||
(::boost::mpl::divides<D_type, den_type>::value)
|
||||
> type;
|
||||
|
||||
static integer_type numerator() { return Numerator; }
|
||||
static integer_type denominator() { return Denominator; }
|
||||
|
||||
// INTERNAL ONLY
|
||||
static_rational() { }
|
||||
//~static_rational() { }
|
||||
};
|
||||
#else
|
||||
template<integer_type N,integer_type D = 1>
|
||||
class static_rational
|
||||
{
|
||||
private:
|
||||
|
||||
static const integer_type nabs = static_abs<N>::value,
|
||||
dabs = static_abs<D>::value;
|
||||
|
||||
/// greatest common divisor of N and D
|
||||
// need cast to signed because static_gcd returns unsigned long
|
||||
static const integer_type den =
|
||||
static_cast<integer_type>(boost::integer::static_gcd<nabs,dabs>::value) * ((D < 0) ? -1 : 1);
|
||||
|
||||
public:
|
||||
// for mpl arithmetic support
|
||||
typedef detail::static_rational_tag tag;
|
||||
|
||||
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
|
||||
typedef static_rational<Numerator,Denominator> type;
|
||||
|
||||
static integer_type numerator() { return Numerator; }
|
||||
static integer_type denominator() { return Denominator; }
|
||||
|
||||
// INTERNAL ONLY
|
||||
static_rational() { }
|
||||
//~static_rational() { }
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if BOOST_UNITS_HAS_BOOST_TYPEOF
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::static_rational, (long)(long))
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
// prohibit zero denominator
|
||||
template<integer_type N> class static_rational<N,0>;
|
||||
|
||||
/// get decimal value of @c static_rational
|
||||
template<class T,integer_type N,integer_type D>
|
||||
inline typename divide_typeof_helper<T,T>::type
|
||||
value(const static_rational<N,D>&)
|
||||
{
|
||||
return T(N)/T(D);
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
|
||||
#ifndef BOOST_UNITS_DOXYGEN
|
||||
|
||||
namespace mpl {
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
|
||||
template<>
|
||||
struct plus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
::boost::mpl::plus<
|
||||
boost::mpl::times<typename T0::N_type, typename T1::D_type>,
|
||||
boost::mpl::times<typename T1::N_type, typename T0::D_type>
|
||||
>::value,
|
||||
::boost::mpl::times<typename T0::D_type, typename T1::D_type>::value
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct minus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
::boost::mpl::minus<
|
||||
boost::mpl::times<typename T0::N_type, typename T1::D_type>,
|
||||
boost::mpl::times<typename T1::N_type, typename T0::D_type>
|
||||
>::value,
|
||||
::boost::mpl::times<typename T0::D_type, typename T1::D_type>::value
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct times_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
::boost::mpl::times<typename T0::N_type, typename T1::N_type>::value,
|
||||
::boost::mpl::times<typename T0::D_type, typename T1::D_type>::value
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct divides_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
::boost::mpl::times<typename T0::N_type, typename T1::D_type>::value,
|
||||
::boost::mpl::times<typename T0::D_type, typename T1::N_type>::value
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct negate_impl<boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
::boost::mpl::negate<typename T0::N_type>::value,
|
||||
::boost::mpl::identity<T0>::type::Denominator
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct less_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef mpl::bool_<((mpl::minus<T0, T1>::type::Numerator) < 0)> type;
|
||||
};
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template<>
|
||||
struct plus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
T0::Numerator*T1::Denominator+T1::Numerator*T0::Denominator,
|
||||
T0::Denominator*T1::Denominator
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct minus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
T0::Numerator*T1::Denominator-T1::Numerator*T0::Denominator,
|
||||
T0::Denominator*T1::Denominator
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct times_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
T0::Numerator*T1::Numerator,
|
||||
T0::Denominator*T1::Denominator
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct divides_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<
|
||||
T0::Numerator*T1::Denominator,
|
||||
T0::Denominator*T1::Numerator
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct negate_impl<boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0>
|
||||
struct apply {
|
||||
typedef typename boost::units::static_rational<-T0::Numerator,T0::Denominator>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct less_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
|
||||
{
|
||||
template<class T0, class T1>
|
||||
struct apply
|
||||
{
|
||||
typedef mpl::bool_<((mpl::minus<T0, T1>::type::Numerator) < 0)> type;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_STATIC_RATIONAL_HPP
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user