From 3b0e445b4cef5ca40064a1c42974678ce4d1a803 Mon Sep 17 00:00:00 2001 From: Andy Little Date: Fri, 10 Jan 2020 04:36:20 +0000 Subject: [PATCH] Remove sandbox.cpp from repo Examples/clcpp_response.cpp : removed debug #defines --- example/clcpp_response.cpp | 12 ++---- example/sandbox.cpp | 86 -------------------------------------- 2 files changed, 4 insertions(+), 94 deletions(-) delete mode 100644 example/sandbox.cpp diff --git a/example/clcpp_response.cpp b/example/clcpp_response.cpp index 857d4495..82c8d074 100644 --- a/example/clcpp_response.cpp +++ b/example/clcpp_response.cpp @@ -55,16 +55,16 @@ namespace { template using fathom = units::si::length; -#if 1 + template using fathom_us = units::si::length; -#endif + template using ft = units::si::length; -#if 1 + template using ft_us = units::si::length; -#endif + template using ly = units::si::length; @@ -174,13 +174,9 @@ void quantities_with_typed_units() std::cout << " = " << length::angstrom<>(meter) << '\n'; std::cout << " = " << length::ch<>(meter) << '\n'; std::cout << " = " << length::fathom<>(meter) << '\n'; -#if 1 std::cout << " = " << length::fathom_us<>(meter) << '\n'; -#endif std::cout << " = " << length::ft<>(meter) << '\n'; -#if 1 std::cout << " = " << length::ft_us<>(meter) << '\n'; -#endif std::cout << " = " << length::in<>(meter) << '\n'; std::cout << " = " << length::ly<>(meter) << '\n'; std::cout << " = " << length::mi<>(meter) << '\n'; diff --git a/example/sandbox.cpp b/example/sandbox.cpp deleted file mode 100644 index b24103ae..00000000 --- a/example/sandbox.cpp +++ /dev/null @@ -1,86 +0,0 @@ - -/* - Copyright (c) 2003-2020 Andy Little. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see http://www.gnu.org/licenses./ -*/ - - -#include - -/* - get conversion factor from one dimensionally-equivalent - quantity type to another -*/ - -namespace { - - - template < - units::Quantity Target, - units::Quantity Source - > - requires units::equivalent_dim - constexpr inline - std::common_type_t< - typename Target::rep, - typename Source::rep - > - conversion_factor() - { - // get quantities looking like inputs but with Q::rep that doesnt have narrowing conversion - typedef std::common_type_t< - typename Target::rep, - typename Source::rep - > rep; - typedef units::quantity source; - typedef units::quantity target; - return target{source{1}}.count(); - } - - auto units_str( units::Quantity const & q) - { - typedef std::remove_cvref_t qtype; - return units::detail::unit_text(); - } - -} - -namespace { - - namespace length{ - using m = units::si::length; - using mm = units::si::length; - } - -} - -#include - -using namespace units::si::literals; -int main() -{ - length::m constexpr plankA = 2.0m; - length::mm constexpr plankB = 1000.0mm; - - std::cout << "ratio plankA / plankB = " << plankA / plankB << '\n'; - - std::cout << "conversion factor to convert from vS in " << units_str(plankA) ; - std::cout << " to vT in " << units_str(plankB) << " : vT = vS * "; - std::cout << conversion_factor() << '\n'; - - // can be evaluated at compile time - static_assert(conversion_factor() == 1000,"error"); - -}