Boost logo

Boost Users :

Subject: Re: [Boost-users] Dynamically creating new units
From: Brandon Olivares (programmer2188_at_[hidden])
Date: 2009-12-26 00:49:05


On 2009-12-25, OvermindDL1 wrote:
> On Fri, Dec 25, 2009 at 11:33 AM, Brandon Olivares
> <programmer2188_at_[hidden]> wrote:
>> On 2009-12-25, OvermindDL1 wrote:
>>> As for dynamically creating types, you can do that all you wish, but
>>> you have no type information then (unless you use variant or any or
>>> something, but that has needless overhead, well, maybe not variant).
>>> That is the point of Boost.Units, to enforce that you are doing things
>>> correctly, at compile time, it optimizes completely out at
> run-time.
>> OK thanks, perhaps you are right. I'm just really trying to figure out
>> a way to make compilation a bit faster. My concern is that since these
>> are in header files, well any source file that needs units will require
>> them all to be processed again, and that is really
> inconvenient.
>
> Yep, that is the major hazard of C++. If you learn how to structure
> things differently and use forward declarations and less class member
> functions (use external functions instead, ala C), that can speed up
> compilation tremendously.

OK, well perhaps there's another method. The primary bulk of the units I was defining were velocities. I just realized though that you can do l/t though, where l is some length and t is some time, and it doesn't have to define an existing unit.

But if I do that, I'm not sure what type to actually define the variable as.

sometype v = l/t;

What is the type in this case?

So for instance if l is light_year and t is hour, just as an example, I don't want to have to define light_year_per_hour as I was before. It's obvious that this is allowed:

quantity<astronomical::light_year_unit> l(3.0 * astronomical::light_years);
quantity<metric::hour_unit> t(8.0 * metric::hours);
quantity<?> v(l/t);

I think figuring that out will pretty much solve my issue.

I appreciate the discussion on pimpl though as I had never heard of it before, and it was interesting reading.

Thanks,
Brandon

> _______________________________________________ Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

--
Brandon
www.creatorspiritus.com
Blog and forum discussing living a Christ-centered life
Follow me on Twitter: http://twitter.com/devbanana

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net