// The MIT License (MIT) // // Copyright (c) 2018 Mateusz Pusz // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #pragma once #include #include #include namespace units { struct length : derived_dimension> {}; template concept Length = QuantityOf; // SI units struct metre : named_coherent_derived_unit {}; struct millimetre : prefixed_derived_unit {}; struct centimetre : prefixed_derived_unit {}; struct kilometre : prefixed_derived_unit {}; inline namespace literals { // m constexpr auto operator""m(unsigned long long l) { return quantity(l); } constexpr auto operator""m(long double l) { return quantity(l); } // mm constexpr auto operator""mm(unsigned long long l) { return quantity(l); } constexpr auto operator""mm(long double l) { return quantity(l); } // cm constexpr auto operator""cm(unsigned long long l) { return quantity(l); } constexpr auto operator""cm(long double l) { return quantity(l); } // km constexpr auto operator""km(unsigned long long l) { return quantity(l); } constexpr auto operator""km(long double l) { return quantity(l); } } // namespace literals // US customary units struct yard : named_scaled_derived_unit> {}; struct foot : named_scaled_derived_unit, yard::ratio>> {}; struct inch : named_scaled_derived_unit, foot::ratio>> {}; struct mile : named_scaled_derived_unit, yard::ratio>> {}; inline namespace literals { // yd constexpr auto operator""yd(unsigned long long l) { return quantity(l); } constexpr auto operator""yd(long double l) { return quantity(l); } // ft constexpr auto operator""ft(unsigned long long l) { return quantity(l); } constexpr auto operator""ft(long double l) { return quantity(l); } // in constexpr auto operator""in(unsigned long long l) { return quantity(l); } constexpr auto operator""in(long double l) { return quantity(l); } // mi constexpr auto operator""mi(unsigned long long l) { return quantity(l); } constexpr auto operator""mi(long double l) { return quantity(l); } } // namespace literals } // namespace units