47 Commits

Author SHA1 Message Date
Mateusz Pusz
cfc90f4aac refactor: 💥 basic_concepts, quantity and quantity_cast refactored
BREAKING CHANGE:  ScalableNumber renamed to QuantityValue

Resolves #107
2020-10-06 18:17:52 +02:00
Mateusz Pusz
c6a5d9e222 fix: broken requires expressions fixed 2020-09-23 16:38:40 +02:00
Mateusz Pusz
a098f97c08 feat: CTAD for dimensionless quantity added 2020-09-23 16:34:13 +02:00
Mateusz Pusz
d4d23847d8 refactor: DOWNCAST_MODE renamed to UNITS_DOWNCAST_MODE 2020-09-13 18:45:46 +02:00
Mateusz Pusz
2a56438f1c refactor: file tree with systems defninitions refactored to limit ODR issues
Relates to #32 as with this commit we created something like modules for derived quantities
2020-09-11 18:11:25 +02:00
Mateusz Pusz
79558a6d72 refactor: systems defined in terms of SI moved under si namespace 2020-09-10 17:14:33 +02:00
Mateusz Pusz
9cd0cb4105 feat: two argument explicit cast support added 2020-09-10 13:01:38 +02:00
Mateusz Pusz
58daacfd58 fix: unit tests fixed for DOWNCAST_MODE = OFF 2020-09-10 11:33:58 +02:00
Mateusz Pusz
c4aa67477c test: new dimensionless tests refactored to work with downcasting=OFF 2020-09-10 00:35:25 +02:00
Mateusz Pusz
e367afed71 Merge branch 'downcasting_2.0' 2020-09-09 20:31:03 +02:00
Mateusz Pusz
9527b39005 refactor: 💥 q_* UDL renamed to _q_*
We had some fun exploring the STD UDLs for potential collisions,
we have learnt our lesson and know how to proceed.
Now is high time to start behaving and obeying C++ rules.
2020-09-09 19:20:35 +02:00
Mateusz Pusz
2b408f19c0 Merge branch 'master' of github.com:mpusz/units 2020-09-09 11:22:58 +02:00
Mateusz Pusz
3e9d5ca189 refactor: ♻️ unitless renamed to one
Resolves #27
2020-09-09 11:20:55 +02:00
Johel Ernesto Guerrero Peña
749684c8ee style: fix name numbering 2020-09-09 08:53:53 +02:00
Johel Ernesto Guerrero Peña
ce583d40e0 style: name parameter after what's being tested 2020-09-09 08:53:53 +02:00
Johel Ernesto Guerrero Peña
2853a20c7f style: remove empty parameter list 2020-09-09 08:53:53 +02:00
Johel Ernesto Guerrero Peña
9a130d9b5b test: percent to unitless conversion 2020-09-09 08:53:53 +02:00
Johel Ernesto Guerrero Peña
c842115604 test: dimensionless common type 2020-09-09 08:53:53 +02:00
Mateusz Pusz
76b6c2972d test: more unit tests for dimensionless quantity 2020-09-08 18:45:14 +02:00
Mateusz Pusz
563b358d5e feat!: 💥 dimensionless quantities refactored
Dimensionless quantities are now represented by quantity types rather
than by plain representation types. Only dimensionless quantities with
`unitless` unit are implicitly convertible from representation types.

`units::exp()` now is a function doing std::exp() on a representation
type (previous `units::exp` class template was renamed to
`units::exponent`).

