could use some help with an elementary example #696
Replies: 4 comments 5 replies
-
Sure! 😃 However, we need more info first. How do you want to model persons? Is it a dimensionless quantity? If so, then it means that a unit auto classroom = 30 * person;
classroom = 29 * one; If the above is incorrect, you should probably make the count of persons a distinct quantity with its own unit. If that is the case, you may model it with: #include <mp-units/core.h>
#include <iostream>
using namespace mp_units;
inline constexpr struct persons_count_dim final : base_dimension<"P"> {} persons_count_dim;
inline constexpr struct persons_count final : quantity_spec<persons_count_dim> {} persons_count;
inline constexpr struct person final : named_unit<"p", kind_of<persons_count>> {} person;
int main()
{
quantity classroom = 30 * person;
std::cout << classroom << "\n";
} https://godbolt.org/z/96jnaxcWP The above can be extended to define quantity types for counts of students and teachers to make them strong, not interconvertible types. |
Beta Was this translation helpful? Give feedback.
-
Interesting. The
Btw, since I don't use conan, I do |
Beta Was this translation helpful? Give feedback.
-
That is strange indeed, as it gets installed in our CI runs:
Could you please double-check that? |
Beta Was this translation helpful? Give feedback.
-
What about the proposed solution? Is it what you expected? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It looks like all your examples are for SI. Can you help me get this going:
Beta Was this translation helpful? Give feedback.
All reactions