Questions tagged [boost-units]
67 questions
17
votes
2 answers
std::chrono & Boost.Units
I'm working on a software design in which I'd like to leverage Boost.Units. Some of the units I'd like to use represent time, however, I'm inclined to use the C++11 std::chrono units for those since they're standard.
I'm wondering if there's any…

user1714423
- 191
- 5
14
votes
4 answers
Combining a linear algebra library with Boost::Units
I'm doing a good amount of scientific programming and made very good experiences with both Boost.Units, which provides compile-time dimensional analysis for quantities (i.e. tags quantities with units and thereby catches many errors with classical…

thiton
- 35,651
- 4
- 70
- 100
10
votes
1 answer
How to add your own base unit and conversions using boost::units
I am currently using boost::units to represent torque in si units, however I am given the torque in pound feet. I am attempting thus to create a pound_foot unit of torque and a conversion to support this. My lazy attempt was to simply…

Dean Povey
- 9,256
- 1
- 41
- 52
10
votes
2 answers
Converting units in boost.units from angular_velocity to degrees_per_second
I need to make a conversion from a general angular_velocity to degrees/second.
To illustrate this problem the example boostUnits.cpp:
#include
#include
#include…

Andrew Hundt
- 2,551
- 2
- 32
- 64
7
votes
2 answers
Physical Boost.Units User Defined Literals
Now that we soon have user defined literals (UDL), in GCC 4.7 for example, I'm eagerly waiting for (physical) unit libraries (such as Boost.Units) using them to ease expression of literals such as 1+3i, 3m, 3meter or 13_meter. Has anybody written an…

Nordlöw
- 11,838
- 10
- 52
- 99
7
votes
3 answers
Millimeters in boost::units
I want to use boost::units for some SI metrics. However our code mostly deals with millimeters and instead of using
quantity value = 1*milli*meter;
we would prefer something like
quantity value = 1*millimeter;
However I am not…

Frankie
- 653
- 1
- 9
- 20
6
votes
3 answers
Casting boost::units::quantity to double
I need to pass the value of a quantity to a library for evaluation. The boost units library takes double values in SI, so the boost units library is very appealing in ensuring that requirement. However, how should I cast the quantity to a double…

ccook
- 5,869
- 6
- 56
- 81
6
votes
2 answers
Is there a reason not to use unit enforcing types?
Conceptually it seems to me that using unit enforcing based types (Meters, Seconds, Kilograms) would have massive benefits (extra checking in passing args, getting rid of unit names in vars, etc) and yet I've not run into as much code which does.…

Catskul
- 17,916
- 15
- 84
- 113
6
votes
1 answer
Creating user-defined conversions
I'm trying to create units for meter and kilometer. I want then to sum and convert them accordingly. I know that the boost::units library has already SI system, but I want create all from scratch, because then I need to create my own systems for my…

Jepessen
- 11,744
- 14
- 82
- 149
5
votes
1 answer
Boost::units::quantity "incomplete type" error
I am trying to use boost::units in a project but am running into trouble.
I have a template class which has some quantity objects as members. In one I wish to store a value with dimensions of pressure so I have quantity press; declared as…

Dan
- 12,857
- 7
- 40
- 57
4
votes
1 answer
How can I use Boost Test with Boost Units
I expected this to compile properly:
#include
#include
#include
using boost::units::quantity;
using boost::units::degree::degrees;
using…

sbabbi
- 11,070
- 2
- 29
- 57
4
votes
1 answer
How does Boost.Units come up with this imprecise result of conversion?
Consider the following code:
#include
#include
#include
#include
#include
#include
int main()
{
using namespace…

Ruslan
- 18,162
- 8
- 67
- 136
4
votes
1 answer
Why would a template class have an unused type?
I'm reviewing the boost units library and I am puzzled why the boost::units::unit class has an extra template parameter. Here is the example:
http://www.boost.org/doc/libs/1_57_0/boost/units/unit.hpp
template

Raymond Valdes
- 1,161
- 1
- 9
- 15
3
votes
2 answers
Is boost odeint supporting dimensional analysis via Boost.Units?
I was trying to implement a simple ode to test whether boost.odeint is supporting the usage of boost.units. However my example is failing at compilation. Is it my code, or doesn't boost.odeint support boost.Units for dimensional…

Mojomoko
- 471
- 5
- 12
3
votes
0 answers
Determine conversion factors of strings describing units
In one of my project I need to determine the conversion factors of fairly complex units. I was able to write a static conversion function in case of statically defined units using the excellent boost library Boost.Units.
In my case the user enters…

Aleph0
- 5,816
- 4
- 29
- 80