BREAKING_CHANGE: gcc-9.3 support removed
BREAKING_CHANGE: `exp` and `Exp` renamed to `exponent` and `Exponent`
Resolves #27
Resolves #42
2020-09-08 11:02:16 +02:00
Mateusz Pusz
77e11173bf Unit tests compilation fixed on VS 2020-09-06 15:35:08 +02:00
Johel Ernesto Guerrero Peña
71eda2fc66 test: codify comment in the correct place 2020-09-06 09:55:59 +02:00
Johel Ernesto Guerrero Peña
9f9397ffc2 test: convert comments to code 2020-09-06 09:55:59 +02:00
Mateusz Pusz
5c98924efb Downcasting reworked to allow OFF and AUTO modes 2020-08-19 13:37:57 +02:00
Mateusz Pusz
deb1ee6efa Truncating conversions disalowed for *=, /=, +=, amd -= operators (resolves #137) 2020-08-16 13:29:40 +02:00
Mateusz Pusz
9f94a73bba Custom is_same implementation added 2020-06-29 20:30:59 +02:00
Mateusz Pusz
d171f5451e NTTP ratio support added (resolves #49) 2020-06-27 19:15:46 +02:00
Mateusz Pusz
86b9177816 Specialize common_type to satisfy comparison concepts (resolves #113) 2020-05-28 20:19:05 +02:00
Mateusz Pusz
ce301748dd Velocity renamed to Speed (resolves #103) 2020-05-10 17:31:47 +02:00
Mateusz Pusz
7e935a4108 Physical units put in the physical namespace (I am sorry) 2020-05-08 22:39:24 +02:00
Mateusz Pusz
1830735544 Unit tests for alias_unit added 2020-05-08 21:18:16 +02:00
Mateusz Pusz
0a906450a2 Custom representation tests moved to a new file 2020-03-24 22:56:11 +01:00
Mateusz Pusz
6a5f25750d UDL naming refactored 2020-03-10 20:53:53 +01:00
Mateusz Pusz
0c89df3980 unknown_unit renamed to unknown_coherent_unit 2020-02-22 09:37:40 +01:00
Mateusz Pusz
18620044c5 All UDLs are now prefixed with q_ 2020-02-17 15:56:06 +01:00
Mateusz Pusz
a01c811f5f Square and cubic UDLs renamed 2020-01-09 10:03:41 +01:00
Oliver Schönrock
509b6c9653 implementing ratio<num,den,exp> which replaces ratio<num,den>
https://github.com/mpusz/units/issues/14

This "works", as in it passes all static and runtime tests.
However quite a few of the tests have been "modified" to make them pass. Whether
this is legitimate is debatable and should be the source of some thought /
discussion.

1. many of the static tests and some of the runtime tests have had the input
ratios of the tests modified in the following way. eg ratio<3,1000> =>
ratio<3,1,-3>. ie they have been "canonicalised".

There are obviously an infinite number of ratios which represent the same
rational number. The way `ratio` is implemented it always moves as "many powers
of 10" from the `num` and `den` into the `exp` and that makes the `canonical`
ratio.

Because these are all "types" and the lib uses is_same all over the place, only
exact matches will be `is_same`. ie ratio<300,4,0> !is_same ratio<3,4,2> (the
latter is the canonical ratio). This is perhaps fine for tests in the devlopment
phase, but there may be a need for "more forgiving" comparison / concept of
value equality. One such comparison which compares den,num,exp after
canonicalisation is the constexpr function `same` as defined at top of
`ratio_test.cpp`. We may need to expose this and perhaps add even more soft
comparisions.

2. In the runtime tests it is "subjective" how some resukts should be
printed. There is the question of "how exactly to format certain ratios". eg
omit denominators of "1" and exponents of "0". However before even addressing
these in detail a decision needs to be made about the general form of
"non-floating-point-converted" ratios which do not map exactly to a "Symbol
prefix".

Arguably these are "relatively ugly" whatever we do, so we could just
go for an easily canonicalised form. An example is:

-        CHECK(stream.str() == "10 [1/60]W");
+        CHECK(stream.str() == "10 [1/6 x 10⁻¹]W");

Which of thses is "better"? Is there a "third", better form?  It's not obvious.

My opnion is: Both of 1&2 are fine for now, unless we think they go down the
wrong avenue, and can be "perfected later"? ie we can expose a softer version of
ratio based equality, and decide on canonical way of printing ratios (as far as
that is actually a very useful output form, compared with decimal, scientific or
engineering notation).
2019-12-28 17:59:47 +01:00
Mateusz Pusz
6596c15238 scaled_unit template parameters order fixed (sorry Oliver) 2019-12-14 21:16:15 +01:00
Mateusz Pusz
b1b63e1b3a 2 parital specializations of a derived_dimension split to different types 2019-12-14 11:44:56 +01:00
Mateusz Pusz
156ab7ae7f Unknown dimension assert added to quantity_test 2019-12-12 15:39:04 +01:00
Mateusz Pusz
f31b26b5e5 Design cleanup
- unknown_unit added
- examples refactored
- base_type renamed to downcast_base_type
- scaled_unit renamed to named_scaled_unit
- detail::reference_unit renamed to scaled_unit
- quantity_test cleanup
2019-12-06 12:18:39 +01:00
Mateusz Pusz
c48bfe2098 quantity refactored and quantity_test enabled 2019-12-04 17:46:19 +01:00
Mateusz Pusz
b9dd6ab440 my_value compilation fixed 2019-11-16 18:29:56 +01:00
Mateusz Pusz
57e464cc99 quantity constraints refactored 2019-11-15 20:20:25 +01:00
Mateusz Pusz
2328a26992 Downcasting support added to quantity_cast (resolves #26) 2019-11-09 14:42:06 +00:00
Mateusz Pusz
367c7d5b6e my_value constructor refactored 2019-11-02 13:58:35 +01:00
Mateusz Pusz
3475f5193e Catch2 support added (resolves #8) 2019-10-14 10:53:02 +02:00