Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating new categories #233

Open
kunaltyagi opened this issue Sep 12, 2019 · 2 comments
Open

Creating new categories #233

kunaltyagi opened this issue Sep 12, 2019 · 2 comments

Comments

@kunaltyagi
Copy link

  1. Which version of units you are using
    master or 3 (doesn't matter)

Is there a way to create new base categories like length, temperature? Based on the inheritance diagram of unit<...> it doesn't seem so.

Essentially, I need to create a couple of non-dimensional units (with user defined conversions between them).

Right now, my functions look like

unitA convert(unitB);
std::tuple<Outunits...> convert(std::tuple<UnitD, Unit E>);  // only a few specializations exist

Can I adapt my usage to make better use of this library?

This is related weakly to the broader discussion in #83

@nholthaus
Copy link
Owner

nholthaus commented Sep 12, 2019 via email

@kunaltyagi
Copy link
Author

kunaltyagi commented Sep 13, 2019

In v3 you can specify your own base dimensions arbitrarily

Great. So just using myUnit = units::make_dimension<MyUnitTagStruct>; and with the tag struct requiring only 2 members? Seems awesome. I'll report back on my experiments with v3

Edit

Update

So, I've a system working, I don't know how well designed it is. I've copied some from the "show off thread". My system can be found at this gist. Would this be the correct place to ask for feedback?

Issues

  1. Converting from one basis to another via the convert functions. But there's no ctor which uses the convert function. Is it possible to add that (on the v3.x branch)? I can't think of a simple way to do that.
// My wish: to use the following syntax without using convert function
projections::spherical_projection::theta_t p = 1_x;  // compiler fails to find a conversion (ofc)
  1. Associating a dimension with my custom dimensions. Eg: using tan with my custom theta_t type which is obviously not an angle type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants