mirror of
https://github.com/nholthaus/units.git
synced 2026-01-14 00:19:27 +01:00
@@ -80,7 +80,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
add_compile_options(-Wall -Wextra -pedantic)
|
||||
endif()
|
||||
|
||||
# Remove IOStream from the library (useful for embdedded development)
|
||||
# Remove IOStream from the library (useful for embedded development)
|
||||
if(DISABLE_IOSTREAM)
|
||||
target_compile_definitions(${PROJECT_NAME} INTERFACE -DUNIT_LIB_DISABLE_IOSTREAM)
|
||||
endif(DISABLE_IOSTREAM)
|
||||
|
||||
@@ -189,7 +189,7 @@ auto speed = 60_mi / 1_hr; // 60 mph
|
||||
|
||||
***NOTE: Think carefully about using `auto` for return types.*** When you explicitly declare the return type, the compiler can check the dimensional analysis for correctness, and produce errors at compile time if you make a mistake. When using `auto`, you are basically saying that whatever unit the right-hand side of the expression results to is correct (even if it's not). If you are only using `auto` because a complex unit type is not available in the library, try [defining a new unit](#defining-new-units) as a better alternative.
|
||||
|
||||
More complex mathematical operations ([almost every `<cmath>` operation actually](http://nholthaus.github.io/units/namespaceunits_1_1math.html)), including exponentials and square roots are possibe by using the `units::math` namespace .
|
||||
More complex mathematical operations ([almost every `<cmath>` operation actually](http://nholthaus.github.io/units/namespaceunits_1_1math.html)), including exponentials and square roots are possible by using the `units::math` namespace .
|
||||
|
||||
```cpp
|
||||
using namespace units::math;
|
||||
@@ -684,7 +684,7 @@ If you know that you only need a subset of the unit namespaces for your applicat
|
||||
|
||||
The generic algorithm is
|
||||
1. disable the pre-defined units using `#define DISABLE_PREDEFINED_UNITS`
|
||||
2. opt-in to the namespaces you want using `#define ENABLE_PREDEFINED_<namepsace name>_UNITS`
|
||||
2. opt-in to the namespaces you want using `#define ENABLE_PREDEFINED_<namespace name>_UNITS`
|
||||
|
||||
Additionally, for `CMake` users, there are equivalently-named cmake options defined which will automatically include the preprocessor definitions in your project. Alternatively, you can use `add_definitions()` in your cmake file to set macros globally::
|
||||
|
||||
@@ -697,7 +697,7 @@ Additionally, for `CMake` users, there are equivalently-named cmake options defi
|
||||
)
|
||||
```
|
||||
|
||||
Be aware, some units depend on others. See the unit dependencies table bellow:
|
||||
Be aware, some units depend on others. See the unit dependencies table below:
|
||||
|
||||
| Unit | Dependencies |
|
||||
|:-----------------------:|:--------------------------------:|
|
||||
@@ -763,7 +763,7 @@ However, if you are already using CMake as your build system, the recommended wa
|
||||
target_link_libraries(${PROJECT_NAME} units)
|
||||
```
|
||||
|
||||
Also, if you are distributing headers that depends on units.h, you shoud consider using cmake's `find_package` to check if the header is installed on the user's system:
|
||||
Also, if you are distributing headers that depends on units.h, you should consider using cmake's `find_package` to check if the header is installed on the user's system:
|
||||
|
||||
```cmake
|
||||
find_package(units)
|
||||
|
||||
@@ -1377,7 +1377,7 @@ namespace units
|
||||
* error. This value should be chosen to be as high as possible before
|
||||
* integer overflow errors occur in the compiler.
|
||||
* @note USE WITH CAUTION. The is an approximate value. In general, squared<sqrt<meter>> != meter,
|
||||
* i.e. the operation is not reversible, and it will result in propogated approximations.
|
||||
* i.e. the operation is not reversible, and it will result in propagated approximations.
|
||||
* Use only when absolutely necessary.
|
||||
*/
|
||||
template<class U, std::intmax_t Eps = 10000000000>
|
||||
@@ -1756,7 +1756,7 @@ namespace units
|
||||
#ifdef FOR_DOXYGEN_PURPOSOES_ONLY
|
||||
/**
|
||||
* @ingroup TypeTraits
|
||||
* @brief Trait for accessing the publically defined types of `units::unit_t`
|
||||
* @brief Trait for accessing the publicly defined types of `units::unit_t`
|
||||
* @details The units library determines certain properties of the unit_t types passed to them
|
||||
* and what they represent by using the members of the corresponding unit_t_traits instantiation.
|
||||
*/
|
||||
@@ -1786,7 +1786,7 @@ namespace units
|
||||
|
||||
/**
|
||||
* @ingroup TypeTraits
|
||||
* @brief Trait for accessing the publically defined types of `units::unit_t`
|
||||
* @brief Trait for accessing the publicly defined types of `units::unit_t`
|
||||
* @details
|
||||
*/
|
||||
template<typename T>
|
||||
@@ -2956,7 +2956,7 @@ namespace units
|
||||
#ifdef FOR_DOXYGEN_PURPOSES_ONLY
|
||||
/**
|
||||
* @ingroup TypeTraits
|
||||
* @brief Trait for accessing the publically defined types of `units::unit_value_t_traits`
|
||||
* @brief Trait for accessing the publicly defined types of `units::unit_value_t_traits`
|
||||
* @details The units library determines certain properties of the `unit_value_t` types passed to
|
||||
* them and what they represent by using the members of the corresponding `unit_value_t_traits`
|
||||
* instantiation.
|
||||
@@ -2983,7 +2983,7 @@ namespace units
|
||||
|
||||
/**
|
||||
* @ingroup TypeTraits
|
||||
* @brief Trait for accessing the publically defined types of `units::unit_value_t_traits`
|
||||
* @brief Trait for accessing the publicly defined types of `units::unit_value_t_traits`
|
||||
* @details
|
||||
*/
|
||||
template<typename T>
|
||||
|
||||
@@ -1104,7 +1104,7 @@ TEST_F(UnitContainer, unitTypeMixedUnitMultiplication)
|
||||
square_meter_t d_m2 = b_ft * a_m;
|
||||
EXPECT_NEAR(1.0, d_m2(), 5.0e-5);
|
||||
|
||||
// a unit times a sclar ends up with the same units.
|
||||
// a unit times a scalar ends up with the same units.
|
||||
meter_t e_m = a_m * scalar_t(3.0);
|
||||
EXPECT_NEAR(3.0, e_m(), 5.0e-5);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user