Skip to content

Commit

Permalink
Merge pull request #11 from 5150VEX/better-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Aang099 authored Jun 22, 2024
2 parents f901d64 + 850eeee commit 01e28f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions include/units/units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,27 @@ template <isQuantity Q> constexpr bool operator>(const Q& lhs, const Q& rhs) {
}

#define NEW_UNIT(Name, suffix, m, l, t, i, a, o, j, n) \
using Name = Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, std::ratio<o>, \
std::ratio<j>, std::ratio<n>>; \
class Name : public Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, \
std::ratio<o>, std::ratio<j>, std::ratio<n>> { \
public: \
explicit constexpr Name(double value) \
: Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, std::ratio<o>, \
std::ratio<j>, std::ratio<n>>(value) {} \
constexpr Name(Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, \
std::ratio<o>, std::ratio<j>, std::ratio<n>> \
value) \
: Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, std::ratio<o>, \
std::ratio<j>, std::ratio<n>>(value) {}; \
}; \
constexpr Name suffix = Name(1.0); \
constexpr Name operator""_##suffix(long double value) { return Name(static_cast<double>(value)); } \
constexpr Name operator""_##suffix(unsigned long long value) { return Name(static_cast<double>(value)); } \
constexpr Name operator""_##suffix(long double value) { \
return Name(Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, std::ratio<o>, \
std::ratio<j>, std::ratio<n>>(static_cast<double>(value))); \
} \
constexpr Name operator""_##suffix(unsigned long long value) { \
return Name(Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, std::ratio<o>, \
std::ratio<j>, std::ratio<n>>(static_cast<double>(value))); \
} \
inline std::ostream& operator<<(std::ostream& os, const Name& quantity) { \
os << quantity.internal() << "_" << #suffix; \
return os; \
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void initialize() {
pros::lcd::register_btn1_cb(on_center_button);
units::Vector2D<AngularAcceleration> a(1_rpm2, 2_rpm2);
Number num = Number(1.0);
num = 0.0;
num = Number(0.0);
a.theta().convert(deg);
to_cDeg(a.theta());

Expand Down

0 comments on commit 01e28f5

Please sign in to comment.