forked from mpusz/mp-units
fix: torque literal fixed + experimental_angle example refactored
This commit is contained in:
@@ -17,5 +17,6 @@ Examples
|
|||||||
examples/capacitor_time_curve
|
examples/capacitor_time_curve
|
||||||
examples/clcpp_response
|
examples/clcpp_response
|
||||||
examples/conversion_factor
|
examples/conversion_factor
|
||||||
|
examples/experimental_angle
|
||||||
examples/kalman_filter-alpha_beta_filter_example2
|
examples/kalman_filter-alpha_beta_filter_example2
|
||||||
examples/total_energy
|
examples/total_energy
|
||||||
|
7
docs/examples/experimental_angle.rst
Normal file
7
docs/examples/experimental_angle.rst
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
experimental_angle
|
||||||
|
==================
|
||||||
|
|
||||||
|
.. literalinclude:: ../../example/references/experimental_angle.cpp
|
||||||
|
:caption: experimental_angle.cpp
|
||||||
|
:start-at: #include
|
||||||
|
:linenos:
|
@@ -22,21 +22,17 @@
|
|||||||
|
|
||||||
#include <units/generic/angle.h>
|
#include <units/generic/angle.h>
|
||||||
#include <units/isq/si/energy.h>
|
#include <units/isq/si/energy.h>
|
||||||
#include <units/isq/si/force.h>
|
|
||||||
#include <units/isq/si/length.h>
|
|
||||||
#include <units/isq/si/torque.h>
|
#include <units/isq/si/torque.h>
|
||||||
#include <units/quantity_io.h>
|
#include <units/quantity_io.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
using namespace units::literals;
|
|
||||||
using namespace units::isq;
|
using namespace units::isq;
|
||||||
using namespace units::isq::si::literals;
|
using namespace units::isq::si::literals;
|
||||||
|
|
||||||
Torque auto torque = 20.0_q_Nm_per_rad;
|
const auto torque = 20.0_q_N_m_per_rad;
|
||||||
Energy auto energy = 20.0_q_J;
|
const auto energy = 20.0_q_J;
|
||||||
|
|
||||||
units::Angle auto angle = energy / torque;
|
units::Angle auto angle = energy / torque;
|
||||||
|
|
||||||
|
@@ -47,8 +47,8 @@ using torque = quantity<dim_torque, U, Rep>;
|
|||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
|
||||||
// Nm
|
// Nm
|
||||||
constexpr auto operator"" _q_Nm_per_rad(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return torque<newton_metre_per_radian, std::int64_t>(static_cast<std::int64_t>(l)); }
|
constexpr auto operator"" _q_N_m_per_rad(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return torque<newton_metre_per_radian, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||||
constexpr auto operator"" _q_Nm_per_rad(long double l) { return torque<newton_metre_per_radian, long double>(l); }
|
constexpr auto operator"" _q_N_m_per_rad(long double l) { return torque<newton_metre_per_radian, long double>(l); }
|
||||||
|
|
||||||
} // namespace literals
|
} // namespace literals
|
||||||
|
|
||||||
|
@@ -312,7 +312,7 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
|||||||
|
|
||||||
SECTION("torque")
|
SECTION("torque")
|
||||||
{
|
{
|
||||||
CHECK(fmt::format("{}", 1_q_Nm_per_rad) == "1 N ⋅ m/rad");
|
CHECK(fmt::format("{}", 1_q_N_m_per_rad) == "1 N ⋅ m/rad");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("storage_capacity")
|
SECTION("storage_capacity")
|
||||||
|
Reference in New Issue
Block a user