WPILibC++ 2024.3.2
volume.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5// Copyright (c) 2016 Nic Holthaus
6//
7// The MIT License (MIT)
8//
9// Permission is hereby granted, free of charge, to any person obtaining a copy
10// of this software and associated documentation files (the "Software"), to deal
11// in the Software without restriction, including without limitation the rights
12// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13// copies of the Software, and to permit persons to whom the Software is
14// furnished to do so, subject to the following conditions:
15//
16// The above copyright notice and this permission notice shall be included in
17// all copies or substantial portions of the Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25// SOFTWARE.
26
27#pragma once
28
29#include "units/base.h"
30#include "units/length.h"
31
32namespace units {
33/**
34 * @namespace units::volume
35 * @brief namespace for unit types and containers representing volume values
36 * @details The SI unit for volume is `cubic_meters`, and the corresponding
37 * `base_unit` category is `volume_unit`.
38 * @anchor volumeContainers
39 * @sa See unit_t for more information on unit type containers.
40 */
41#if !defined(DISABLE_PREDEFINED_UNITS) || \
42 defined(ENABLE_PREDEFINED_VOLUME_UNITS)
43UNIT_ADD(volume, cubic_meter, cubic_meters, cu_m,
44 unit<std::ratio<1>, units::category::volume_unit>)
46 cubed<length::millimeter>)
47UNIT_ADD(volume, cubic_kilometer, cubic_kilometers, cu_km,
48 cubed<length::kilometer>)
50 cubed<deci<length::meter>>)
51UNIT_ADD(volume, cubic_inch, cubic_inches, cu_in, cubed<length::inches>)
52UNIT_ADD(volume, cubic_foot, cubic_feet, cu_ft, cubed<length::feet>)
53UNIT_ADD(volume, cubic_yard, cubic_yards, cu_yd, cubed<length::yards>)
54UNIT_ADD(volume, cubic_mile, cubic_miles, cu_mi, cubed<length::miles>)
55UNIT_ADD(volume, gallon, gallons, gal, unit<std::ratio<231>, cubic_inches>)
56UNIT_ADD(volume, quart, quarts, qt, unit<std::ratio<1, 4>, gallons>)
57UNIT_ADD(volume, pint, pints, pt, unit<std::ratio<1, 2>, quarts>)
58UNIT_ADD(volume, cup, cups, c, unit<std::ratio<1, 2>, pints>)
59UNIT_ADD(volume, fluid_ounce, fluid_ounces, fl_oz, unit<std::ratio<1, 8>, cups>)
60UNIT_ADD(volume, barrel, barrels, bl, unit<std::ratio<42>, gallons>)
61UNIT_ADD(volume, bushel, bushels, bu,
62 unit<std::ratio<215042, 100>, cubic_inches>)
63UNIT_ADD(volume, cord, cords, cord, unit<std::ratio<128>, cubic_feet>)
64UNIT_ADD(volume, cubic_fathom, cubic_fathoms, cu_fm, cubed<length::fathom>)
66 unit<std::ratio<1, 2>, fluid_ounces>)
67UNIT_ADD(volume, teaspoon, teaspoons, tsp, unit<std::ratio<1, 6>, fluid_ounces>)
68UNIT_ADD(volume, pinch, pinches, pinch, unit<std::ratio<1, 8>, teaspoons>)
69UNIT_ADD(volume, dash, dashes, dash, unit<std::ratio<1, 2>, pinches>)
70UNIT_ADD(volume, drop, drops, drop, unit<std::ratio<1, 360>, fluid_ounces>)
71UNIT_ADD(volume, fifth, fifths, fifth, unit<std::ratio<1, 5>, gallons>)
72UNIT_ADD(volume, dram, drams, dr, unit<std::ratio<1, 8>, fluid_ounces>)
73UNIT_ADD(volume, gill, gills, gi, unit<std::ratio<4>, fluid_ounces>)
74UNIT_ADD(volume, peck, pecks, pk, unit<std::ratio<1, 4>, bushels>)
75UNIT_ADD(volume, sack, sacks, sacks, unit<std::ratio<3>, bushels>)
76UNIT_ADD(volume, shot, shots, shots, unit<std::ratio<3, 2>, fluid_ounces>)
77UNIT_ADD(volume, strike, strikes, strikes, unit<std::ratio<2>, bushels>)
78
80#endif
81
82using namespace volume;
83} // namespace units
#define UNIT_ADD_CATEGORY_TRAIT(unitCategory)
Macro to create the is_category_unit type trait.
Definition: base.h:369
typename units::detail::prefix< std::deci, U >::type deci
Represents the type of class U with the metric 'deci' prefix appended.
Definition: base.h:1484
typename units::detail::cubed_impl< U >::type cubed
represents the type of class U cubed.
Definition: base.h:1195
Definition: array.h:89
static constexpr const velocity::meters_per_second_t c(299792458.0)
Speed of light in vacuum.
Unit Conversion Library namespace.
Definition: data.h:31
cubed< length::millimeter > L
Definition: volume.h:49
cu_mm
Definition: volume.h:45
UNIT_ADD_WITH_METRIC_PREFIXES(solid_angle, steradian, steradians, sr, unit< std::ratio< 1 >, units::category::solid_angle_unit >) UNIT_ADD(solid_angle
squared< angle::degrees > UNIT_ADD(solid_angle, spat, spats, sp, unit< std::ratio< 4 >, steradians, std::ratio< 1 > >) using namespace solid_angle
cubed< length::millimeter > cubed< deci< length::meter > > tbsp
Definition: volume.h:65
cubic_millimeters
Definition: volume.h:45
cubed< length::millimeter > liter
Definition: volume.h:49
cubic_millimeter
Definition: volume.h:45
cubed< length::millimeter > liters
Definition: volume.h:49
cubed< length::millimeter > cubed< deci< length::meter > > tablespoon
Definition: volume.h:65
cubed< length::millimeter > cubed< deci< length::meter > > tablespoons
Definition: volume.h:65
Class representing SI base unit types.
Definition: base.h:757
Type representing an arbitrary unit.
Definition: base.h:884