From 9b19dcf193352603c6b631fe2d04eae9f01e7191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Thu, 24 Mar 2022 16:57:12 -0400 Subject: [PATCH 01/50] refactor(bits): remove unused header in prime.h --- src/core/include/units/bits/prime.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/include/units/bits/prime.h b/src/core/include/units/bits/prime.h index 49b74a10..f6aa9e48 100644 --- a/src/core/include/units/bits/prime.h +++ b/src/core/include/units/bits/prime.h @@ -24,7 +24,6 @@ #include #include -#include #include #include #include From fbe2e686eb7c44df04f1ed2dc8ac70c840b4b673 Mon Sep 17 00:00:00 2001 From: Markus Hofbauer Date: Tue, 22 Mar 2022 18:34:05 +0100 Subject: [PATCH 02/50] check: enable cmake-format in pre-commit --- .pre-commit-config.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 682b1f66..7a10eda4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,10 +10,11 @@ repos: # rev: v1.3.5 # hooks: # - id: clang-format - # - repo: https://github.com/cheshirekow/cmake-format-precommit - # rev: v0.6.13 - # hooks: - # - id: cmake-format - # additional_dependencies: ["cmakelang"] - # - id: cmake-lint - # additional_dependencies: ["cmakelang"] + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.13 + hooks: + - id: cmake-format + additional_dependencies: ["cmakelang"] + # - id: cmake-lint + # additional_dependencies: ["cmakelang"] + # exclude: "cmake/.*" From 4c9ada5f932d7c660ad047bc23901e13944e7fa7 Mon Sep 17 00:00:00 2001 From: Markus Hofbauer Date: Sun, 27 Mar 2022 16:06:18 +0200 Subject: [PATCH 03/50] check: use cmake format config file --- .cmake-format.yaml | 41 +++++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .cmake-format.yaml diff --git a/.cmake-format.yaml b/.cmake-format.yaml new file mode 100644 index 00000000..45da65a4 --- /dev/null +++ b/.cmake-format.yaml @@ -0,0 +1,41 @@ +parse: + additional_commands: + add_documentation: + pargs: + nargs: 1 + flags: + - ALL + kwargs: + BREATHE_PROJECT: 1 + CODE_SOURCE_DIR: 1 + INSTALL_DIR: 1 + CODE_DEPENDS: 1 + DOCS_DEPENDS: 1 + enable_iwyu: + pargs: + flags: + - NO_FORWARD_DECLARATIONS + - QUOTED_INCLUDES_FIRST + - NO_COMMENTS + kwargs: + MAPPING_FILE: 1 + MAX_LINE_LENGTH: 1 + metabench_add_chart: + pargs: + nargs: 1 + kwargs: + TITLE: 1 + SUBTITLE: 1 + DATASETS: + +format: + line_width: 120 + tab_size: 4 + max_subgroups_hwrap: 3 + max_pargs_hwrap: 6 + max_rows_cmdline: 2 + dangle_parens: true + min_prefix_chars: 8 + max_prefix_chars: 8 + max_lines_hwrap: 2 +markup: + enable_markup: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a10eda4..90919c87 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: rev: v0.6.13 hooks: - id: cmake-format - additional_dependencies: ["cmakelang"] + additional_dependencies: ["cmakelang[YAML]"] # - id: cmake-lint # additional_dependencies: ["cmakelang"] # exclude: "cmake/.*" From cf7a7ed17a73ed08154aae93696a5a94ed5e43c6 Mon Sep 17 00:00:00 2001 From: Markus Hofbauer Date: Sat, 2 Apr 2022 18:58:23 +0200 Subject: [PATCH 04/50] check: run pre-commit on all files --- CMakeLists.txt | 7 +- cmake/FindSphinx.cmake | 8 +- cmake/ccache.cmake | 23 +- cmake/documentation.cmake | 31 +- cmake/include-what-you-use.cmake | 16 +- cmake/metabench.cmake | 833 ++++++++++--------- cmake/modern_project_structure.cmake | 12 +- cmake/warnings.cmake | 4 +- docs/CMakeLists.txt | 42 +- example/aliases/CMakeLists.txt | 22 +- example/glide_computer/CMakeLists.txt | 10 +- example/kalman_filter/CMakeLists.txt | 5 +- example/literals/CMakeLists.txt | 22 +- example/references/CMakeLists.txt | 22 +- src/CMakeLists.txt | 19 +- src/cmake/AddUnitsModule.cmake | 6 +- src/core-fmt/CMakeLists.txt | 4 +- src/core/CMakeLists.txt | 19 +- src/systems/CMakeLists.txt | 28 +- test/metabench/CMakeLists.txt | 11 +- test/metabench/list/CMakeLists.txt | 52 +- test/metabench/make_dimension/CMakeLists.txt | 17 +- test/metabench/ratio/CMakeLists.txt | 71 +- test/unit_test/runtime/CMakeLists.txt | 19 +- test/unit_test/static/CMakeLists.txt | 30 +- test_package/CMakeLists.txt | 4 +- 26 files changed, 652 insertions(+), 685 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21bf11b0..e3626289 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,7 @@ # SOFTWARE. cmake_minimum_required(VERSION 3.15) -project(mp-units-dev - LANGUAGES CXX -) +project(mp-units-dev LANGUAGES CXX) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -50,8 +48,7 @@ if(${projectPrefix}IWYU) include(include-what-you-use) enable_iwyu( MAPPING_FILE "${PROJECT_SOURCE_DIR}/.mp-units.imp" - NO_FORWARD_DECLARATIONS - QUOTED_INCLUDES_FIRST + NO_FORWARD_DECLARATIONS QUOTED_INCLUDES_FIRST MAX_LINE_LENGTH 120 NO_COMMENTS ) diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake index 7b1504ab..a7d4382d 100644 --- a/cmake/FindSphinx.cmake +++ b/cmake/FindSphinx.cmake @@ -1,11 +1,7 @@ # Look for an executable called sphinx-build -find_program(SPHINX_EXECUTABLE - NAMES sphinx-build - DOC "Path to sphinx-build executable") +find_program(SPHINX_EXECUTABLE NAMES sphinx-build DOC "Path to sphinx-build executable") include(FindPackageHandleStandardArgs) # Handle standard arguments to find_package like REQUIRED and QUIET -find_package_handle_standard_args(Sphinx - "Failed to find sphinx-build executable" - SPHINX_EXECUTABLE) +find_package_handle_standard_args(Sphinx "Failed to find sphinx-build executable" SPHINX_EXECUTABLE) diff --git a/cmake/ccache.cmake b/cmake/ccache.cmake index 396b52df..f14ec3c0 100644 --- a/cmake/ccache.cmake +++ b/cmake/ccache.cmake @@ -134,7 +134,7 @@ function(enable_ccache) endif() if("${_ccache_version}" VERSION_LESS 3.3.0) - list(APPEND _ccacheEnv CCACHE_CPP2=1) # avoids spurious warnings with some compilers for ccache older than 3.3 + list(APPEND _ccacheEnv CCACHE_CPP2=1) # avoids spurious warnings with some compilers for ccache older than 3.3 endif() if(_enable_ccache_MODE STREQUAL DIRECT_DEPEND) @@ -188,25 +188,18 @@ function(enable_ccache) if(CMAKE_GENERATOR MATCHES "Ninja|Makefiles") foreach(_lang IN ITEMS C CXX OBJC OBJCXX CUDA) - set(CMAKE_${_lang}_COMPILER_LAUNCHER - ${CMAKE_COMMAND} -E env - ${_ccacheEnv} ${CCACHE_PATH} - PARENT_SCOPE - ) + set(CMAKE_${_lang}_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env ${_ccacheEnv} ${CCACHE_PATH} PARENT_SCOPE) endforeach() elseif(CMAKE_GENERATOR STREQUAL Xcode) # Each of the Xcode project variables allow specifying only a single value, but the ccache command line needs to have multiple options. # A separate launch script needs to be written out and the project variables pointed at them. foreach(_lang IN ITEMS C CXX) - set(launch${_lang} ${CMAKE_BINARY_DIR}/launch-${_lang}) - file(WRITE ${launch${_lang}} "#!/bin/bash\n\n") - foreach(keyVal IN LISTS _ccacheEnv) - file(APPEND ${launch${_lang}} "export ${keyVal}\n") - endforeach() - file(APPEND ${launch${_lang}} - "exec \"${CCACHE_PROGRAM}\" " - "\"${CMAKE_${_lang}_COMPILER}\" \"$@\"\n" - ) + set(launch${_lang} ${CMAKE_BINARY_DIR}/launch-${_lang}) + file(WRITE ${launch${_lang}} "#!/bin/bash\n\n") + foreach(keyVal IN LISTS _ccacheEnv) + file(APPEND ${launch${_lang}} "export ${keyVal}\n") + endforeach() + file(APPEND ${launch${_lang}} "exec \"${CCACHE_PROGRAM}\" " "\"${CMAKE_${_lang}_COMPILER}\" \"$@\"\n") execute_process(COMMAND chmod a+rx ${launch${_lang}}) endforeach() set(CMAKE_XCODE_ATTRIBUTE_CC ${launchC} PARENT_SCOPE) diff --git a/cmake/documentation.cmake b/cmake/documentation.cmake index d3cbf585..3e6b239d 100644 --- a/cmake/documentation.cmake +++ b/cmake/documentation.cmake @@ -22,7 +22,8 @@ cmake_minimum_required(VERSION 3.5) -find_package(Doxygen MODULE REQUIRED) # TODO Switch to CONFIG when Conan will start supporting imported executables in CMakeDeps +find_package(Doxygen MODULE REQUIRED +)# TODO Switch to CONFIG when Conan will start supporting imported executables in CMakeDeps find_package(Sphinx REQUIRED) # @@ -80,16 +81,14 @@ function(add_documentation targetName) set(_doxygenIndexFile "${DOXYGEN_OUTPUT_DIR}/xml/index.xml") # Only regenerate Doxygen when the Doxyfile or given dependencies change - add_custom_command(OUTPUT "${_doxygenIndexFile}" + add_custom_command( + OUTPUT "${_doxygenIndexFile}" COMMAND ${CMAKE_COMMAND} -E make_directory ${DOXYGEN_OUTPUT_DIR} COMMAND Doxygen::doxygen ARGS "${_doxyfile}" MAIN_DEPENDENCY "${_doxyfileIn}" - DEPENDS - "${_doxyfile}" - "${_args_CODE_DEPENDS}" + DEPENDS "${_doxyfile}" "${_args_CODE_DEPENDS}" COMMENT "Generating doxygen XML metadata" - USES_TERMINAL - VERBATIM + USES_TERMINAL VERBATIM ) set(_sphinx_docs_dir "${CMAKE_CURRENT_BINARY_DIR}/sphinx") @@ -99,16 +98,16 @@ function(add_documentation targetName) # - Doxygen has rerun # - Our doc files have been updated # - The Sphinx config has been updated - add_custom_command(OUTPUT "${_sphinx_index_file}" - COMMAND "${SPHINX_EXECUTABLE}" ARGS -b html -j auto "-Dbreathe_projects.${_args_BREATHE_PROJECT}=${DOXYGEN_OUTPUT_DIR}/xml" "${_args_DOCS_SOURCE_DIR}" "${_sphinx_docs_dir}" + add_custom_command( + OUTPUT "${_sphinx_index_file}" + COMMAND "${SPHINX_EXECUTABLE}" ARGS -b html -j auto + "-Dbreathe_projects.${_args_BREATHE_PROJECT}=${DOXYGEN_OUTPUT_DIR}/xml" "${_args_DOCS_SOURCE_DIR}" + "${_sphinx_docs_dir}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" MAIN_DEPENDENCY "${_args_DOCS_SOURCE_DIR}/conf.py" - DEPENDS - "${_doxygenIndexFile}" - "${_args_DOCS_DEPENDS}" + DEPENDS "${_doxygenIndexFile}" "${_args_DOCS_DEPENDS}" COMMENT "Generating documentation with Sphinx" - USES_TERMINAL - VERBATIM + USES_TERMINAL VERBATIM ) # Custom target @@ -118,7 +117,7 @@ function(add_documentation targetName) add_custom_target(${targetName} ${_all} DEPENDS "${_sphinx_index_file}") if(_args_INSTALL_DIR) - # Add an install step to install the docs - install(DIRECTORY ${_sphinx_docs_dir} TYPE DOC) + # Add an install step to install the docs + install(DIRECTORY ${_sphinx_docs_dir} TYPE DOC) endif() endfunction() diff --git a/cmake/include-what-you-use.cmake b/cmake/include-what-you-use.cmake index 41853ae6..53556e7a 100644 --- a/cmake/include-what-you-use.cmake +++ b/cmake/include-what-you-use.cmake @@ -48,7 +48,17 @@ macro(_enable_iwyu_failed log_postfix) endmacro() macro(_process_iwyu_arguments offset log_postfix) - set(_options QUIET REQUIRED NO_DEFAULT_MAPPINGS PCH_IN_CODE TRANSITIVE_INCLUDES_ONLY NO_COMMENTS NO_FORWARD_DECLARATIONS CXX17_NAMESPACES QUOTED_INCLUDES_FIRST) + set(_options + QUIET + REQUIRED + NO_DEFAULT_MAPPINGS + PCH_IN_CODE + TRANSITIVE_INCLUDES_ONLY + NO_COMMENTS + NO_FORWARD_DECLARATIONS + CXX17_NAMESPACES + QUOTED_INCLUDES_FIRST + ) set(_one_value_args PROGRAM MAPPING_FILE MAX_LINE_LENGTH) set(_multi_value_args KEEP) cmake_parse_arguments(PARSE_ARGV ${offset} _enable_iwyu "${_options}" "${_one_value_args}" "${_multi_value_args}") @@ -160,7 +170,5 @@ endfunction() # function(enable_target_iwyu target) _process_iwyu_arguments(1 " for '${target}'") - set_target_properties(${target} PROPERTIES - CXX_INCLUDE_WHAT_YOU_USE "${_iwyu_path};${_iwyu_args}" - ) + set_target_properties(${target} PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "${_iwyu_path};${_iwyu_args}") endfunction() diff --git a/cmake/metabench.cmake b/cmake/metabench.cmake index 4f183ff3..0b4002d9 100644 --- a/cmake/metabench.cmake +++ b/cmake/metabench.cmake @@ -20,7 +20,6 @@ endif() # avoid polluting the build tree. set(METABENCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/_metabench") - # metabench_add_dataset(target path_to_template range # [NAME name] # [ENV env] @@ -124,41 +123,40 @@ function(metabench_add_dataset target path_to_template range) set(multi_value_args) cmake_parse_arguments(ARGS "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) - if (NOT IS_ABSOLUTE "${path_to_template}") + if(NOT IS_ABSOLUTE "${path_to_template}") set(path_to_template "${CMAKE_CURRENT_SOURCE_DIR}/${path_to_template}") endif() - if (NOT EXISTS ${path_to_template}) + if(NOT EXISTS ${path_to_template}) message(FATAL_ERROR "The file specified to metabench_add_dataset (${path_to_template}) does not exist.") endif() - if (NOT ARGS_NAME) + if(NOT ARGS_NAME) set(ARGS_NAME ${target}) endif() - if (NOT ARGS_ENV) + if(NOT ARGS_ENV) set(ARGS_ENV "{}") endif() - if (NOT ARGS_COLOR) + if(NOT ARGS_COLOR) set(ARGS_COLOR "") endif() - if (NOT ARGS_SCALE) + if(NOT ARGS_SCALE) set(ARGS_SCALE 1.0) endif() - if (NOT ARGS_MEDIAN_OF) + if(NOT ARGS_MEDIAN_OF) set(ARGS_MEDIAN_OF 1) endif() - if (NOT ARGS_OUTPUT) + if(NOT ARGS_OUTPUT) set(ARGS_OUTPUT "${target}.json") endif() if(NOT IS_ABSOLUTE "${ARGS_OUTPUT}") set(ARGS_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_OUTPUT}") endif() - # Add a dummy executable that will be used to collect the dataset. # We'll build this executable multiple times for different values # of `n`, and collect compilation statistics each time. Compiling @@ -169,46 +167,42 @@ function(metabench_add_dataset target path_to_template range) # so we store it in a custom property. file(WRITE "${METABENCH_DIR}/${target}.cpp" "") add_executable(${target} EXCLUDE_FROM_ALL "${METABENCH_DIR}/${target}.cpp") - set_target_properties(${target} PROPERTIES - RULE_LAUNCH_COMPILE "${RUBY_EXECUTABLE} -- \"${COMPILE_RB_PATH}\"" - RULE_LAUNCH_LINK "${RUBY_EXECUTABLE} -- \"${LINK_RB_PATH}\"" - RUNTIME_OUTPUT_DIRECTORY "${METABENCH_DIR}" - RUNTIME_OUTPUT_DIRECTORY_RELEASE "${METABENCH_DIR}" - RUNTIME_OUTPUT_DIRECTORY_DEBUG "${METABENCH_DIR}" - RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${METABENCH_DIR}" - RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${METABENCH_DIR}" - METABENCH_DATASET_PATH "${ARGS_OUTPUT}" + set_target_properties( + ${target} + PROPERTIES + RULE_LAUNCH_COMPILE "${RUBY_EXECUTABLE} -- \"${COMPILE_RB_PATH}\"" + RULE_LAUNCH_LINK "${RUBY_EXECUTABLE} -- \"${LINK_RB_PATH}\"" + RUNTIME_OUTPUT_DIRECTORY "${METABENCH_DIR}" + RUNTIME_OUTPUT_DIRECTORY_RELEASE "${METABENCH_DIR}" + RUNTIME_OUTPUT_DIRECTORY_DEBUG "${METABENCH_DIR}" + RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${METABENCH_DIR}" + RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${METABENCH_DIR}" + METABENCH_DATASET_PATH "${ARGS_OUTPUT}" ) get_filename_component(template_dir "${path_to_template}" DIRECTORY) target_include_directories(${target} PUBLIC "${template_dir}") # Add a command to generate the JSON file that will contain the measurements # we collect for this dataset when we build the executable above. - add_custom_command(OUTPUT "${ARGS_OUTPUT}" - COMMAND "${RUBY_EXECUTABLE}" -r json -r fileutils -r "${METABENCH_RB_PATH}" - -e "range = (${range}).to_a" - -e "env = (${ARGS_ENV})" - -e "data = {}" - -e "data['key'] = '${ARGS_NAME}'" - -e "data['scale'] = (${ARGS_SCALE})" - -e "data['color'] = '${ARGS_COLOR}'" - -e "data['values'] = measure('${target}', '${path_to_template}', range, env, ${ARGS_MEDIAN_OF})" - -e "FileUtils.mkdir_p(File.dirname('${ARGS_OUTPUT}'))" - -e "IO.write('${ARGS_OUTPUT}', JSON.generate(data))" + add_custom_command( + OUTPUT "${ARGS_OUTPUT}" + COMMAND "${RUBY_EXECUTABLE}" -r json -r fileutils -r "${METABENCH_RB_PATH}" -e "range = (${range}).to_a" -e + "env = (${ARGS_ENV})" -e "data = {}" -e "data['key'] = '${ARGS_NAME}'" -e + "data['scale'] = (${ARGS_SCALE})" -e "data['color'] = '${ARGS_COLOR}'" -e + "data['values'] = measure('${target}', '${path_to_template}', range, env, ${ARGS_MEDIAN_OF})" -e + "FileUtils.mkdir_p(File.dirname('${ARGS_OUTPUT}'))" -e "IO.write('${ARGS_OUTPUT}', JSON.generate(data))" DEPENDS "${path_to_template}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" VERBATIM USES_TERMINAL ) - # We also setup a CTest target to test the generation of the dataset. # We do not actually collect any data here. - add_test(NAME ${target} - COMMAND "${RUBY_EXECUTABLE}" -r "${METABENCH_RB_PATH}" - -e "range = (${range}).to_a" - -e "range = [range[0], range[-1]] if range.length >= 2" - -e "env = (${ARGS_ENV})" - -e "data = measure('${target}', '${path_to_template}', range, env, 1)" + add_test( + NAME ${target} + COMMAND "${RUBY_EXECUTABLE}" -r "${METABENCH_RB_PATH}" -e "range = (${range}).to_a" -e + "range = [range[0], range[-1]] if range.length >= 2" -e "env = (${ARGS_ENV})" -e + "data = measure('${target}', '${path_to_template}', range, env, 1)" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) endfunction() @@ -276,7 +270,7 @@ function(metabench_add_chart target) set(multi_value_args DATASETS) cmake_parse_arguments(ARGS "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) - if (NOT ARGS_ASPECT) + if(NOT ARGS_ASPECT) set(ARGS_ASPECT "COMPILATION_TIME") endif() @@ -284,7 +278,7 @@ function(metabench_add_chart target) message(FATAL_ERROR "metabench_add_chart requires at least one dataset.") endif() - if (NOT ARGS_OUTPUT) + if(NOT ARGS_OUTPUT) set(ARGS_OUTPUT "${target}.html") endif() @@ -300,22 +294,17 @@ function(metabench_add_chart target) add_custom_command( OUTPUT "${ARGS_OUTPUT}" - COMMAND "${RUBY_EXECUTABLE}" -r erb -r json -r fileutils - -e "options = {}" - -e "options['TITLE'] = '${ARGS_TITLE}'" - -e "options['SUBTITLE'] = '${ARGS_SUBTITLE}'" - -e "options['XLABEL'] = '${ARGS_XLABEL}'" - -e "options['YLABEL'] = '${ARGS_YLABEL}'" - -e "aspect = '${ARGS_ASPECT}'" - -e "data = '${data}'.split(';').map { |datum| JSON.parse(IO.read(datum)) }" - -e "html = ERB.new(File.read('${CHART_HTML_ERB_PATH}')).result(binding)" - -e "FileUtils.mkdir_p(File.dirname('${ARGS_OUTPUT}'))" - -e "IO.write('${ARGS_OUTPUT}', html)" + COMMAND "${RUBY_EXECUTABLE}" -r erb -r json -r fileutils -e "options = {}" -e + "options['TITLE'] = '${ARGS_TITLE}'" -e "options['SUBTITLE'] = '${ARGS_SUBTITLE}'" -e + "options['XLABEL'] = '${ARGS_XLABEL}'" -e "options['YLABEL'] = '${ARGS_YLABEL}'" -e + "aspect = '${ARGS_ASPECT}'" -e "data = '${data}'.split(';').map { |datum| JSON.parse(IO.read(datum)) }" + -e "html = ERB.new(File.read('${CHART_HTML_ERB_PATH}')).result(binding)" -e + "FileUtils.mkdir_p(File.dirname('${ARGS_OUTPUT}'))" -e "IO.write('${ARGS_OUTPUT}', html)" DEPENDS ${data} "${ARGS_CHART}" VERBATIM ) - if (${ARGS_ALL}) + if(${ARGS_ALL}) add_custom_target(${target} ALL DEPENDS "${ARGS_OUTPUT}") else() add_custom_target(${target} DEPENDS "${ARGS_OUTPUT}") @@ -338,109 +327,109 @@ endfunction() ################################################################################ set(METABENCH_RB_PATH "${METABENCH_DIR}/metabench.rb") file(WRITE "${METABENCH_RB_PATH}" -"require 'benchmark' \n" -"require 'erb' \n" -"require 'fileutils' \n" -"require 'open3' \n" -"require 'pathname' \n" -"require 'time' \n" -" \n" -" \n" -"def report_error(command_line, stdout, stderr, code) \n" -" raise [%{\\ncommand line: #{command_line}}, \n" -" %{stdout\\n#{'-'*80}\\n#{stdout}}, \n" -" %{stderr\\n#{'-'*80}\\n#{stderr}}, \n" -" %{code\\n#{'-'*80}\\n#{code}}].join(%{\\n\\n}) \n" -"end \n" -" \n" -"# Build the specified CMake target and return the measurements that were taken. \n" -"# The exact format of a measurement returned by this function is explained \n" -"# in the JavaScript code that loads it, in the chart template file below. \n" -"def build(target) \n" -" command = ['${CMAKE_COMMAND}', '--build', '${CMAKE_BINARY_DIR}', '--target', target] \n" -" exe_file = %{${METABENCH_DIR}/#{target}${CMAKE_EXECUTABLE_SUFFIX}} \n" -" cpp_file = %{${METABENCH_DIR}/#{target}.cpp} \n" -" \n" -" # We change the timestamp of the source file and remove the executable \n" -" # to make sure CMake considers the target as outdated; otherwise, we \n" -" # might skip the compilation and/or link steps. This is because CMake's \n" -" # timestamps are not precise enough. \n" -" FileUtils.touch(cpp_file, mtime: Time.now+1) \n" -" File.delete(exe_file) if File.exist?(exe_file) \n" -" \n" -" stdout, stderr, status = Open3.capture3(*command) \n" -" compile_cli = stdout.match(/\\[compilation command: (.+)\\]/i) \n" -" compile_cli = compile_cli ? compile_cli.captures[0] : '(unavailable)' \n" -" link_cli = stdout.match(/\\[link command: (.+)\\]/i) \n" -" link_cli = link_cli ? link_cli.captures[0] : '(unavailable)' \n" -" \n" -" if not status.success? \n" -" cli = %{compile: #{compile_cli}\\nlink: #{link_cli}} \n" -" report_error(cli, stdout, stderr, IO.read(cpp_file)) \n" -" end \n" -" \n" -" result = {} \n" -" \n" -" # Compilation and link times in seconds. They are output to stdout because \n" -" # we use the `compile.rb` and `link.rb` scripts below to launch the compiler \n" -" # and linker with CMake. \n" -" result['COMPILATION_TIME'] = stdout.match(/\\[COMPILATION_TIME: (.+)\\]/i).captures[0].to_f \n" -" result['LINK_TIME'] = stdout.match(/\\[LINK_TIME: (.+)\\]/i).captures[0].to_f \n" -" \n" -" # Peak memory usage \n" -" result['PEAK_MEMORY'] = stdout.match(/\\[PEAK_MEMORY: (.+)\\]/i).captures[0].to_f \n" -" \n" -" # Size of the generated executable in KB \n" -" result['EXECUTABLE_SIZE'] = File.size(exe_file).to_f / 1000 \n" -" \n" -" return result \n" -"end \n" -" \n" -"# Render the ERB template and return the generated code. \n" -"def render(erb_template, n, env) \n" -" begin \n" -" ERB.new(File.read(erb_template)).result(binding) \n" -" rescue Exception => e \n" -" $stderr.puts(%{\\nError while generating a C++ file from the ERB template #{erb_template}:\\n}) \n" -" raise e \n" -" end \n" -"end \n" -" \n" -"# Formats the progress bar that we print while we run the benchmark \n" -"def progress_bar(range, index, start_time, filename) \n" -" n = range[index] \n" -" percentage = (index+1) * 100 / range.size \n" -" relative = filename.relative_path_from(Pathname.getwd) \n" -" elapsed = Time.now - start_time \n" -" return %{==> #{percentage}% (#{elapsed.round(2)}s) #{relative} (n = #{n})} \n" -"end \n" -" \n" -"# Returns an array of measurements representing the compilation of an ERB \n" -"# template for the values of `n` in the specified `range`. \n" -"def measure(target, erb_template, range, env, repetitions) \n" -" erb_template = Pathname.new(erb_template) \n" -" cpp_file = %{${METABENCH_DIR}/#{target}.cpp} \n" -" data = [] \n" -" range = range.to_a \n" -" start = Time.now \n" -" $stderr.write(progress_bar(range, 0, start, erb_template)) # Setup the initial progress bar \n" -" range.each_with_index do |n, index| \n" -" compile = -> (code) { \n" -" IO.write(cpp_file, code) \n" -" return repetitions.times.map { build(target) } \n" -" } \n" -" code = render(erb_template, n, env) \n" -" compile[code] if index == 0 # Fill the cache on the first iteration \n" -" base = compile[code] \n" -" total = compile[%{#define METABENCH\\n} + code] \n" -" data << {'n' => n, 'base' => base, 'total' => total} \n" -" $stderr.write(%{\\r} + progress_bar(range, index, start, erb_template)) # Update the progress bar \n" -" end \n" -" return data \n" -"ensure \n" -" $stderr.puts # Otherwise the output of the next CMake command appears on the same line \n" -" IO.write(cpp_file, '') \n" -"end \n" + "require 'benchmark' \n" + "require 'erb' \n" + "require 'fileutils' \n" + "require 'open3' \n" + "require 'pathname' \n" + "require 'time' \n" + " \n" + " \n" + "def report_error(command_line, stdout, stderr, code) \n" + " raise [%{\\ncommand line: #{command_line}}, \n" + " %{stdout\\n#{'-'*80}\\n#{stdout}}, \n" + " %{stderr\\n#{'-'*80}\\n#{stderr}}, \n" + " %{code\\n#{'-'*80}\\n#{code}}].join(%{\\n\\n}) \n" + "end \n" + " \n" + "# Build the specified CMake target and return the measurements that were taken. \n" + "# The exact format of a measurement returned by this function is explained \n" + "# in the JavaScript code that loads it, in the chart template file below. \n" + "def build(target) \n" + " command = ['${CMAKE_COMMAND}', '--build', '${CMAKE_BINARY_DIR}', '--target', target] \n" + " exe_file = %{${METABENCH_DIR}/#{target}${CMAKE_EXECUTABLE_SUFFIX}} \n" + " cpp_file = %{${METABENCH_DIR}/#{target}.cpp} \n" + " \n" + " # We change the timestamp of the source file and remove the executable \n" + " # to make sure CMake considers the target as outdated; otherwise, we \n" + " # might skip the compilation and/or link steps. This is because CMake's \n" + " # timestamps are not precise enough. \n" + " FileUtils.touch(cpp_file, mtime: Time.now+1) \n" + " File.delete(exe_file) if File.exist?(exe_file) \n" + " \n" + " stdout, stderr, status = Open3.capture3(*command) \n" + " compile_cli = stdout.match(/\\[compilation command: (.+)\\]/i) \n" + " compile_cli = compile_cli ? compile_cli.captures[0] : '(unavailable)' \n" + " link_cli = stdout.match(/\\[link command: (.+)\\]/i) \n" + " link_cli = link_cli ? link_cli.captures[0] : '(unavailable)' \n" + " \n" + " if not status.success? \n" + " cli = %{compile: #{compile_cli}\\nlink: #{link_cli}} \n" + " report_error(cli, stdout, stderr, IO.read(cpp_file)) \n" + " end \n" + " \n" + " result = {} \n" + " \n" + " # Compilation and link times in seconds. They are output to stdout because \n" + " # we use the `compile.rb` and `link.rb` scripts below to launch the compiler \n" + " # and linker with CMake. \n" + " result['COMPILATION_TIME'] = stdout.match(/\\[COMPILATION_TIME: (.+)\\]/i).captures[0].to_f \n" + " result['LINK_TIME'] = stdout.match(/\\[LINK_TIME: (.+)\\]/i).captures[0].to_f \n" + " \n" + " # Peak memory usage \n" + " result['PEAK_MEMORY'] = stdout.match(/\\[PEAK_MEMORY: (.+)\\]/i).captures[0].to_f \n" + " \n" + " # Size of the generated executable in KB \n" + " result['EXECUTABLE_SIZE'] = File.size(exe_file).to_f / 1000 \n" + " \n" + " return result \n" + "end \n" + " \n" + "# Render the ERB template and return the generated code. \n" + "def render(erb_template, n, env) \n" + " begin \n" + " ERB.new(File.read(erb_template)).result(binding) \n" + " rescue Exception => e \n" + " $stderr.puts(%{\\nError while generating a C++ file from the ERB template #{erb_template}:\\n}) \n" + " raise e \n" + " end \n" + "end \n" + " \n" + "# Formats the progress bar that we print while we run the benchmark \n" + "def progress_bar(range, index, start_time, filename) \n" + " n = range[index] \n" + " percentage = (index+1) * 100 / range.size \n" + " relative = filename.relative_path_from(Pathname.getwd) \n" + " elapsed = Time.now - start_time \n" + " return %{==> #{percentage}% (#{elapsed.round(2)}s) #{relative} (n = #{n})} \n" + "end \n" + " \n" + "# Returns an array of measurements representing the compilation of an ERB \n" + "# template for the values of `n` in the specified `range`. \n" + "def measure(target, erb_template, range, env, repetitions) \n" + " erb_template = Pathname.new(erb_template) \n" + " cpp_file = %{${METABENCH_DIR}/#{target}.cpp} \n" + " data = [] \n" + " range = range.to_a \n" + " start = Time.now \n" + " $stderr.write(progress_bar(range, 0, start, erb_template)) # Setup the initial progress bar \n" + " range.each_with_index do |n, index| \n" + " compile = -> (code) { \n" + " IO.write(cpp_file, code) \n" + " return repetitions.times.map { build(target) } \n" + " } \n" + " code = render(erb_template, n, env) \n" + " compile[code] if index == 0 # Fill the cache on the first iteration \n" + " base = compile[code] \n" + " total = compile[%{#define METABENCH\\n} + code] \n" + " data << {'n' => n, 'base' => base, 'total' => total} \n" + " $stderr.write(%{\\r} + progress_bar(range, index, start, erb_template)) # Update the progress bar \n" + " end \n" + " return data \n" + "ensure \n" + " $stderr.puts # Otherwise the output of the next CMake command appears on the same line \n" + " IO.write(cpp_file, '') \n" + "end \n" ) ################################################################################ # end metabench.rb @@ -454,47 +443,47 @@ file(WRITE "${METABENCH_RB_PATH}" ################################################################################ set(MEMUSG_RB_PATH "${METABENCH_DIR}/memusg.rb") file(WRITE "${MEMUSG_RB_PATH}" -"module OS \n" -" def OS.windows? \n" -" (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil \n" -" end \n" -" def OS.mac? \n" -" (/darwin/ =~ RUBY_PLATFORM) != nil \n" -" end \n" -" def OS.unix? \n" -" !OS.windows? \n" -" end \n" -" def OS.linux? \n" -" OS.unix? and not OS.mac? \n" -" end \n" -"end \n" -" \n" -"if OS.mac? \n" -" def memusg(pgid) \n" -" `/bin/ps -o rss= -g #{pgid}`.to_i \n" -" end \n" -"elsif OS.linux? \n" -" def memusg(pgid) \n" -" `/bin/ps -o rss= -#{pgid}`.to_i \n" -" end \n" -"else \n" -" throw %{Unsupported platform #{RUBY_PLATFORM}} \n" -"end \n" -" \n" -"pid = Process.spawn(*ARGV) \n" -"Process.detach(pid) # Make sure the child process does not become a zombie \n" -"peak = 0 \n" -"# Loop until getpgid throws ESRCH, which means the process is not alive anymore \n" -"begin \n" -" while true \n" -" pgid = Process.getpgid(pid) \n" -" peak = [peak, memusg(pgid)].max \n" -" sleep 0.01 \n" -" end \n" -"rescue Errno::ESRCH \n" -"end \n" -" \n" -"puts %{[PEAK_MEMORY: #{peak}]} \n" + "module OS \n" + " def OS.windows? \n" + " (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil \n" + " end \n" + " def OS.mac? \n" + " (/darwin/ =~ RUBY_PLATFORM) != nil \n" + " end \n" + " def OS.unix? \n" + " !OS.windows? \n" + " end \n" + " def OS.linux? \n" + " OS.unix? and not OS.mac? \n" + " end \n" + "end \n" + " \n" + "if OS.mac? \n" + " def memusg(pgid) \n" + " `/bin/ps -o rss= -g #{pgid}`.to_i \n" + " end \n" + "elsif OS.linux? \n" + " def memusg(pgid) \n" + " `/bin/ps -o rss= -#{pgid}`.to_i \n" + " end \n" + "else \n" + " throw %{Unsupported platform #{RUBY_PLATFORM}} \n" + "end \n" + " \n" + "pid = Process.spawn(*ARGV) \n" + "Process.detach(pid) # Make sure the child process does not become a zombie \n" + "peak = 0 \n" + "# Loop until getpgid throws ESRCH, which means the process is not alive anymore \n" + "begin \n" + " while true \n" + " pgid = Process.getpgid(pid) \n" + " peak = [peak, memusg(pgid)].max \n" + " sleep 0.01 \n" + " end \n" + "rescue Errno::ESRCH \n" + "end \n" + " \n" + "puts %{[PEAK_MEMORY: #{peak}]} \n" ) ################################################################################ # end memusg.rb @@ -508,18 +497,18 @@ file(WRITE "${MEMUSG_RB_PATH}" ################################################################################ set(COMPILE_RB_PATH "${METABENCH_DIR}/compile.rb") file(WRITE "${COMPILE_RB_PATH}" -"require 'benchmark' \n" -"require 'open3' \n" -"stdout = stderr = status = nil \n" -"command_line = ['${RUBY_EXECUTABLE}', '--', '${MEMUSG_RB_PATH}'] + ARGV \n" -"time = Benchmark.measure { \n" -" stdout, stderr, status = Open3.capture3(*command_line) \n" -"}.total \n" -"$stdout.puts(stdout) \n" -"$stdout.puts(%{[compilation command: #{command_line.join(' ')}]}) \n" -"$stdout.puts(%{[COMPILATION_TIME: #{time}]}) \n" -"$stderr.puts(stderr) \n" -"exit(status.success?) \n" + "require 'benchmark' \n" + "require 'open3' \n" + "stdout = stderr = status = nil \n" + "command_line = ['${RUBY_EXECUTABLE}', '--', '${MEMUSG_RB_PATH}'] + ARGV \n" + "time = Benchmark.measure { \n" + " stdout, stderr, status = Open3.capture3(*command_line) \n" + "}.total \n" + "$stdout.puts(stdout) \n" + "$stdout.puts(%{[compilation command: #{command_line.join(' ')}]}) \n" + "$stdout.puts(%{[COMPILATION_TIME: #{time}]}) \n" + "$stderr.puts(stderr) \n" + "exit(status.success?) \n" ) ################################################################################ # end compile.rb @@ -532,15 +521,15 @@ file(WRITE "${COMPILE_RB_PATH}" ################################################################################ set(LINK_RB_PATH "${METABENCH_DIR}/link.rb") file(WRITE "${LINK_RB_PATH}" -"require 'benchmark' \n" -"require 'open3' \n" -"stdout = stderr = status = nil \n" -"time = Benchmark.measure { stdout, stderr, status = Open3.capture3(*ARGV) }.total\n" -"$stdout.puts(stdout) \n" -"$stdout.puts(%{[link command: #{ARGV.join(' ')}]}) \n" -"$stdout.puts(%{[LINK_TIME: #{time}]}) \n" -"$stderr.puts(stderr) \n" -"exit(status.success?) \n" + "require 'benchmark' \n" + "require 'open3' \n" + "stdout = stderr = status = nil \n" + "time = Benchmark.measure { stdout, stderr, status = Open3.capture3(*ARGV) }.total\n" + "$stdout.puts(stdout) \n" + "$stdout.puts(%{[link command: #{ARGV.join(' ')}]}) \n" + "$stdout.puts(%{[LINK_TIME: #{time}]}) \n" + "$stderr.puts(stderr) \n" + "exit(status.success?) \n" ) ################################################################################ # end link.rb @@ -555,191 +544,191 @@ file(WRITE "${LINK_RB_PATH}" ################################################################################ set(CHART_HTML_ERB_PATH "${METABENCH_DIR}/chart.html.erb") file(WRITE "${CHART_HTML_ERB_PATH}" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" ) ################################################################################ # end chart.html.erb @@ -751,13 +740,15 @@ file(WRITE "${CHART_HTML_ERB_PATH}" # The following is a copy of the nvd3 1.8.5 css file. # https://github.com/novus/nvd3 ################################################################################ -file(WRITE "${METABENCH_DIR}/nvd3.css" "\ +file(WRITE "${METABENCH_DIR}/nvd3.css" + "\ .nvd3 .nv-axis line,.nvd3 .nv-axis path{fill:none;shape-rendering:crispEdges}.nv-brush .extent,.nvd3 .background path,.nvd3 .nv-axis line,.nvd3 .nv-axis path{shape-rendering:crispEdges}.nv-distx,.nv-disty,.nv-noninteractive,.nvd3 .nv-axis,.nvd3.nv-pie .nv-label,.nvd3.nv-sparklineplus g.nv-hoverValue{pointer-events:none}.nvd3 .nv-axis{opacity:1}.nvd3 .nv-axis.nv-disabled,.nvd3 .nv-controlsWrap .nv-legend .nv-check-box .nv-check{opacity:0}.nvd3 .nv-axis path{stroke:#000;stroke-opacity:.75}.nvd3 .nv-axis path.domain{stroke-opacity:.75}.nvd3 .nv-axis.nv-x path.domain{stroke-opacity:0}.nvd3 .nv-axis line{stroke:#e5e5e5}.nvd3 .nv-axis .zero line, .nvd3 .nv-axis line.zero{stroke-opacity:.75}.nvd3 .nv-axis .nv-axisMaxMin text{font-weight:700}.nvd3 .x .nv-axis .nv-axisMaxMin text,.nvd3 .x2 .nv-axis .nv-axisMaxMin text,.nvd3 .x3 .nv-axis .nv-axisMaxMin text{text-anchor:middle}.nvd3 .nv-bars rect{fill-opacity:.75;transition:fill-opacity 250ms linear}.nvd3 .nv-bars rect.hover{fill-opacity:1}.nvd3 .nv-bars .hover rect{fill:#add8e6}.nvd3 .nv-bars text{fill:transparent}.nvd3 .nv-bars .hover text{fill:rgba(0,0,0,1)}.nvd3 .nv-discretebar .nv-groups rect,.nvd3 .nv-multibar .nv-groups rect,.nvd3 .nv-multibarHorizontal .nv-groups rect{stroke-opacity:0;transition:fill-opacity 250ms linear}.with-transitions .nv-candlestickBar .nv-ticks .nv-tick,.with-transitions .nvd3 .nv-groups .nv-point{transition:stroke-width 250ms linear,stroke-opacity 250ms linear}.nvd3 .nv-candlestickBar .nv-ticks rect:hover,.nvd3 .nv-discretebar .nv-groups rect:hover,.nvd3 .nv-multibar .nv-groups rect:hover,.nvd3 .nv-multibarHorizontal .nv-groups rect:hover{fill-opacity:1}.nvd3 .nv-discretebar .nv-groups text,.nvd3 .nv-multibarHorizontal .nv-groups text{font-weight:700;fill:rgba(0,0,0,1);stroke:transparent}.nvd3 .nv-boxplot circle{fill-opacity:.5}.nvd3 .nv-boxplot circle:hover,.nvd3 .nv-boxplot rect:hover{fill-opacity:1}.nvd3 line.nv-boxplot-median{stroke:#000}.nv-boxplot-tick:hover{stroke-width:2.5px}.nvd3.nv-bullet{font:10px sans-serif}.nvd3.nv-bullet .nv-measure{fill-opacity:.8}.nvd3.nv-bullet \ .nv-measure:hover{fill-opacity:1}.nvd3.nv-bullet .nv-marker{stroke:#000;stroke-width:2px}.nvd3.nv-bullet .nv-markerTriangle{stroke:#000;fill:#fff;stroke-width:1.5px}.nvd3.nv-bullet .nv-markerLine{stroke:#000;stroke-width:1.5px}.nvd3.nv-bullet .nv-tick line{stroke:#666;stroke-width:.5px}.nvd3.nv-bullet .nv-range.nv-s0{fill:#eee}.nvd3.nv-bullet .nv-range.nv-s1{fill:#ddd}.nvd3.nv-bullet .nv-range.nv-s2{fill:#ccc}.nvd3.nv-bullet .nv-title{font-size:14px;font-weight:700}.nvd3.nv-bullet .nv-subtitle{fill:#999}.nvd3.nv-bullet .nv-range{fill:#bababa;fill-opacity:.4}.nvd3.nv-bullet .nv-range:hover{fill-opacity:.7}.nvd3.nv-candlestickBar .nv-ticks .nv-tick{stroke-width:1px}.nvd3.nv-candlestickBar .nv-ticks .nv-tick.hover{stroke-width:2px}.nvd3.nv-candlestickBar .nv-ticks .nv-tick.positive rect{stroke:#2ca02c;fill:#2ca02c}.nvd3.nv-candlestickBar .nv-ticks .nv-tick.negative rect{stroke:#d62728;fill:#d62728}.nvd3.nv-candlestickBar .nv-ticks line{stroke:#333}.nv-force-node{stroke:#fff;stroke-width:1.5px}.nv-force-link{stroke:#999;stroke-opacity:.6}.nv-force-node text{stroke-width:0}.nvd3 .nv-check-box .nv-box{fill-opacity:0;stroke-width:2}.nvd3 .nv-check-box .nv-check{fill-opacity:0;stroke-width:4}.nvd3 .nv-series.nv-disabled .nv-check-box .nv-check{fill-opacity:0;stroke-opacity:0}.nvd3.nv-linePlusBar .nv-bar rect{fill-opacity:.75}.nvd3.nv-linePlusBar .nv-bar rect:hover{fill-opacity:1}.nvd3 .nv-groups path.nv-line{fill:none}.nvd3 .nv-groups path.nv-area{stroke:none}.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point{fill-opacity:0;stroke-opacity:0}.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point{fill-opacity:.5!important;stroke-opacity:.5!important}.nvd3 .nv-groups .nv-point.hover,.nvd3.nv-scatter .nv-groups .nv-point.hover{stroke-width:7px;fill-opacity:.95!important;stroke-opacity:.95!important}.nvd3 .nv-point-paths path{stroke:#aaa;stroke-opacity:0;fill:#eee;fill-opacity:0}.nvd3 .nv-indexLine{cursor:ew-resize}svg.nvd3-svg{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:block;width:100%;\ height:100%}.nvtooltip.with-3d-shadow,.with-3d-shadow .nvtooltip{box-shadow:0 5px 10px rgba(0,0,0,.2);border-radius:5px}.nvd3 text{font:400 12px Arial,sans-serif}.nvd3 .title{font:700 14px Arial,sans-serif}.nvd3 .nv-background{fill:#fff;fill-opacity:0}.nvd3.nv-noData{font-size:18px;font-weight:700}.nv-brush .extent{fill-opacity:.125}.nv-brush .resize path{fill:#eee;stroke:#666}.nvd3 .nv-legend .nv-series{cursor:pointer}.nvd3 .nv-legend .nv-disabled circle{fill-opacity:0}.nvd3 .nv-brush .extent{fill-opacity:0!important}.nvd3 .nv-brushBackground rect{stroke:#000;stroke-width:.4;fill:#fff;fill-opacity:.7}\@media print{.nvd3 text{stroke-width:0;fill-opacity:1}}.nvd3.nv-ohlcBar .nv-ticks .nv-tick{stroke-width:1px}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover{stroke-width:2px}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive{stroke:#2ca02c}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative{stroke:#d62728}.nvd3 .background path{fill:none;stroke:#EEE;stroke-opacity:.4}.nvd3 .foreground path{fill:none;stroke-opacity:.7}.nvd3 .nv-parallelCoordinates-brush .extent{fill:#fff;fill-opacity:.6;stroke:gray;shape-rendering:crispEdges}.nvd3 .nv-parallelCoordinates .hover{fill-opacity:1;stroke-width:3px}.nvd3 .missingValuesline line{fill:none;stroke:#000;stroke-width:1;stroke-opacity:1;stroke-dasharray:5,5}.nvd3.nv-pie .nv-pie-title{font-size:24px;fill:rgba(19,196,249,.59)}.nvd3.nv-pie .nv-slice text{stroke:#000;stroke-width:0}.nvd3.nv-pie path{transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear;stroke:#fff;stroke-width:1px;stroke-opacity:1;fill-opacity:.7}.nvd3.nv-pie .hover path{fill-opacity:1}.nvd3.nv-pie .nv-label rect{fill-opacity:0;stroke-opacity:0}.nvd3 .nv-groups .nv-point.hover{stroke-width:20px;stroke-opacity:.5}.nvd3 .nv-scatter .nv-point.hover{fill-opacity:1}.nvd3.nv-sparkline path{fill:none}.nvd3.nv-sparklineplus .nv-hoverValue line{stroke:#333;stroke-width:1.5px}.nvd3.nv-sparklineplus,.nvd3.nv-sparklineplus g{pointer-events:all}.nvd3 .nv-interactiveGuideLine,.nvtooltip{pointer-events:none}.nvd3 .nv-hoverArea{fill-opacity:0;\ stroke-opacity:0}.nvd3.nv-sparklineplus .nv-xValue,.nvd3.nv-sparklineplus .nv-yValue{stroke-width:0;font-size:.9em;font-weight:400}.nvd3.nv-sparklineplus .nv-yValue{stroke:#f66}.nvd3.nv-sparklineplus .nv-maxValue{stroke:#2ca02c;fill:#2ca02c}.nvd3.nv-sparklineplus .nv-minValue{stroke:#d62728;fill:#d62728}.nvd3.nv-sparklineplus .nv-currentValue{font-weight:700;font-size:1.1em}.nvtooltip h3,.nvtooltip table td.key{font-weight:400}.nvd3.nv-stackedarea path.nv-area{fill-opacity:.7;stroke-opacity:0;transition:fill-opacity 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-stackedarea path.nv-area.hover{fill-opacity:.9}.nvd3.nv-stackedarea .nv-groups .nv-point{stroke-opacity:0;fill-opacity:0}.nvtooltip{position:absolute;color:rgba(0,0,0,1);padding:1px;z-index:10000;display:block;font-family:Arial,sans-serif;font-size:13px;text-align:left;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background:rgba(255,255,255,.8);border:1px solid rgba(0,0,0,.5);border-radius:4px}.nvtooltip h3,.nvtooltip p{margin:0;text-align:center}.nvtooltip.with-transitions,.with-transitions .nvtooltip{transition:opacity 50ms linear;transition-delay:200ms}.nvtooltip.x-nvtooltip,.nvtooltip.y-nvtooltip{padding:8px}.nvtooltip h3{padding:4px 14px;line-height:18px;background-color:rgba(247,247,247,.75);color:rgba(0,0,0,1);border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.nvtooltip p{padding:5px 14px}.nvtooltip span{display:inline-block;margin:2px 0}.nvtooltip table{margin:6px;border-spacing:0}.nvtooltip table td{padding:2px 9px 2px 0;vertical-align:middle}.nvtooltip table td.key.total{font-weight:700}.nvtooltip table td.value{text-align:right;font-weight:700}.nvtooltip table td.percent{color:#a9a9a9}.nvtooltip table tr.highlight td{padding:1px 9px 1px 0;border-bottom-style:solid;border-bottom-width:1px;border-top-style:solid;border-top-width:1px}.nvtooltip table td.legend-color-guide div{vertical-align:middle;width:12px;height:12px;border:1px solid #999}.nvtooltip .footer{padding:3px;text-align:center}.nvtooltip-pending-removal{pointer-events:none;\ display:none}.nvd3 line.nv-guideline{stroke:#ccc}\ -") +" +) ################################################################################ # end nvd3.css ################################################################################ @@ -770,7 +761,8 @@ display:none}.nvd3 line.nv-guideline{stroke:#ccc}\ # parsing too long strings. # https://github.com/novus/nvd3 ################################################################################ -file(WRITE "${METABENCH_DIR}/nvd3.js" "\ +file(WRITE "${METABENCH_DIR}/nvd3.js" + "\ /* nvd3 version 1.8.5 (https://github.com/novus/nvd3) 2016-12-01 */\ !function(){var a={};a.dev=!1,a.tooltip=a.tooltip||{},a.utils=a.utils||{},a.models=a.models||{},a.charts={},a.logs={},a.dom={},\"undefined\"!=typeof module&&\"undefined\"!=typeof exports&&\"undefined\"==typeof d3&&(d3=require(\"d3\")),a.dispatch=d3.dispatch(\"render_start\",\"render_end\"),Function.prototype.bind||(Function.prototype.bind=function(a){if(\"function\"!=typeof this)throw new TypeError(\"Function.prototype.bind - what is trying to be bound is not callable\");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),a.dev&&(a.dispatch.on(\"render_start\",function(b){a.logs.startTime=+new Date}),a.dispatch.on(\"render_end\",function(b){a.logs.endTime=+new Date,a.logs.totalTime=a.logs.endTime-a.logs.startTime,a.log(\"total\",a.logs.totalTime)})),a.log=function(){if(a.dev&&window.console&&console.log&&console.log.apply)console.log.apply(console,arguments);else if(a.dev&&window.console&&\"function\"==typeof console.log&&Function.prototype.bind){var b=Function.prototype.bind.call(console.log,console);b.apply(console,arguments)}return arguments[arguments.length-1]},a.deprecated=function(a,b){console&&console.warn&&console.warn(\"nvd3 warning: `\"+a+\"` has been deprecated. \",b||\"\")},a.render=function(b){b=b||1,a.render.active=!0,a.dispatch.render_start();var c=function(){for(var d,e,f=0;b>f&&(e=a.render.queue[f]);f++)d=e.generate(),typeof e.callback==typeof Function&&e.callback(d);a.render.queue.splice(0,f),a.render.queue.length?setTimeout(c):(a.dispatch.render_end(),a.render.active=!1)};setTimeout(c)},a.render.active=!1,a.render.queue=[],a.addGraph=function(b){typeof arguments[0]==typeof Function&&(b={generate:arguments[0],callback:arguments[1]}),a.render.queue.push(b),a.render.active||a.render()},\"undefined\"!=typeof module&&\"undefined\"!=typeof exports&&(module.exports=a),\"undefined\"!=typeof window&&(window.nv=a),a.dom.write=function(a){return void 0!==window.fastdom?fastdom.mutate(a):a()},\ a.dom.read=function(a){return void 0!==window.fastdom?fastdom.measure(a):a()},a.interactiveGuideline=function(){\"use strict\";function b(l){l.each(function(l){function m(){var a=d3.mouse(this),d=a[0],e=a[1],h=!0,i=!1;if(k&&(d=d3.event.offsetX,e=d3.event.offsetY,\"svg\"!==d3.event.target.tagName&&(h=!1),d3.event.target.className.baseVal.match(\"nv-legend\")&&(i=!0)),h&&(d-=c.left,e-=c.top),\"mouseout\"===d3.event.type||0>d||0>e||d>o||e>p||d3.event.relatedTarget&&void 0===d3.event.relatedTarget.ownerSVGElement||i){if(k&&d3.event.relatedTarget&&void 0===d3.event.relatedTarget.ownerSVGElement&&(void 0===d3.event.relatedTarget.className||d3.event.relatedTarget.className.match(j.nvPointerEventsClass)))return;return g.elementMouseout({mouseX:d,mouseY:e}),b.renderGuideLine(null),void j.hidden(!0)}j.hidden(!1);var l=\"function\"==typeof f.rangeBands,m=void 0;if(l){var n=d3.bisect(f.range(),d)-1;if(!(f.range()[n]+f.rangeBand()>=d))return g.elementMouseout({mouseX:d,mouseY:e}),b.renderGuideLine(null),void j.hidden(!0);m=f.domain()[d3.bisect(f.range(),d)-1]}else m=f.invert(d);g.elementMousemove({mouseX:d,mouseY:e,pointXValue:m}),\"dblclick\"===d3.event.type&&g.elementDblclick({mouseX:d,mouseY:e,pointXValue:m}),\"click\"===d3.event.type&&g.elementClick({mouseX:d,mouseY:e,pointXValue:m}),\"mousedown\"===d3.event.type&&g.elementMouseDown({mouseX:d,mouseY:e,pointXValue:m}),\"mouseup\"===d3.event.type&&g.elementMouseUp({mouseX:d,mouseY:e,pointXValue:m})}var n=d3.select(this),o=d||960,p=e||400,q=n.selectAll(\"g.nv-wrap.nv-interactiveLineLayer\").data([l]),r=q.enter().append(\"g\").attr(\"class\",\" nv-wrap nv-interactiveLineLayer\");r.append(\"g\").attr(\"class\",\"nv-interactiveGuideLine\"),i&&(i.on(\"touchmove\",m).on(\"mousemove\",m,!0).on(\"mouseout\",m,!0).on(\"mousedown\",m,!0).on(\"mouseup\",m,!0).on(\"dblclick\",m).on(\"click\",m),b.guideLine=null,b.renderGuideLine=function(c){h&&(b.guideLine&&b.guideLine.attr(\"x1\")===c||a.dom.write(function(){var b=q.select(\".nv-interactiveGuideLine\").selectAll(\"line\").data(null!=c?[a.utils.NaNtoZero(c)]:[],String);b.enter().append(\"line\").attr(\"class\",\ @@ -800,9 +792,11 @@ c>d?m(d)-m(c):m(c)-m(d)})}),b}var c,d,e,f,g,h={top:0,right:0,bottom:0,left:0},i= h.bottom=void 0!=a.bottom?a.bottom:h.bottom,h.left=void 0!=a.left?a.left:h.left}},color:{get:function(){return x},set:function(b){x=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.cumulativeLineChart=function(){\"use strict\";function b(l){return I.reset(),I.models(f),s&&I.models(g),t&&I.models(h),l.each(function(l){function B(a,c){d3.select(b.container).style(\"cursor\",\"ew-resize\")}function F(a,b){H.x=d3.event.x,H.i=Math.round(G.invert(H.x)),L()}function I(a,c){d3.select(b.container).style(\"cursor\",\"auto\"),z.index=H.i,D.stateChange(z)}function L(){ba.data([H]);var a=b.duration();b.duration(0),b.update(),b.duration(a)}var M=d3.select(this);a.utils.initSVG(M),M.classed(\"nv-chart-\"+y,!0);var N=a.utils.availableWidth(p,M,m),O=a.utils.availableHeight(q,M,m);if(b.update=function(){0===E?M.call(b):M.transition().duration(E).call(b)},b.container=this,z.setter(K(l),b.update).getter(J(l)).update(),z.disabled=l.map(function(a){return!!a.disabled}),!A){var P;A={};for(P in z)z[P]instanceof Array?A[P]=z[P].slice(0):A[P]=z[P]}var Q=d3.behavior.drag().on(\"dragstart\",B).on(\"drag\",F).on(\"dragend\",I);if(!(l&&l.length&&l.filter(function(a){return a.values.length}).length))return a.utils.noData(b,M),b;if(M.selectAll(\".nv-noData\").remove(),d=f.xScale(),e=f.yScale(),x)f.yDomain(null);else{var R=l.filter(function(a){return!a.disabled}).map(function(a,b){var c=d3.extent(a.values,f.y());return c[0]<-.95&&(c[0]=-.95),[(c[0]-c[1])/(1+c[1]),(c[1]-c[0])/(1+c[0])]}),S=[d3.min(R,function(a){return a[0]}),d3.max(R,function(a){return a[1]})];f.yDomain(S)}G.domain([0,l[0].values.length-1]).range([0,N]).clamp(!0);var l=c(H.i,l),T=w?\"none\":\"all\",U=M.selectAll(\"g.nv-wrap.nv-cumulativeLine\").data([l]),V=U.enter().append(\"g\").attr(\"class\",\"nvd3 nv-wrap nv-cumulativeLine\").append(\"g\"),W=U.select(\"g\");if(V.append(\"g\").attr(\"class\",\"nv-interactive\"),V.append(\"g\").attr(\"class\",\"nv-x nv-axis\").style(\"pointer-events\",\"none\"),V.append(\"g\").attr(\"class\",\"nv-y nv-axis\"),V.append(\"g\").attr(\"class\",\"nv-background\"),V.append(\"g\").attr(\"class\",\"nv-linesWrap\").style(\"pointer-events\",\ T),V.append(\"g\").attr(\"class\",\"nv-avgLinesWrap\").style(\"pointer-events\",\"none\"),V.append(\"g\").attr(\"class\",\"nv-legendWrap\"),V.append(\"g\").attr(\"class\",\"nv-controlsWrap\"),r?(i.width(N),W.select(\".nv-legendWrap\").datum(l).call(i),n||i.height()===m.top||(m.top=i.height(),O=a.utils.availableHeight(q,M,m)),W.select(\".nv-legendWrap\").attr(\"transform\",\"translate(0,\"+-m.top+\")\")):W.select(\".nv-legendWrap\").selectAll(\"*\").remove(),v){var X=[{key:\"Re-scale y-axis\",disabled:!x}];j.width(140).color([\"#444\",\"#444\",\"#444\"]).rightAlign(!1).margin({top:5,right:0,bottom:5,left:20}),W.select(\".nv-controlsWrap\").datum(X).attr(\"transform\",\"translate(0,\"+-m.top+\")\").call(j)}else W.select(\".nv-controlsWrap\").selectAll(\"*\").remove();U.attr(\"transform\",\"translate(\"+m.left+\",\"+m.top+\")\"),u&&W.select(\".nv-y.nv-axis\").attr(\"transform\",\"translate(\"+N+\",0)\");var Y=l.filter(function(a){return a.tempDisabled});U.select(\".tempDisabled\").remove(),Y.length&&U.append(\"text\").attr(\"class\",\"tempDisabled\").attr(\"x\",N/2).attr(\"y\",\"-.71em\").style(\"text-anchor\",\"end\").text(Y.map(function(a){return a.key}).join(\", \")+\" values cannot be calculated for this time period.\"),w&&(k.width(N).height(O).margin({left:m.left,top:m.top}).svgContainer(M).xScale(d),U.select(\".nv-interactive\").call(k)),V.select(\".nv-background\").append(\"rect\"),W.select(\".nv-background rect\").attr(\"width\",N).attr(\"height\",O),f.y(function(a){return a.display.y}).width(N).height(O).color(l.map(function(a,b){return a.color||o(a,b)}).filter(function(a,b){return!l[b].disabled&&!l[b].tempDisabled}));var Z=W.select(\".nv-linesWrap\").datum(l.filter(function(a){return!a.disabled&&!a.tempDisabled}));Z.call(f),l.forEach(function(a,b){a.seriesIndex=b});var $=l.filter(function(a){return!a.disabled&&!!C(a)}),_=W.select(\".nv-avgLinesWrap\").selectAll(\"line\").data($,function(a){return a.key}),aa=function(a){var b=e(C(a));return 0>b?0:b>O?O:b};_.enter().append(\"line\").style(\"stroke-width\",2).style(\"stroke-dasharray\",\"10,10\").style(\"stroke\",function(a,b){return f.color()(a,a.seriesIndex)}).attr(\"x1\",0).attr(\"x2\",\ N).attr(\"y1\",aa).attr(\"y2\",aa),_.style(\"stroke-opacity\",function(a){var b=e(C(a));return 0>b||b>O?0:1}).attr(\"x1\",0).attr(\"x2\",N).attr(\"y1\",aa).attr(\"y2\",aa),_.exit().remove();var ba=Z.selectAll(\".nv-indexLine\").data([H]);ba.enter().append(\"rect\").attr(\"class\",\"nv-indexLine\").attr(\"width\",3).attr(\"x\",-2).attr(\"fill\",\"red\").attr(\"fill-opacity\",.5).style(\"pointer-events\",\"all\").call(Q),ba.attr(\"transform\",function(a){return\"translate(\"+G(a.i)+\",0)\"}).attr(\"height\",O),s&&(g.scale(d)._ticks(a.utils.calcTicksX(N/70,l)).tickSize(-O,0),W.select(\".nv-x.nv-axis\").attr(\"transform\",\"translate(0,\"+e.range()[0]+\")\"),W.select(\".nv-x.nv-axis\").call(g)),t&&(h.scale(e)._ticks(a.utils.calcTicksY(O/36,l)).tickSize(-N,0),W.select(\".nv-y.nv-axis\").call(h)),W.select(\".nv-background rect\").on(\"click\",function(){H.x=d3.mouse(this)[0],H.i=Math.round(G.invert(H.x)),z.index=H.i,D.stateChange(z),L()}),f.dispatch.on(\"elementClick\",function(a){H.i=a.pointIndex,H.x=G(H.i),z.index=H.i,D.stateChange(z),L()}),j.dispatch.on(\"legendClick\",function(a,c){a.disabled=!a.disabled,x=!a.disabled,z.rescaleY=x,D.stateChange(z),b.update()}),i.dispatch.on(\"stateChange\",function(a){for(var c in a)z[c]=a[c];D.stateChange(z),b.update()}),k.dispatch.on(\"elementMousemove\",function(c){f.clearHighlights();var d,e,i,j=[];if(l.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(g,h){e=a.interactiveBisect(g.values,c.pointXValue,b.x()),f.highlightPoint(h,e,!0);var k=g.values[e];\"undefined\"!=typeof k&&(\"undefined\"==typeof d&&(d=k),\"undefined\"==typeof i&&(i=b.xScale()(b.x()(k,e))),j.push({key:g.key,value:b.y()(k,e),color:o(g,g.seriesIndex)}))}),j.length>2){var m=b.yScale().invert(c.mouseY),n=Math.abs(b.yScale().domain()[0]-b.yScale().domain()[1]),p=.03*n,q=a.nearestValueIndex(j.map(function(a){return a.value}),m,p);null!==q&&(j[q].highlight=!0)}var r=g.tickFormat()(b.x()(d,e),e);k.tooltip.valueFormatter(function(a,b){return h.tickFormat()(a)}).data({value:r,series:j})(),k.renderGuideLine(i)}),k.dispatch.on(\"elementMouseout\",function(a){f.clearHighlights()}),\ -") +" +) -file(APPEND "${METABENCH_DIR}/nvd3.js" "\ +file(APPEND "${METABENCH_DIR}/nvd3.js" + "\ D.on(\"changeState\",function(a){\"undefined\"!=typeof a.disabled&&(l.forEach(function(b,c){b.disabled=a.disabled[c]}),z.disabled=a.disabled),\"undefined\"!=typeof a.index&&(H.i=a.index,H.x=G(H.i),z.index=a.index,ba.data([H])),\"undefined\"!=typeof a.rescaleY&&(x=a.rescaleY),b.update()})}),I.renderEnd(\"cumulativeLineChart immediate\"),b}function c(a,b){return L||(L=f.y()),b.map(function(b,c){if(!b.values)return b;var d=b.values[a];if(null==d)return b;var e=L(d,a);return-.95>e&&!F?(b.tempDisabled=!0,b):(b.tempDisabled=!1,b.values=b.values.map(function(a,b){return a.display={y:(L(a,b)-e)/(1+e)},a}),b)})}var d,e,f=a.models.line(),g=a.models.axis(),h=a.models.axis(),i=a.models.legend(),j=a.models.legend(),k=a.interactiveGuideline(),l=a.models.tooltip(),m={top:30,right:30,bottom:50,left:60},n=null,o=a.utils.defaultColor(),p=null,q=null,r=!0,s=!0,t=!0,u=!1,v=!0,w=!1,x=!0,y=f.id(),z=a.utils.state(),A=null,B=null,C=function(a){return a.average},D=d3.dispatch(\"stateChange\",\"changeState\",\"renderEnd\"),E=250,F=!1;z.index=0,z.rescaleY=x,g.orient(\"bottom\").tickPadding(7),h.orient(u?\"right\":\"left\"),l.valueFormatter(function(a,b){return h.tickFormat()(a,b)}).headerFormatter(function(a,b){return g.tickFormat()(a,b)}),j.updateState(!1);var G=d3.scale.linear(),H={i:0,x:0},I=a.utils.renderWatch(D,E),J=function(a){return function(){return{active:a.map(function(a){return!a.disabled}),index:H.i,rescaleY:x}}},K=function(a){return function(b){void 0!==b.index&&(H.i=b.index),void 0!==b.rescaleY&&(x=b.rescaleY),void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};f.dispatch.on(\"elementMouseover.tooltip\",function(a){var c={x:b.x()(a.point),y:b.y()(a.point),color:a.point.color};a.point=c,l.data(a).hidden(!1)}),f.dispatch.on(\"elementMouseout.tooltip\",function(a){l.hidden(!0)});var L=null;return b.dispatch=D,b.lines=f,b.legend=i,b.controls=j,b.xAxis=g,b.yAxis=h,b.interactiveLayer=k,b.state=z,b.tooltip=l,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return p},set:function(a){p=a}},height:{get:function(){return \ q},set:function(a){q=a}},rescaleY:{get:function(){return x},set:function(a){x=a}},showControls:{get:function(){return v},set:function(a){v=a}},showLegend:{get:function(){return r},set:function(a){r=a}},average:{get:function(){return C},set:function(a){C=a}},defaultState:{get:function(){return A},set:function(a){A=a}},noData:{get:function(){return B},set:function(a){B=a}},showXAxis:{get:function(){return s},set:function(a){s=a}},showYAxis:{get:function(){return t},set:function(a){t=a}},noErrorCheck:{get:function(){return F},set:function(a){F=a}},margin:{get:function(){return m},set:function(a){void 0!==a.top&&(m.top=a.top,n=a.top),m.right=void 0!==a.right?a.right:m.right,m.bottom=void 0!==a.bottom?a.bottom:m.bottom,m.left=void 0!==a.left?a.left:m.left}},color:{get:function(){return o},set:function(b){o=a.utils.getColor(b),i.color(o)}},useInteractiveGuideline:{get:function(){return w},set:function(a){w=a,a===!0&&(b.interactive(!1),b.useVoronoi(!1))}},rightAlignYAxis:{get:function(){return u},set:function(a){u=a,h.orient(a?\"right\":\"left\")}},duration:{get:function(){return E},set:function(a){E=a,f.duration(E),g.duration(E),h.duration(E),I.reset(E)}}}),a.utils.inheritOptions(b,f),a.utils.initOptions(b),b},a.models.discreteBar=function(){\"use strict\";function b(m){return y.reset(),m.each(function(b){var m=k-j.left-j.right,x=l-j.top-j.bottom;c=d3.select(this),a.utils.initSVG(c),b.forEach(function(a,b){a.values.forEach(function(a){a.series=b})});var z=d&&e?[]:b.map(function(a){return a.values.map(function(a,b){return{x:p(a,b),y:q(a,b),y0:a.y0}})});n.domain(d||d3.merge(z).map(function(a){return a.x})).rangeBands(f||[0,m],.1),o.domain(e||d3.extent(d3.merge(z).map(function(a){return a.y}).concat(r))),t?o.range(g||[x-(o.domain()[0]<0?12:0),o.domain()[1]>0?12:0]):o.range(g||[x,0]),h=h||n,i=i||o.copy().range([o(0),o(0)]);var A=c.selectAll(\"g.nv-wrap.nv-discretebar\").data([b]),B=A.enter().append(\"g\").attr(\"class\",\"nvd3 nv-wrap nv-discretebar\"),C=B.append(\"g\");A.select(\"g\");C.append(\"g\").attr(\"class\",\"nv-groups\"),A.attr(\"transform\",\ \"translate(\"+j.left+\",\"+j.top+\")\");var D=A.select(\".nv-groups\").selectAll(\".nv-group\").data(function(a){return a},function(a){return a.key});D.enter().append(\"g\").style(\"stroke-opacity\",1e-6).style(\"fill-opacity\",1e-6),D.exit().watchTransition(y,\"discreteBar: exit groups\").style(\"stroke-opacity\",1e-6).style(\"fill-opacity\",1e-6).remove(),D.attr(\"class\",function(a,b){return\"nv-group nv-series-\"+b}).classed(\"hover\",function(a){return a.hover}),D.watchTransition(y,\"discreteBar: groups\").style(\"stroke-opacity\",1).style(\"fill-opacity\",.75);var E=D.selectAll(\"g.nv-bar\").data(function(a){return a.values});E.exit().remove();var F=E.enter().append(\"g\").attr(\"transform\",function(a,b,c){return\"translate(\"+(n(p(a,b))+.05*n.rangeBand())+\", \"+o(0)+\")\"}).on(\"mouseover\",function(a,b){d3.select(this).classed(\"hover\",!0),v.elementMouseover({data:a,index:b,color:d3.select(this).style(\"fill\")})}).on(\"mouseout\",function(a,b){d3.select(this).classed(\"hover\",!1),v.elementMouseout({data:a,index:b,color:d3.select(this).style(\"fill\")})}).on(\"mousemove\",function(a,b){v.elementMousemove({data:a,index:b,color:d3.select(this).style(\"fill\")})}).on(\"click\",function(a,b){var c=this;v.elementClick({data:a,index:b,color:d3.select(this).style(\"fill\"),event:d3.event,element:c}),d3.event.stopPropagation()}).on(\"dblclick\",function(a,b){v.elementDblClick({data:a,index:b,color:d3.select(this).style(\"fill\")}),d3.event.stopPropagation()});F.append(\"rect\").attr(\"height\",0).attr(\"width\",.9*n.rangeBand()/b.length),t?(F.append(\"text\").attr(\"text-anchor\",\"middle\"),E.select(\"text\").text(function(a,b){return u(q(a,b))}).watchTransition(y,\"discreteBar: bars text\").attr(\"x\",.9*n.rangeBand()/2).attr(\"y\",function(a,b){return q(a,b)<0?o(q(a,b))-o(0)+12:-4})):E.selectAll(\"text\").remove(),E.attr(\"class\",function(a,b){return q(a,b)<0?\"nv-bar negative\":\"nv-bar positive\"}).style(\"fill\",function(a,b){return a.color||s(a,b)}).style(\"stroke\",function(a,b){return a.color||s(a,b)}).select(\"rect\").attr(\"class\",w).watchTransition(y,\"discreteBar: bars rect\").attr(\"width\",.9*n.rangeBand()/b.length),\ @@ -833,9 +827,11 @@ K.select(\".nv-legendWrap\").attr(\"transform\",\"translate(0,\"+-l.top+\")\"))) i.tooltip.valueFormatter(i.tooltip.valueFormatter()||s).data({value:b.x()(f,h),index:h,series:m})(),i.renderGuideLine(l)}),i.dispatch.on(\"elementClick\",function(c){var d,f=[];j.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(e){var g=a.interactiveBisect(e.values,c.pointXValue,b.x()),h=e.values[g];if(\"undefined\"!=typeof h){\"undefined\"==typeof d&&(d=b.xScale()(b.x()(h,g)));var i=b.yScale()(b.y()(h,g));f.push({point:h,pointIndex:g,pos:[d,i],seriesIndex:e.seriesIndex,series:e})}}),e.dispatch.elementClick(f)}),i.dispatch.on(\"elementMouseout\",function(a){e.clearHighlights()}),A.on(\"changeState\",function(a){\"undefined\"!=typeof a.disabled&&j.length===a.disabled.length&&(j.forEach(function(b,c){b.disabled=a.disabled[c]}),x.disabled=a.disabled),b.update()})}),C.renderEnd(\"lineChart immediate\"),b}var c,d,e=a.models.line(),f=a.models.axis(),g=a.models.axis(),h=a.models.legend(),i=a.interactiveGuideline(),j=a.models.tooltip(),k=a.models.focus(a.models.line()),l={top:30,right:20,bottom:50,left:60},m=null,n=a.utils.defaultColor(),o=null,p=null,q=!0,r=\"top\",s=!0,t=!0,u=!1,v=!1,w=!1,x=a.utils.state(),y=null,z=null,A=d3.dispatch(\"tooltipShow\",\"tooltipHide\",\"stateChange\",\"changeState\",\"renderEnd\"),B=250;f.orient(\"bottom\").tickPadding(7),g.orient(u?\"right\":\"left\"),e.clipEdge(!0).duration(0),j.valueFormatter(function(a,b){return g.tickFormat()(a,b)}).headerFormatter(function(a,b){return f.tickFormat()(a,b)}),i.tooltip.valueFormatter(function(a,b){return g.tickFormat()(a,b)}).headerFormatter(function(a,b){return f.tickFormat()(a,b)});var C=a.utils.renderWatch(A,B),D=function(a){return function(){return{active:a.map(function(a){return!a.disabled})}}},E=function(a){return function(b){void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return e.dispatch.on(\"elementMouseover.tooltip\",function(a){a.series.disableTooltip||j.data(a).hidden(!1)}),e.dispatch.on(\"elementMouseout.tooltip\",function(a){j.hidden(!0)}),b.dispatch=A,b.lines=e,b.legend=h,b.focus=k,b.xAxis=f,b.x2Axis=k.xAxis,b.yAxis=g,b.y2Axis=k.yAxis,\ b.interactiveLayer=i,b.tooltip=j,b.state=x,b.dispatch=A,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return o},set:function(a){o=a}},height:{get:function(){return p},set:function(a){p=a}},showLegend:{get:function(){return q},set:function(a){q=a}},legendPosition:{get:function(){return r},set:function(a){r=a}},showXAxis:{get:function(){return s},set:function(a){s=a}},showYAxis:{get:function(){return t},set:function(a){t=a}},defaultState:{get:function(){return y},set:function(a){y=a}},noData:{get:function(){return z},set:function(a){z=a}},focusEnable:{get:function(){return w},set:function(a){w=a}},focusHeight:{get:function(){return k.height()},set:function(a){k.height(a)}},focusShowAxisX:{get:function(){return k.showXAxis()},set:function(a){k.showXAxis(a)}},focusShowAxisY:{get:function(){return k.showYAxis()},set:function(a){k.showYAxis(a)}},brushExtent:{get:function(){return k.brushExtent()},set:function(a){k.brushExtent(a)}},focusMargin:{get:function(){return k.margin},set:function(a){void 0!==a.top&&(l.top=a.top,m=a.top),k.margin.right=void 0!==a.right?a.right:k.margin.right,k.margin.bottom=void 0!==a.bottom?a.bottom:k.margin.bottom,k.margin.left=void 0!==a.left?a.left:k.margin.left}},margin:{get:function(){return l},set:function(a){l.top=void 0!==a.top?a.top:l.top,l.right=void 0!==a.right?a.right:l.right,l.bottom=void 0!==a.bottom?a.bottom:l.bottom,l.left=void 0!==a.left?a.left:l.left}},duration:{get:function(){return B},set:function(a){B=a,C.reset(B),e.duration(B),k.duration(B),f.duration(B),g.duration(B)}},color:{get:function(){return n},set:function(b){n=a.utils.getColor(b),h.color(n),e.color(n),k.color(n)}},interpolate:{get:function(){return e.interpolate()},set:function(a){e.interpolate(a),k.interpolate(a)}},xTickFormat:{get:function(){return f.tickFormat()},set:function(a){f.tickFormat(a),k.xTickFormat(a)}},yTickFormat:{get:function(){return g.tickFormat()},set:function(a){g.tickFormat(a),k.yTickFormat(a)}},x:{get:function(){return e.x()},set:function(a){e.x(a),k.x(a)}},\ y:{get:function(){return e.y()},set:function(a){e.y(a),k.y(a)}},rightAlignYAxis:{get:function(){return u},set:function(a){u=a,g.orient(u?\"right\":\"left\")}},useInteractiveGuideline:{get:function(){return v},set:function(a){v=a,v&&(e.interactive(!1),e.useVoronoi(!1))}}}),a.utils.inheritOptions(b,e),a.utils.initOptions(b),b},a.models.lineWithFocusChart=function(){return a.models.lineChart().margin({bottom:30}).focusEnable(!0)},a.models.linePlusBarChart=function(){\"use strict\";function b(v){return v.each(function(v){function K(a){var b=+(\"e\"==a),c=b?1:-1,d=$/3;return\"M\"+.5*c+\",\"+d+\"A6,6 0 0 \"+b+\" \"+6.5*c+\",\"+(d+6)+\"V\"+(2*d-6)+\"A6,6 0 0 \"+b+\" \"+.5*c+\",\"+2*d+\"ZM\"+2.5*c+\",\"+(d+8)+\"V\"+(2*d-8)+\"M\"+4.5*c+\",\"+(d+8)+\"V\"+(2*d-8)}function S(){u.empty()||u.extent(J),na.data([u.empty()?e.domain():J]).each(function(a,b){var c=e(a[0])-e.range()[0],d=e.range()[1]-e(a[1]);d3.select(this).select(\".left\").attr(\"width\",0>c?0:c),d3.select(this).select(\".right\").attr(\"x\",e(a[1])).attr(\"width\",0>d?0:d)})}function T(){J=u.empty()?null:u.extent(),c=u.empty()?e.domain():u.extent(),L.brush({extent:c,brush:u}),S(),l.width(Y).height(Z).color(v.map(function(a,b){return a.color||D(a,b)}).filter(function(a,b){return!v[b].disabled&&v[b].bar})),j.width(Y).height(Z).color(v.map(function(a,b){return a.color||D(a,b)}).filter(function(a,b){return!v[b].disabled&&!v[b].bar}));var b=ga.select(\".nv-focus .nv-barsWrap\").datum(aa.length?aa.map(function(a,b){return{key:a.key,values:a.values.filter(function(a,b){return l.x()(a,b)>=c[0]&&l.x()(a,b)<=c[1]})}}):[{values:[]}]),h=ga.select(\".nv-focus .nv-linesWrap\").datum(W(ba)?[{values:[]}]:ba.filter(function(a){return!a.disabled}).map(function(a,b){return{area:a.area,fillOpacity:a.fillOpacity,strokeWidth:a.strokeWidth,key:a.key,values:a.values.filter(function(a,b){return j.x()(a,b)>=c[0]&&j.x()(a,b)<=c[1]})}}));d=aa.length&&!R?l.xScale():j.xScale(),n.scale(d)._ticks(a.utils.calcTicksX(Y/100,v)).tickSize(-Z,0),n.domain([Math.ceil(c[0]),Math.floor(c[1])]),ga.select(\".nv-x.nv-axis\").transition().duration(M).call(n),b.transition().duration(M).call(l),\ -") +" +) -file(APPEND "${METABENCH_DIR}/nvd3.js" "\ +file(APPEND "${METABENCH_DIR}/nvd3.js" + "\ h.transition().duration(M).call(j),ga.select(\".nv-focus .nv-x.nv-axis\").attr(\"transform\",\"translate(0,\"+f.range()[0]+\")\"),p.scale(f)._ticks(a.utils.calcTicksY(Z/36,v)).tickSize(-Y,0),q.scale(g)._ticks(a.utils.calcTicksY(Z/36,v)),R?q.tickSize(ba.length?0:-Y,0):q.tickSize(aa.length?0:-Y,0);var i=aa.length?1:0,k=ba.length&&!W(ba)?1:0,m=R?k:i,o=R?i:k;ga.select(\".nv-focus .nv-y1.nv-axis\").style(\"opacity\",m),ga.select(\".nv-focus .nv-y2.nv-axis\").style(\"opacity\",o).attr(\"transform\",\"translate(\"+d.range()[1]+\",0)\"),ga.select(\".nv-focus .nv-y1.nv-axis\").transition().duration(M).call(p),ga.select(\".nv-focus .nv-y2.nv-axis\").transition().duration(M).call(q)}var X=d3.select(this);a.utils.initSVG(X);var Y=a.utils.availableWidth(z,X,w),Z=a.utils.availableHeight(A,X,w)-(F?I:0),$=I-y.top-y.bottom;if(b.update=function(){X.transition().duration(M).call(b)},b.container=this,N.setter(V(v),b.update).getter(U(v)).update(),N.disabled=v.map(function(a){return!!a.disabled}),!O){var _;O={};for(_ in N)N[_]instanceof Array?O[_]=N[_].slice(0):O[_]=N[_]}if(!(v&&v.length&&v.filter(function(a){return a.values.length}).length))return a.utils.noData(b,X),b;X.selectAll(\".nv-noData\").remove();var aa=v.filter(function(a){return!a.disabled&&a.bar}),ba=v.filter(function(a){return!a.bar});d=aa.length&&!R?l.xScale():j.xScale(),e=o.scale(),f=R?j.yScale():l.yScale(),g=R?l.yScale():j.yScale(),h=R?k.yScale():m.yScale(),i=R?m.yScale():k.yScale();var ca=v.filter(function(a){return!a.disabled&&(R?!a.bar:a.bar)}).map(function(a){return a.values.map(function(a,b){return{x:B(a,b),y:C(a,b)}})}),da=v.filter(function(a){return!a.disabled&&(R?a.bar:!a.bar)}).map(function(a){return a.values.map(function(a,b){return{x:B(a,b),y:C(a,b)}})});d.range([0,Y]),e.domain(d3.extent(d3.merge(ca.concat(da)),function(a){return a.x})).range([0,Y]);var ea=X.selectAll(\"g.nv-wrap.nv-linePlusBar\").data([v]),fa=ea.enter().append(\"g\").attr(\"class\",\"nvd3 nv-wrap nv-linePlusBar\").append(\"g\"),ga=ea.select(\"g\");fa.append(\"g\").attr(\"class\",\"nv-legendWrap\");var ha=fa.append(\"g\").attr(\"class\",\"nv-focus\");\ ha.append(\"g\").attr(\"class\",\"nv-x nv-axis\"),ha.append(\"g\").attr(\"class\",\"nv-y1 nv-axis\"),ha.append(\"g\").attr(\"class\",\"nv-y2 nv-axis\"),ha.append(\"g\").attr(\"class\",\"nv-barsWrap\"),ha.append(\"g\").attr(\"class\",\"nv-linesWrap\");var ia=fa.append(\"g\").attr(\"class\",\"nv-context\");if(ia.append(\"g\").attr(\"class\",\"nv-x nv-axis\"),ia.append(\"g\").attr(\"class\",\"nv-y1 nv-axis\"),ia.append(\"g\").attr(\"class\",\"nv-y2 nv-axis\"),ia.append(\"g\").attr(\"class\",\"nv-barsWrap\"),ia.append(\"g\").attr(\"class\",\"nv-linesWrap\"),ia.append(\"g\").attr(\"class\",\"nv-brushBackground\"),ia.append(\"g\").attr(\"class\",\"nv-x nv-brush\"),E){var ja=t.align()?Y/2:Y,ka=t.align()?ja:0;t.width(ja),ga.select(\".nv-legendWrap\").datum(v.map(function(a){return a.originalKey=void 0===a.originalKey?a.key:a.originalKey,R?a.key=a.originalKey+(a.bar?Q:P):a.key=a.originalKey+(a.bar?P:Q),a})).call(t),x||t.height()===w.top||(w.top=t.height(),Z=a.utils.availableHeight(A,X,w)-I),ga.select(\".nv-legendWrap\").attr(\"transform\",\"translate(\"+ka+\",\"+-w.top+\")\")}else ga.select(\".nv-legendWrap\").selectAll(\"*\").remove();ea.attr(\"transform\",\"translate(\"+w.left+\",\"+w.top+\")\"),ga.select(\".nv-context\").style(\"display\",F?\"initial\":\"none\"),m.width(Y).height($).color(v.map(function(a,b){return a.color||D(a,b)}).filter(function(a,b){return!v[b].disabled&&v[b].bar})),k.width(Y).height($).color(v.map(function(a,b){return a.color||D(a,b)}).filter(function(a,b){return!v[b].disabled&&!v[b].bar}));var la=ga.select(\".nv-context .nv-barsWrap\").datum(aa.length?aa:[{values:[]}]),ma=ga.select(\".nv-context .nv-linesWrap\").datum(W(ba)?[{values:[]}]:ba.filter(function(a){return!a.disabled}));ga.select(\".nv-context\").attr(\"transform\",\"translate(0,\"+(Z+w.bottom+y.top)+\")\"),la.transition().call(m),ma.transition().call(k),H&&(o._ticks(a.utils.calcTicksX(Y/100,v)).tickSize(-$,0),ga.select(\".nv-context .nv-x.nv-axis\").attr(\"transform\",\"translate(0,\"+h.range()[0]+\")\"),ga.select(\".nv-context .nv-x.nv-axis\").transition().call(o)),G&&(r.scale(h)._ticks($/36).tickSize(-Y,0),s.scale(i)._ticks($/36).tickSize(aa.length?0:-Y,0),ga.select(\".nv-context \ .nv-y3.nv-axis\").style(\"opacity\",aa.length?1:0).attr(\"transform\",\"translate(0,\"+e.range()[0]+\")\"),ga.select(\".nv-context .nv-y2.nv-axis\").style(\"opacity\",ba.length?1:0).attr(\"transform\",\"translate(\"+e.range()[1]+\",0)\"),ga.select(\".nv-context .nv-y1.nv-axis\").transition().call(r),ga.select(\".nv-context .nv-y2.nv-axis\").transition().call(s)),u.x(e).on(\"brush\",T),J&&u.extent(J);var na=ga.select(\".nv-brushBackground\").selectAll(\"g\").data([J||u.extent()]),oa=na.enter().append(\"g\");oa.append(\"rect\").attr(\"class\",\"left\").attr(\"x\",0).attr(\"y\",0).attr(\"height\",$),oa.append(\"rect\").attr(\"class\",\"right\").attr(\"x\",0).attr(\"y\",0).attr(\"height\",$);var pa=ga.select(\".nv-x.nv-brush\").call(u);pa.selectAll(\"rect\").attr(\"height\",$),pa.selectAll(\".resize\").append(\"path\").attr(\"d\",K),t.dispatch.on(\"stateChange\",function(a){for(var c in a)N[c]=a[c];L.stateChange(N),b.update()}),L.on(\"changeState\",function(a){\"undefined\"!=typeof a.disabled&&(v.forEach(function(b,c){b.disabled=a.disabled[c]}),N.disabled=a.disabled),b.update()}),T()}),b}var c,d,e,f,g,h,i,j=a.models.line(),k=a.models.line(),l=a.models.historicalBar(),m=a.models.historicalBar(),n=a.models.axis(),o=a.models.axis(),p=a.models.axis(),q=a.models.axis(),r=a.models.axis(),s=a.models.axis(),t=a.models.legend(),u=d3.svg.brush(),v=a.models.tooltip(),w={top:30,right:30,bottom:30,left:60},x=null,y={top:0,right:30,bottom:20,left:60},z=null,A=null,B=function(a){return a.x},C=function(a){return a.y},D=a.utils.defaultColor(),E=!0,F=!0,G=!1,H=!0,I=50,J=null,K=null,L=d3.dispatch(\"brush\",\"stateChange\",\"changeState\"),M=0,N=a.utils.state(),O=null,P=\" (left axis)\",Q=\" (right axis)\",R=!1;j.clipEdge(!0),k.interactive(!1),k.pointActive(function(a){return!1}),n.orient(\"bottom\").tickPadding(5),p.orient(\"left\"),q.orient(\"right\"),o.orient(\"bottom\").tickPadding(5),r.orient(\"left\"),s.orient(\"right\"),v.headerEnabled(!0).headerFormatter(function(a,b){return n.tickFormat()(a,b)});var S=function(){return R?{main:q,focus:s}:{main:p,focus:r}},T=function(){return R?{main:p,focus:r}:{main:q,focus:s}},U=function(a){return \ @@ -866,9 +862,11 @@ D=C.enter().append(\"g\").attr(\"class\",\"nvd3 nv-wrap nv-ohlcBar\"),E=D.append d[1]]);l[b.key].brush.y(f),v.push(b.key)}if(isNaN(a.values[b.key])||isNaN(parseFloat(a.values[b.key])))return[k(b.key),l[b.key](e)]}return void 0!==U&&(v.length>0||O?(U.style(\"display\",\"inline\"),V.style(\"display\",\"inline\")):(U.style(\"display\",\"none\"),V.style(\"display\",\"none\"))),[k(b.key),l[b.key](a.values[b.key])]}))}function B(a){s.forEach(function(b){var c=l[b.dimension].brush.y().domain();b.hasOnlyNaN&&(b.extent[1]=(l[b.dimension].domain()[1]-c[0])*(b.extent[1]-b.extent[0])/(N[b.dimension]-b.extent[0])+c[0]),b.hasNaN&&(b.extent[0]=c[0]),a&&l[b.dimension].brush.extent(b.extent)}),e.select(\".nv-brushBackground\").each(function(a){d3.select(this).call(l[a.key].brush)}).selectAll(\"rect\").attr(\"x\",-8).attr(\"width\",16),F()}function C(){q===!1&&(q=!0,B(!0))}function D(){$=p.filter(function(a){return!l[a].brush.empty()}),_=$.map(function(a){return l[a].brush.extent()}),s=[],$.forEach(function(a,b){s[b]={dimension:a,extent:_[b],hasNaN:!1,hasOnlyNaN:!1}}),t=[],c.style(\"display\",function(a){var b=$.every(function(b,c){return(isNaN(a.values[b])||isNaN(parseFloat(a.values[b])))&&_[c][0]==l[b].brush.y().domain()[0]?!0:_[c][0]<=a.values[b]&&a.values[b]<=_[c][1]&&!isNaN(parseFloat(a.values[b]))});return b&&t.push(a),b?null:\"none\"}),F(),z.brush({filters:s,active:t})}function E(){var a=$.length>0?!0:!1;s.forEach(function(a){a.extent[0]===l[a.dimension].brush.y().domain()[0]&&v.indexOf(a.dimension)>=0&&(a.hasNaN=!0),a.extent[1]l[a.key].domain()[0]&&(P[a.key]=[c[0].extent[1]]),c[0].extent[0]>=l[a.key].domain()[0]&&P[a.key].push(c[0].extent[0])),d3.select(this).call(y.scale(l[a.key]).tickFormat(a.format).tickValues(P[a.key]))})}function G(a){u[a.key]=this.parentNode.__origin__=k(a.key),d.attr(\"visibility\",\"hidden\")}function H(a){u[a.key]=Math.min(i,Math.max(0,this.parentNode.__origin__+=d3.event.x)),\ c.attr(\"d\",A),o.sort(function(a,b){return J(a.key)-J(b.key)}),o.forEach(function(a,b){return a.currentPosition=b}),k.domain(o.map(function(a){return a.key})),e.attr(\"transform\",function(a){return\"translate(\"+J(a.key)+\")\"})}function I(a,b){delete this.parentNode.__origin__,delete u[a.key],d3.select(this.parentNode).attr(\"transform\",\"translate(\"+k(a.key)+\")\"),c.attr(\"d\",A),d.attr(\"d\",A).attr(\"visibility\",null),z.dimensionsOrder(o)}function J(a){var b=u[a];return null==b?k(a):b}var K=d3.select(this);if(i=a.utils.availableWidth(g,K,f),j=a.utils.availableHeight(h,K,f),a.utils.initSVG(K),void 0===b[0].values){var L=[];b.forEach(function(a){var b={},c=Object.keys(a);c.forEach(function(c){\"name\"!==c&&(b[c]=a[c])}),L.push({key:a.name,values:b})}),b=L}var M=b.map(function(a){return a.values});0===t.length&&(t=b),p=n.sort(function(a,b){return a.currentPosition-b.currentPosition}).map(function(a){return a.key}),o=n.filter(function(a){return!a.disabled}),k.rangePoints([0,i],1).domain(o.map(function(a){return a.key}));var N={},O=!1,P=[];p.forEach(function(a){var b=d3.extent(M,function(b){return+b[a]}),c=b[0],d=b[1],e=!1;(isNaN(c)||isNaN(d))&&(e=!0,c=0,d=0),c===d&&(c-=1,d+=1);var f=s.filter(function(b){return b.dimension==a});0!==f.length&&(e?(c=l[a].domain()[0],d=l[a].domain()[1]):!f[0].hasOnlyNaN&&q?(c=c>f[0].extent[0]?f[0].extent[0]:c,d=d0||!a.utils.arrayEquals(t,aa))&&z.activeChanged(t)}),b}var c,d,e,f={top:30,right:0,bottom:10,left:0},g=null,h=null,i=null,j=null,k=d3.scale.ordinal(),l={},m=\"undefined values\",n=[],o=[],p=[],q=!0,r=a.utils.defaultColor(),s=[],t=[],u=[],v=[],w=1,x=d3.svg.line(),y=d3.svg.axis(),z=d3.dispatch(\"brushstart\",\"brush\",\"brushEnd\",\"dimensionsOrder\",\"stateChange\",\"elementClick\",\"elementMouseover\",\"elementMouseout\",\"elementMousemove\",\"renderEnd\",\"activeChanged\"),A=a.utils.renderWatch(z);return b.dispatch=z,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return g},set:function(a){g=a}},height:{get:function(){return h},set:function(a){h=a}},dimensionData:{get:function(){return n},set:function(a){n=a}},displayBrush:{get:function(){return q},set:function(a){q=a}},filters:{get:function(){return s},set:function(a){s=a}},active:{get:function(){return t},set:function(a){t=a}},lineTension:{get:function(){return w},set:function(a){w=a}},undefinedValuesLabel:{get:function(){return m},set:function(a){m=a}},dimensions:{get:function(){return n.map(function(a){return a.key})},set:function(b){a.deprecated(\"dimensions\",\"use dimensionData instead\"),0===n.length?b.forEach(function(a){n.push({key:a})}):b.forEach(function(a,b){n[b].key=a})}},dimensionNames:{get:function(){return n.map(function(a){return a.key})},set:function(b){a.deprecated(\"dimensionNames\",\"use dimensionData instead\"),p=[],0===n.length?b.forEach(function(a){n.push({key:a})}):b.forEach(function(a,b){n[b].key=a})}},dimensionFormats:{get:function(){return \ n.map(function(a){return a.format})},set:function(b){a.deprecated(\"dimensionFormats\",\"use dimensionData instead\"),0===n.length?b.forEach(function(a){n.push({format:a})}):b.forEach(function(a,b){n[b].format=a})}},margin:{get:function(){return f},set:function(a){f.top=void 0!==a.top?a.top:f.top,f.right=void 0!==a.right?a.right:f.right,f.bottom=void 0!==a.bottom?a.bottom:f.bottom,f.left=void 0!==a.left?a.left:f.left}},color:{get:function(){return r},set:function(b){r=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.parallelCoordinatesChart=function(){\"use strict\";function b(e){return s.reset(),s.models(c),e.each(function(e){var k=d3.select(this);a.utils.initSVG(k);var p=a.utils.availableWidth(h,k,f),q=a.utils.availableHeight(i,k,f);if(b.update=function(){k.call(b)},b.container=this,l.setter(u(m),b.update).getter(t(m)).update(),l.disabled=m.map(function(a){return!!a.disabled}),m=m.map(function(a){return a.disabled=!!a.disabled,a}),m.forEach(function(a,b){a.originalPosition=isNaN(a.originalPosition)?b:a.originalPosition,a.currentPosition=isNaN(a.currentPosition)?b:a.currentPosition}),!o){var s;o={};for(s in l)l[s]instanceof Array?o[s]=l[s].slice(0):o[s]=l[s]}if(!e||!e.length)return a.utils.noData(b,k),b;k.selectAll(\".nv-noData\").remove();var v=k.selectAll(\"g.nv-wrap.nv-parallelCoordinatesChart\").data([e]),w=v.enter().append(\"g\").attr(\"class\",\"nvd3 nv-wrap nv-parallelCoordinatesChart\").append(\"g\"),x=v.select(\"g\");w.append(\"g\").attr(\"class\",\"nv-parallelCoordinatesWrap\"),w.append(\"g\").attr(\"class\",\"nv-legendWrap\"),x.select(\"rect\").attr(\"width\",p).attr(\"height\",q>0?q:0),j?(d.width(p).color(function(a){return\"rgb(188,190,192)\"}),x.select(\".nv-legendWrap\").datum(m.sort(function(a,b){return a.originalPosition-b.originalPosition})).call(d),g||d.height()===f.top||(f.top=d.height(),q=a.utils.availableHeight(i,k,f)),v.select(\".nv-legendWrap\").attr(\"transform\",\"translate( 0 ,\"+-f.top+\")\")):x.select(\".nv-legendWrap\").selectAll(\"*\").remove(),v.attr(\"transform\",\"translate(\"+f.left+\",\"+f.top+\")\"),c.width(p).height(q).dimensionData(m).displayBrush(n);\ var y=x.select(\".nv-parallelCoordinatesWrap \").datum(e);y.transition().call(c),c.dispatch.on(\"brushEnd\",function(a,b){b?(n=!0,r.brushEnd(a)):n=!1}),d.dispatch.on(\"stateChange\",function(a){for(var c in a)l[c]=a[c];r.stateChange(l),b.update()}),c.dispatch.on(\"dimensionsOrder\",function(a){m.sort(function(a,b){return a.currentPosition-b.currentPosition});var b=!1;m.forEach(function(a,c){a.currentPosition=c,a.currentPosition!==a.originalPosition&&(b=!0)}),r.dimensionsOrder(m,b)}),r.on(\"changeState\",function(a){\"undefined\"!=typeof a.disabled&&(m.forEach(function(b,c){b.disabled=a.disabled[c]}),l.disabled=a.disabled),b.update()})}),s.renderEnd(\"parraleleCoordinateChart immediate\"),b}var c=a.models.parallelCoordinates(),d=a.models.legend(),e=a.models.tooltip(),f=(a.models.tooltip(),{top:0,right:0,bottom:0,left:0}),g=null,h=null,i=null,j=!0,k=a.utils.defaultColor(),l=a.utils.state(),m=[],n=!0,o=null,p=null,q=\"undefined\",r=d3.dispatch(\"dimensionsOrder\",\"brushEnd\",\"stateChange\",\"changeState\",\"renderEnd\"),s=a.utils.renderWatch(r),t=function(a){return function(){return{active:a.map(function(a){return!a.disabled})}}},u=function(a){return function(b){void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return e.contentGenerator(function(a){var b='\";return 0!==a.series.length&&(b+='',a.series.forEach(function(a){b=b+'\"}),b+=\"\"),b+=\"
'+a.key+\"
'+a.key+''+a.value+\"
\"}),c.dispatch.on(\"elementMouseover.tooltip\",function(a){var b={key:a.label,color:a.color,series:[]};a.values&&(Object.keys(a.values).forEach(function(c){var d=a.dimensions.filter(function(a){return a.key===c})[0];if(d){var e;e=isNaN(a.values[c])||isNaN(parseFloat(a.values[c]))?q:d.format(a.values[c]),b.series.push({idx:d.currentPosition,\ @@ -906,7 +904,8 @@ a.models.sunburst=function(){\"use strict\";function b(a){var b=c(a);return b>90 \"nvd3 nv-wrap nv-sunburst nv-chart-\"+u).attr(\"transform\",\"translate(\"+(m/2+p.left+p.right)+\",\"+(n/2+p.top+p.bottom)+\")\"),v.on(\"click\",function(a,b){E.chartClick({data:a,index:b,pos:d3.event,id:u})}),H.value(t[s]||t.count);var k=H.nodes(f[0]).reverse();i(k);var l=h.selectAll(\".arc-container\").data(k,B),z=l.enter().append(\"g\").attr(\"class\",\"arc-container\");z.append(\"path\").attr(\"d\",J).style(\"fill\",function(a){return a.color?a.color:w(C?(a.children?a:a.parent).name:a.name)}).style(\"stroke\",\"#FFF\").on(\"click\",function(a,b){j(a),E.elementClick({data:a,index:b})}).on(\"mouseover\",function(a,b){d3.select(this).classed(\"hover\",!0).style(\"opacity\",.8),E.elementMouseover({data:a,color:d3.select(this).style(\"fill\"),percent:d(a)})}).on(\"mouseout\",function(a,b){d3.select(this).classed(\"hover\",!1).style(\"opacity\",1),E.elementMouseout({data:a})}).on(\"mousemove\",function(a,b){E.elementMousemove({data:a})}),l.each(function(a){d3.select(this).select(\"path\").transition().duration(D).attrTween(\"d\",g)}),x&&(l.selectAll(\"text\").remove(),l.append(\"text\").text(function(a){return y(a)}).transition().duration(D).attr(\"opacity\",function(a){return e(a)?1:0}).attr(\"transform\",function(a){var d=this.getBBox().width;if(0===a.depth)return\"rotate(0)translate(\"+d/2*-1+\",0)\";var e=c(a),f=b(a);return 0===f?\"rotate(\"+e+\")translate(\"+(G(a.y)+5)+\",0)\":\"rotate(\"+e+\")translate(\"+(G(a.y)+d+5)+\",0)rotate(\"+f+\")\"})),j(k[k.length-1]),l.exit().transition().duration(D).attr(\"opacity\",0).each(\"end\",function(a){var b=B(a);I[b]=void 0}).remove()}),K.renderEnd(\"sunburst immediate\"),k}var l,m,n,o,p={top:0,right:0,bottom:0,left:0},q=600,r=600,s=\"count\",t={count:function(a){return 1},value:function(a){return a.value||a.size},size:function(a){return a.value||a.size}},u=Math.floor(1e4*Math.random()),v=null,w=a.utils.defaultColor(),x=!1,y=function(a){return\"count\"===s?a.name+\" #\"+a.value:a.name+\" \"+(a.value||a.size)},z=.02,A=function(a,b){return a.name>b.name},B=function(a,b){return a.name},C=!0,D=500,E=d3.dispatch(\"chartClick\",\"elementClick\",\"elementDblClick\",\"elementMousemove\",\ \"elementMouseover\",\"elementMouseout\",\"renderEnd\"),F=d3.scale.linear().range([0,2*Math.PI]),G=d3.scale.sqrt(),H=d3.layout.partition().sort(A),I={},J=d3.svg.arc().startAngle(function(a){return Math.max(0,Math.min(2*Math.PI,F(a.x)))}).endAngle(function(a){return Math.max(0,Math.min(2*Math.PI,F(a.x+a.dx)))}).innerRadius(function(a){return Math.max(0,G(a.y))}).outerRadius(function(a){return Math.max(0,G(a.y+a.dy))}),K=a.utils.renderWatch(E);return k.dispatch=E,k.options=a.utils.optionsFunc.bind(k),k._options=Object.create({},{width:{get:function(){return q},set:function(a){q=a}},height:{get:function(){return r},set:function(a){r=a}},mode:{get:function(){return s},set:function(a){s=a}},id:{get:function(){return u},set:function(a){u=a}},duration:{get:function(){return D},set:function(a){D=a}},groupColorByParent:{get:function(){return C},set:function(a){C=!!a}},showLabels:{get:function(){return x},set:function(a){x=!!a}},labelFormat:{get:function(){return y},set:function(a){y=a}},labelThreshold:{get:function(){return z},set:function(a){z=a}},sort:{get:function(){return A},set:function(a){A=a}},key:{get:function(){return B},set:function(a){B=a}},margin:{get:function(){return p},set:function(a){p.top=void 0!=a.top?a.top:p.top,p.right=void 0!=a.right?a.right:p.right,p.bottom=void 0!=a.bottom?a.bottom:p.bottom,p.left=void 0!=a.left?a.left:p.left}},color:{get:function(){return w},set:function(b){w=a.utils.getColor(b)}}}),a.utils.initOptions(k),k},a.models.sunburstChart=function(){\"use strict\";function b(d){return n.reset(),n.models(c),d.each(function(d){var h=d3.select(this);a.utils.initSVG(h);var i=a.utils.availableWidth(f,h,e),j=a.utils.availableHeight(g,h,e);return b.update=function(){0===l?h.call(b):h.transition().duration(l).call(b)},b.container=h,d&&d.length?(h.selectAll(\".nv-noData\").remove(),c.width(i).height(j).margin(e),void h.call(c)):(a.utils.noData(b,h),b)}),n.renderEnd(\"sunburstChart immediate\"),b}var c=a.models.sunburst(),d=a.models.tooltip(),e={top:30,right:20,bottom:20,left:20},f=null,g=null,h=a.utils.defaultColor(),\ i=!1,j=(Math.round(1e5*Math.random()),null),k=null,l=250,m=d3.dispatch(\"stateChange\",\"changeState\",\"renderEnd\"),n=a.utils.renderWatch(m);return d.duration(0).headerEnabled(!1).valueFormatter(function(a){return a}),c.dispatch.on(\"elementMouseover.tooltip\",function(a){a.series={key:a.data.name,value:a.data.value||a.data.size,color:a.color,percent:a.percent},i||(delete a.percent,delete a.series.percent),d.data(a).hidden(!1)}),c.dispatch.on(\"elementMouseout.tooltip\",function(a){d.hidden(!0)}),c.dispatch.on(\"elementMousemove.tooltip\",function(a){d()}),b.dispatch=m,b.sunburst=c,b.tooltip=d,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{noData:{get:function(){return k},set:function(a){k=a}},defaultState:{get:function(){return j},set:function(a){j=a}},showTooltipPercent:{get:function(){return i},set:function(a){i=a}},color:{get:function(){return h},set:function(a){h=a,c.color(h)}},duration:{get:function(){return l},set:function(a){l=a,n.reset(l),c.duration(l)}},margin:{get:function(){return e},set:function(a){e.top=void 0!==a.top?a.top:e.top,e.right=void 0!==a.right?a.right:e.right,e.bottom=void 0!==a.bottom?a.bottom:e.bottom,e.left=void 0!==a.left?a.left:e.left,c.margin(e)}}}),a.utils.inheritOptions(b,c),a.utils.initOptions(b),b},a.version=\"1.8.5\"}();\ -") +" +) ################################################################################ # end nvd3.js ################################################################################ @@ -919,7 +918,8 @@ i=!1,j=(Math.round(1e5*Math.random()),null),k=null,l=250,m=d3.dispatch(\"stateCh # parsing too long strings. # https://github.com/mbostock/d3 ################################################################################ -file(WRITE "${METABENCH_DIR}/d3.js" "\ +file(WRITE "${METABENCH_DIR}/d3.js" + "\ !function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:NaN}function r(n){return null===n?NaN:+n}function i(n){return!isNaN(n)}function u(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)<0?r=u+1:i=u}return r},right:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)>0?i=u:r=u+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function l(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function c(){this._=Object.create(null)}function f(n){return(n+=\"\")===bo||n[0]===_o?_o+n:n}function s(n){return(n+=\"\")[0]===_o?n.slice(1):n}function h(n){return f(n)in this._}function p(n){return(n=f(n))in this._&&delete this._[n]}function g(){var n=[];for(var t in this._)n.push(s(t));return n}function v(){var n=0;for(var t in this._)++n;return n}function d(){for(var n in this._)return!1;return!0}function y(){this._=Object.create(null)}function m(n){return n}function M(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function x(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=wo.length;r>e;++e){var i=wo[e]+t;if(i in n)return i}}function b(){}function _(){}function w(n){function t(){for(var t,r=e,i=-1,u=r.length;++ie;e++)for(var i,u=n[e],o=0,a=u.length;a>o;o++)(i=u[o])&&t(i,o,e);return n}function Z(n){return ko(n,qo),n}function V(n){var t,e;return function(r,i,u){var o,a=n[u].update,l=a.length;for(u!=e&&(e=u,t=0),i>=t&&(t=i+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var c=To.get(n);return c&&(n=c,l=B),a?t?i:r:t?b:u}function $(n,t){return function(e){var r=ao.event;ao.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ao.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=\".dragsuppress-\"+ ++Do,i=\"click\"+r,u=ao.select(t(e)).on(\"touchmove\"+r,S).on(\"dragstart\"+r,S).on(\"selectstart\"+r,S);if(null==Ro&&(Ro=\"onselectstart\"in e?!1:x(e.style,\"userSelect\")),Ro){var o=n(e).style,a=o[Ro];o[Ro]=\"none\"}return function(n){if(u.on(r,null),Ro&&(o[Ro]=a),n){var t=function(){u.on(i,null)};u.on(i,function(){S(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Po){var u=t(n);if(u.scrollX||u.scrollY){r=ao.select(\"body\").append(\"svg\").style({position:\"absolute\",top:0,left:0,margin:0,padding:0,border:\"none\"},\"important\");var o=r[0][0].getScreenCTM();Po=!(o.f||o.e),r.remove()}}return Po?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,\ @@ -958,9 +958,11 @@ ao={version:\"3.5.17\"},lo=[].slice,co=function(n){return lo.call(n)},fo=this.do t){var u,o=[],a=n.length,l=-1;if(1===arguments.length)for(;++l1?l/(f-1):void 0},ao.deviation=function(){var n=ao.variance.apply(this,arguments);return n?Math.sqrt(n):n};var Mo=u(e);ao.bisectLeft=Mo.left,ao.bisect=ao.bisectRight=Mo.right,ao.bisector=function(n){return u(1===n.length?function(t,r){return e(n(t),r)}:n)},ao.shuffle=function(n,t,e){(u=arguments.length)<3&&(e=n.length,2>u&&(t=0));for(var r,i,u=e-t;u;)i=Math.random()*u--|0,r=n[u+t],n[u+t]=n[i+t],n[i+t]=r;return n},ao.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ao.pairs=function(n){for(var t,e=0,r=n.length-1,i=n[0],u=new Array(0>r?0:r);r>e;)u[e]=[t=i,i=n[++e]];return u},ao.transpose=function(n){if(!(i=n.length))return[];for(var t=-1,e=ao.min(n,o),r=new Array(e);++t=0;)for(r=n[i],t=r.length;--t>=0;)e[--o]=r[t];return e};var xo=Math.abs;ao.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error(\"infinite range\");var r,i=[],u=a(xo(e)),o=-1;if(n*=u,t*=u,e*=u,0>e)for(;(r=n+e*++o)>t;)i.push(r/u);else for(;(r=n+e*++o)=u.length)return r?r.call(i,o):e?o.sort(e):o;for(var l,f,s,h,p=-1,g=o.length,v=u[a++],d=new c;++p=u.length)return n;var r=[],i=o[e++];return n.forEach(function(n,i){r.push({key:n,values:t(i,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var e,r,i={},u=[],o=[];return i.map=function(t,e){return n(e,t,0)},i.entries=function(e){return t(n(ao.map,e,0),0)},i.key=function(n){return u.push(n),i},i.sortKeys=function(n){return o[u.length-1]=n,i},i.sortValues=function(n){return e=n,i},i.rollup=function(n){return r=n,i},i},ao.set=function(n){var t=new y;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},l(y,{has:h,add:function(n){return this._[f(n+=\"\")]=!0,n},remove:p,values:g,size:v,empty:d,forEach:function(n){for(var t in this._)n.call(this,s(t))}}),ao.behavior={},ao.rebind=function(n,t){for(var e,r=1,i=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ao.event=null,ao.requote=function(n){return \ n.replace(So,\"\\\\$&\")};var So=/[\\\\\\^\\$\\*\\+\\?\\|\\[\\]\\(\\)\\.\\{\\}]/g,ko={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},No=function(n,t){return t.querySelector(n)},Eo=function(n,t){return t.querySelectorAll(n)},Ao=function(n,t){var e=n.matches||n[x(n,\"matchesSelector\")];return(Ao=function(n,t){return e.call(n,t)})(n,t)};\"function\"==typeof Sizzle&&(No=function(n,t){return Sizzle(n,t)[0]||null},Eo=Sizzle,Ao=Sizzle.matchesSelector),ao.selection=function(){return ao.select(fo.documentElement)};var Co=ao.selection.prototype=[];Co.select=function(n){var t,e,r,i,u=[];n=A(n);for(var o=-1,a=this.length;++o=0&&\"xmlns\"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),Lo.hasOwnProperty(e)?{space:Lo[e],local:n}:n}},Co.attr=function(n,t){if(arguments.length<2){if(\"string\"==typeof n){var e=this.node();return n=ao.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(z(t,n[t]));return this}return this.each(z(n,t))},Co.classed=function(n,t){if(arguments.length<2){if(\"string\"==typeof n){var e=this.node(),r=(n=T(n)).length,i=-1;if(t=e.classList){for(;++ii){if(\"string\"!=typeof n){2>i&&(e=\"\");\ -") +" +) -file(APPEND "${METABENCH_DIR}/d3.js" "\ +file(APPEND "${METABENCH_DIR}/d3.js" + "\ for(r in n)this.each(P(r,n[r],e));return this}if(2>i){var u=this.node();return t(u).getComputedStyle(u,null).getPropertyValue(n)}r=\"\"}return this.each(P(n,e,r))},Co.property=function(n,t){if(arguments.length<2){if(\"string\"==typeof n)return this.node()[n];for(t in n)this.each(U(t,n[t]));return this}return this.each(U(n,t))},Co.text=function(n){return arguments.length?this.each(\"function\"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?\"\":t}:null==n?function(){this.textContent=\"\"}:function(){this.textContent=n}):this.node().textContent},Co.html=function(n){return arguments.length?this.each(\"function\"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?\"\":t}:null==n?function(){this.innerHTML=\"\"}:function(){this.innerHTML=n}):this.node().innerHTML},Co.append=function(n){return n=j(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},Co.insert=function(n,t){return n=j(n),t=A(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},Co.remove=function(){return this.each(F)},Co.data=function(n,t){function e(n,e){var r,i,u,o=n.length,s=e.length,h=Math.min(o,s),p=new Array(s),g=new Array(s),v=new Array(o);if(t){var d,y=new c,m=new Array(o);for(r=-1;++rr;++r)g[r]=H(e[r]);for(;o>r;++r)v[r]=n[r]}g.update=p,g.parentNode=p.parentNode=v.parentNode=n.parentNode,a.push(g),l.push(p),f.push(v)}var r,i,u=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++uu;u++){i.push(t=[]),t.parentNode=(e=this[u]).parentNode;for(var a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,u)&&t.push(r)}return E(i)},Co.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},Co.sort=function(n){n=I.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null},Co.size=function(){var n=0;return Y(this,function(){++n}),n};var qo=[];ao.selection.enter=Z,ao.selection.enter.prototype=qo,qo.append=Co.append,qo.empty=Co.empty,qo.node=Co.node,qo.call=Co.call,qo.size=Co.size,qo.select=function(n){for(var t,e,r,i,u,o=[],a=-1,l=this.length;++ar){if(\"string\"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()[\"__on\"+n])&&r._;e=!1}return this.each(X(n,t,e))};var To=ao.map({mouseenter:\"mouseover\",\ mouseleave:\"mouseout\"});fo&&To.forEach(function(n){\"on\"+n in fo&&To.remove(n)});var Ro,Do=0;ao.mouse=function(n){return J(n,k())};var Po=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ao.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=k().changedTouches),t)for(var r,i=0,u=t.length;u>i;++i)if((r=t[i]).identifier===e)return J(n,r)},ao.behavior.drag=function(){function n(){this.on(\"mousedown.drag\",u).on(\"touchstart.drag\",o)}function e(n,t,e,u,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],g|=n|e,M=r,p({type:\"drag\",x:r[0]+c[0],y:r[1]+c[1],dx:n,dy:e}))}function l(){t(h,v)&&(y.on(u+d,null).on(o+d,null),m(g),p({type:\"dragend\"}))}var c,f=this,s=ao.event.target.correspondingElement||ao.event.target,h=f.parentNode,p=r.of(f,arguments),g=0,v=n(),d=\".drag\"+(null==v?\"\":\"-\"+v),y=ao.select(e(s)).on(u+d,a).on(o+d,l),m=W(s),M=t(h,v);i?(c=i.apply(f,arguments),c=[c.x-M[0],c.y-M[1]]):c=[0,0],p({type:\"dragstart\"})}}var r=N(n,\"drag\",\"dragstart\",\"dragend\"),i=null,u=e(b,ao.mouse,t,\"mousemove\",\"mouseup\"),o=e(G,ao.touch,m,\"touchmove\",\"touchend\");return n.origin=function(t){return arguments.length?(i=t,n):i},ao.rebind(n,r,\"on\")},ao.touches=function(n,t){return arguments.length<2&&(t=k().touches),t?co(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier,e}):[]};var Uo=1e-6,jo=Uo*Uo,Fo=Math.PI,Ho=2*Fo,Oo=Ho-Uo,Io=Fo/2,Yo=Fo/180,Zo=180/Fo,Vo=Math.SQRT2,Xo=2,$o=4;ao.interpolateZoom=function(n,t){var e,r,i=n[0],u=n[1],o=n[2],a=t[0],l=t[1],c=t[2],f=a-i,s=l-u,h=f*f+s*s;if(jo>h)r=Math.log(c/o)/Vo,e=function(n){return[i+n*f,u+n*s,o*Math.exp(Vo*n*r)]};else{var p=Math.sqrt(h),g=(c*c-o*o+$o*h)/(2*o*Xo*p),v=(c*c-o*o-$o*h)/(2*c*Xo*p),d=Math.log(Math.sqrt(g*g+1)-g),y=Math.log(Math.sqrt(v*v+1)-v);r=(y-d)/Vo,e=function(n){var t=n*r,e=rn(d),a=o/(Xo*p)*(e*un(Vo*t+d)-en(d));return[i+a*f,u+a*s,o*e/rn(Vo*t+d)]}}return e.duration=1e3*r,e},ao.behavior.zoom=function(){function n(n){n.on(L,s).on(Wo+\".zoom\",p).on(\"dblclick.zoom\",g).on(R,h)}function e(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function r(n){return[n[0]*k.k+k.x,\ @@ -999,7 +1001,8 @@ function(n){return/^[ns]/.test(n)?-3:null}).attr(\"width\",6).attr(\"height\",6) d).on(\"mouseup.brush\",m),k.interrupt().selectAll(\"*\").interrupt(),C)L[0]=s[0]-L[0],L[1]=h[0]-L[1];else if(N){var T=+/w$/.test(N),R=+/^n/.test(N);x=[s[1-T]-L[0],h[1-R]-L[1]],L[0]=s[T],L[1]=h[R]}else ao.event.altKey&&(M=L.slice());k.style(\"pointer-events\",\"none\").selectAll(\".resize\").style(\"display\",null),ao.select(\"body\").style(\"cursor\",_.style(\"cursor\")),w({type:\"brushstart\"}),d()}var o,a,l=N(n,\"brushstart\",\"brush\",\"brushend\"),c=null,f=null,s=[0,0],h=[0,0],p=!0,g=!0,v=Bl[0];return n.event=function(n){n.each(function(){var n=l.of(this,arguments),t={x:s,y:h,i:o,j:a},e=this.__chart__||t;this.__chart__=t,Hl?ao.select(this).transition().each(\"start.brush\",function(){o=e.i,a=e.j,s=e.x,h=e.y,n({type:\"brushstart\"})}).tween(\"brush:brush\",function(){var e=xr(s,t.x),r=xr(h,t.y);return o=a=null,function(i){s=t.x=e(i),h=t.y=r(i),n({type:\"brush\",mode:\"resize\"})}}).each(\"end.brush\",function(){o=t.i,a=t.j,n({type:\"brush\",mode:\"resize\"}),n({type:\"brushend\"})}):(n({type:\"brushstart\"}),n({type:\"brush\",mode:\"resize\"}),n({type:\"brushend\"}))})},n.x=function(t){return arguments.length?(c=t,v=Bl[!c<<1|!f],n):c},n.y=function(t){return arguments.length?(f=t,v=Bl[!c<<1|!f],n):f},n.clamp=function(t){return arguments.length?(c&&f?(p=!!t[0],g=!!t[1]):c?p=!!t:f&&(g=!!t),n):c&&f?[p,g]:c?p:f?g:null},n.extent=function(t){var e,r,i,u,l;return arguments.length?(c&&(e=t[0],r=t[1],f&&(e=e[0],r=r[0]),o=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(l=e,e=r,r=l),e==s[0]&&r==s[1]||(s=[e,r])),f&&(i=t[0],u=t[1],c&&(i=i[1],u=u[1]),a=[i,u],f.invert&&(i=f(i),u=f(u)),i>u&&(l=i,i=u,u=l),i==h[0]&&u==h[1]||(h=[i,u])),n):(c&&(o?(e=o[0],r=o[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(l=e,e=r,r=l))),f&&(a?(i=a[0],u=a[1]):(i=h[0],u=h[1],f.invert&&(i=f.invert(i),u=f.invert(u)),i>u&&(l=i,i=u,u=l))),c&&f?[[e,i],[r,u]]:c?[e,r]:f&&[i,u])},n.clear=function(){return n.empty()||(s=[0,0],h=[0,0],o=a=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!f&&h[0]==h[1]},ao.rebind(n,l,\"on\")};var $l={n:\"ns-resize\",e:\"ew-resize\",s:\"ns-resize\",w:\"ew-resize\",nw:\"nwse-resize\",\ ne:\"nesw-resize\",se:\"nwse-resize\",sw:\"nesw-resize\"},Bl=[[\"n\",\"e\",\"s\",\"w\",\"nw\",\"ne\",\"se\",\"sw\"],[\"e\",\"w\"],[\"n\",\"s\"],[]],Wl=ga.format=xa.timeFormat,Jl=Wl.utc,Gl=Jl(\"%Y-%m-%dT%H:%M:%S.%LZ\");Wl.iso=Date.prototype.toISOString&&+new Date(\"2000-01-01T00:00:00.000Z\")?eo:Gl,eo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},eo.toString=Gl.toString,ga.second=On(function(n){return new va(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),ga.seconds=ga.second.range,ga.seconds.utc=ga.second.utc.range,ga.minute=On(function(n){return new va(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),ga.minutes=ga.minute.range,ga.minutes.utc=ga.minute.utc.range,ga.hour=On(function(n){var t=n.getTimezoneOffset()/60;return new va(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),ga.hours=ga.hour.range,ga.hours.utc=ga.hour.utc.range,ga.month=On(function(n){return n=ga.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),ga.months=ga.month.range,ga.months.utc=ga.month.utc.range;var Kl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ql=[[ga.second,1],[ga.second,5],[ga.second,15],[ga.second,30],[ga.minute,1],[ga.minute,5],[ga.minute,15],[ga.minute,30],[ga.hour,1],[ga.hour,3],[ga.hour,6],[ga.hour,12],[ga.day,1],[ga.day,2],[ga.week,1],[ga.month,1],[ga.month,3],[ga.year,1]],nc=Wl.multi([[\".%L\",function(n){return n.getMilliseconds()}],[\":%S\",function(n){return n.getSeconds()}],[\"%I:%M\",function(n){return n.getMinutes()}],[\"%I %p\",function(n){return n.getHours()}],[\"%a %d\",function(n){return n.getDay()&&1!=n.getDate()}],[\"%b %d\",function(n){return 1!=n.getDate()}],[\"%B\",function(n){return n.getMonth()}],[\"%Y\",zt]]),tc={range:function(n,t,e){return ao.range(Math.ceil(n/e)*e,+t,e).map(io)},floor:m,ceil:m};Ql.year=ga.year,ga.scale=function(){return \ ro(ao.scale.linear(),Ql,nc)};var ec=Ql.map(function(n){return[n[0].utc,n[1]]}),rc=Jl.multi([[\".%L\",function(n){return n.getUTCMilliseconds()}],[\":%S\",function(n){return n.getUTCSeconds()}],[\"%I:%M\",function(n){return n.getUTCMinutes()}],[\"%I %p\",function(n){return n.getUTCHours()}],[\"%a %d\",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],[\"%b %d\",function(n){return 1!=n.getUTCDate()}],[\"%B\",function(n){return n.getUTCMonth()}],[\"%Y\",zt]]);ec.year=ga.year.utc,ga.scale.utc=function(){return ro(ao.scale.linear(),ec,rc)},ao.text=An(function(n){return n.responseText}),ao.json=function(n,t){return Cn(n,\"application/json\",uo,t)},ao.html=function(n,t){return Cn(n,\"text/html\",oo,t)},ao.xml=An(function(n){return n.responseXML}),\"function\"==typeof define&&define.amd?(this.d3=ao,define(ao)):\"object\"==typeof module&&module.exports?module.exports=ao:this.d3=ao}(); -") +" +) ################################################################################ # end d3.js ################################################################################ diff --git a/cmake/modern_project_structure.cmake b/cmake/modern_project_structure.cmake index a24a7c96..3accf45e 100644 --- a/cmake/modern_project_structure.cmake +++ b/cmake/modern_project_structure.cmake @@ -23,9 +23,11 @@ cmake_minimum_required(VERSION 3.4) function(ensure_entry_point) - if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - message(FATAL_ERROR "'${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt' is meant to be used only " - "as a CMake entry point and should not be included from other CMake files. " - "Include '${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt' directly instead.") - endif() + if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + message(FATAL_ERROR + "'${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt' is meant to be used only " + "as a CMake entry point and should not be included from other CMake files. " + "Include '${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt' directly instead." + ) + endif() endfunction() diff --git a/cmake/warnings.cmake b/cmake/warnings.cmake index 25ad0d1e..76428a23 100644 --- a/cmake/warnings.cmake +++ b/cmake/warnings.cmake @@ -70,9 +70,7 @@ macro(_set_flags) -Wformat=2 # warn on security issues around functions that format output (ie printf) ) - set(CLANG_WARNINGS - ${GCC_COMMON_WARNINGS} - ) + set(CLANG_WARNINGS ${GCC_COMMON_WARNINGS}) set(GCC_WARNINGS ${GCC_COMMON_WARNINGS} diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 78d964bf..657bbdd5 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -44,17 +44,13 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/_static/img/downcast_1.png" "${CMAKE_CURRENT_SOURCE_DIR}/_static/img/downcast_2.png" "${CMAKE_CURRENT_SOURCE_DIR}/_static/img/units.svg" - "${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG.md" - "${CMAKE_CURRENT_SOURCE_DIR}/design.rst" "${CMAKE_CURRENT_SOURCE_DIR}/design/directories.rst" "${CMAKE_CURRENT_SOURCE_DIR}/design/downcasting.rst" "${CMAKE_CURRENT_SOURCE_DIR}/design/quantity.rst" "${CMAKE_CURRENT_SOURCE_DIR}/design/quantity_kind.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/examples.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/examples/basics.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/basics/avg_speed.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/basics/box_example.rst" @@ -66,17 +62,13 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/examples/basics/hello_units.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/basics/total_energy.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/basics/unknown_dimension.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_representation.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_representation/linear_algebra.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_representation/measurement.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_systems.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_systems/custom_systems.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_utilities.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_utilities/conversion_factor.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/examples/kalman_filter.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/kalman_filter/example_1.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/kalman_filter/example_2.rst" @@ -87,9 +79,7 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/examples/kalman_filter/example_7.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/kalman_filter/example_8.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/kalman_filter/kalman.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/faq.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/framework.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/arithmetics.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/basic_concepts.rst" @@ -101,18 +91,16 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/framework/quantity_points.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/text_output.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/units.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/genindex.rst" "${CMAKE_CURRENT_SOURCE_DIR}/glossary.rst" "${CMAKE_CURRENT_SOURCE_DIR}/index.rst" "${CMAKE_CURRENT_SOURCE_DIR}/introduction.rst" "${CMAKE_CURRENT_SOURCE_DIR}/quick_start.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/core.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/concepts.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/customization_points.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/downcasting.rst" -# "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/functions.rst" + # "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/functions.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/metafunctions.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/types.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/types/dimensions.rst" @@ -128,26 +116,20 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/types/utilities/basic_fixed_string.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/types/utilities/basic_symbol_text.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/core/types/utilities/ratio.rst" - -# "${CMAKE_CURRENT_SOURCE_DIR}/reference/math.rst" + # "${CMAKE_CURRENT_SOURCE_DIR}/reference/math.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/random.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/angle.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/dimensionless.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/unknown.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/binary_prefixes.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/modulation_rate.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/storage_capacity.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/traffic_intensity.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/transfer_rate.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/acceleration.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/constants.rst" @@ -159,7 +141,6 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/speed.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/time.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/units.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_cgs.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/length.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/acceleration.rst" @@ -172,9 +153,7 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/pressure.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/speed.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/time.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/dimensions_and_concepts.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_fps.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/length.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/acceleration.rst" @@ -189,19 +168,15 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/speed.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/time.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/volume.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_iau.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/iau/length.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_imperial.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/imperial/length.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_international.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/international/area.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/international/length.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/international/speed.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/international/volume.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/absorbed_dose.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/acceleration.rst" @@ -245,15 +220,11 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/time.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/voltage.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/volume.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_typographic.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/typographic/length.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_uscs.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/uscs/length.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/references.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/use_cases.rst" "${CMAKE_CURRENT_SOURCE_DIR}/use_cases/custom_representation_types.rst" "${CMAKE_CURRENT_SOURCE_DIR}/use_cases/extensions.rst" @@ -262,14 +233,14 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/use_cases/linear_algebra.rst" "${CMAKE_CURRENT_SOURCE_DIR}/use_cases/natural_units.rst" "${CMAKE_CURRENT_SOURCE_DIR}/use_cases/unknown_dimensions.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/usage.rst" ) include(documentation) include(GNUInstallDirs) -add_documentation(documentation ALL +add_documentation( + documentation ALL BREATHE_PROJECT mp-units CODE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src" INSTALL_DIR ${CMAKE_INSTALL_DOCDIR} @@ -277,6 +248,7 @@ add_documentation(documentation ALL DOCS_DEPENDS ${unitsSphinxDocs} ) -add_custom_command(TARGET documentation POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/_static/img/*.svg ${CMAKE_CURRENT_BINARY_DIR}/sphinx/_images +add_custom_command( + TARGET documentation POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/_static/img/*.svg + ${CMAKE_CURRENT_BINARY_DIR}/sphinx/_images ) diff --git a/example/aliases/CMakeLists.txt b/example/aliases/CMakeLists.txt index 27f4a246..ba27ce60 100644 --- a/example/aliases/CMakeLists.txt +++ b/example/aliases/CMakeLists.txt @@ -28,16 +28,23 @@ cmake_minimum_required(VERSION 3.2) function(add_example target) add_executable(${target}-aliases ${target}.cpp) target_link_libraries(${target}-aliases PRIVATE ${ARGN}) - target_compile_definitions(${target}-aliases PRIVATE - ${projectPrefix}NO_LITERALS - ${projectPrefix}NO_REFERENCES - ) + target_compile_definitions(${target}-aliases PRIVATE ${projectPrefix}NO_LITERALS ${projectPrefix}NO_REFERENCES) endfunction() add_example(avg_speed mp-units::core-io mp-units::si mp-units::si-cgs mp-units::si-international) add_example(box_example mp-units::core-fmt mp-units::si) add_example(capacitor_time_curve mp-units::core-io mp-units::si) -add_example(clcpp_response mp-units::core-fmt mp-units::core-io mp-units::si mp-units::si-iau mp-units::si-imperial mp-units::si-international mp-units::si-typographic mp-units::si-uscs) +add_example( + clcpp_response + mp-units::core-fmt + mp-units::core-io + mp-units::si + mp-units::si-iau + mp-units::si-imperial + mp-units::si-international + mp-units::si-typographic + mp-units::si-uscs +) add_example(experimental_angle mp-units::core-fmt mp-units::core-io mp-units::si) add_example(foot_pound_second mp-units::core-fmt mp-units::si-fps) add_example(measurement mp-units::core-io mp-units::si) @@ -46,9 +53,8 @@ add_example(unknown_dimension mp-units::core-io mp-units::si) if(NOT ${projectPrefix}LIBCXX) add_example(glide_computer_example mp-units::core-fmt mp-units::si-international glide_computer) - target_compile_definitions(glide_computer_example-aliases PRIVATE - ${projectPrefix}NO_LITERALS - ${projectPrefix}NO_REFERENCES + target_compile_definitions( + glide_computer_example-aliases PRIVATE ${projectPrefix}NO_LITERALS ${projectPrefix}NO_REFERENCES ) find_package(wg21_linear_algebra CONFIG REQUIRED) diff --git a/example/glide_computer/CMakeLists.txt b/example/glide_computer/CMakeLists.txt index c47eafab..d98b3636 100644 --- a/example/glide_computer/CMakeLists.txt +++ b/example/glide_computer/CMakeLists.txt @@ -22,12 +22,6 @@ cmake_minimum_required(VERSION 3.2) -add_library(glide_computer STATIC - geographic.cpp include/geographic.h - glide_computer.cpp include/glide_computer.h -) -target_link_libraries(glide_computer - PRIVATE mp-units::core-fmt - PUBLIC mp-units::si -) +add_library(glide_computer STATIC geographic.cpp include/geographic.h glide_computer.cpp include/glide_computer.h) +target_link_libraries(glide_computer PRIVATE mp-units::core-fmt PUBLIC mp-units::si) target_include_directories(glide_computer PUBLIC include) diff --git a/example/kalman_filter/CMakeLists.txt b/example/kalman_filter/CMakeLists.txt index 25691790..9c5fbe6a 100644 --- a/example/kalman_filter/CMakeLists.txt +++ b/example/kalman_filter/CMakeLists.txt @@ -28,10 +28,7 @@ cmake_minimum_required(VERSION 3.2) function(add_example target) add_executable(${target} ${target}.cpp) target_link_libraries(${target} PRIVATE ${ARGN}) - target_compile_definitions(${target} PRIVATE - ${projectPrefix}NO_LITERALS - ${projectPrefix}NO_ALIASES - ) + target_compile_definitions(${target} PRIVATE ${projectPrefix}NO_LITERALS ${projectPrefix}NO_ALIASES) endfunction() add_example(kalman_filter-example_1 mp-units::core-fmt mp-units::si) diff --git a/example/literals/CMakeLists.txt b/example/literals/CMakeLists.txt index 4b5eeb9e..13f5adb4 100644 --- a/example/literals/CMakeLists.txt +++ b/example/literals/CMakeLists.txt @@ -28,16 +28,23 @@ cmake_minimum_required(VERSION 3.2) function(add_example target) add_executable(${target}-literals ${target}.cpp) target_link_libraries(${target}-literals PRIVATE ${ARGN}) - target_compile_definitions(${target}-literals PRIVATE - ${projectPrefix}NO_REFERENCES - ${projectPrefix}NO_ALIASES - ) + target_compile_definitions(${target}-literals PRIVATE ${projectPrefix}NO_REFERENCES ${projectPrefix}NO_ALIASES) endfunction() add_example(avg_speed mp-units::core-io mp-units::si mp-units::si-cgs mp-units::si-international) add_example(box_example mp-units::core-fmt mp-units::si) add_example(capacitor_time_curve mp-units::core-io mp-units::si) -add_example(clcpp_response mp-units::core-fmt mp-units::core-io mp-units::si mp-units::si-iau mp-units::si-imperial mp-units::si-international mp-units::si-typographic mp-units::si-uscs) +add_example( + clcpp_response + mp-units::core-fmt + mp-units::core-io + mp-units::si + mp-units::si-iau + mp-units::si-imperial + mp-units::si-international + mp-units::si-typographic + mp-units::si-uscs +) add_example(experimental_angle mp-units::core-fmt mp-units::core-io mp-units::si) add_example(foot_pound_second mp-units::core-fmt mp-units::si-fps) add_example(total_energy mp-units::core-io mp-units::si mp-units::isq-natural) @@ -45,9 +52,8 @@ add_example(unknown_dimension mp-units::core-io mp-units::si) if(NOT ${projectPrefix}LIBCXX) add_example(glide_computer_example mp-units::core-fmt mp-units::si-international glide_computer) - target_compile_definitions(glide_computer_example-literals PRIVATE - ${projectPrefix}NO_REFERENCES - ${projectPrefix}NO_ALIASES + target_compile_definitions( + glide_computer_example-literals PRIVATE ${projectPrefix}NO_REFERENCES ${projectPrefix}NO_ALIASES ) find_package(wg21_linear_algebra CONFIG REQUIRED) diff --git a/example/references/CMakeLists.txt b/example/references/CMakeLists.txt index f014d400..ee75f6c2 100644 --- a/example/references/CMakeLists.txt +++ b/example/references/CMakeLists.txt @@ -28,16 +28,23 @@ cmake_minimum_required(VERSION 3.2) function(add_example target) add_executable(${target}-references ${target}.cpp) target_link_libraries(${target}-references PRIVATE ${ARGN}) - target_compile_definitions(${target}-references PRIVATE - ${projectPrefix}NO_LITERALS - ${projectPrefix}NO_ALIASES - ) + target_compile_definitions(${target}-references PRIVATE ${projectPrefix}NO_LITERALS ${projectPrefix}NO_ALIASES) endfunction() add_example(avg_speed mp-units::core-io mp-units::si mp-units::si-cgs mp-units::si-international) add_example(box_example mp-units::core-fmt mp-units::si) add_example(capacitor_time_curve mp-units::core-io mp-units::si) -add_example(clcpp_response mp-units::core-fmt mp-units::core-io mp-units::si mp-units::si-iau mp-units::si-imperial mp-units::si-international mp-units::si-typographic mp-units::si-uscs) +add_example( + clcpp_response + mp-units::core-fmt + mp-units::core-io + mp-units::si + mp-units::si-iau + mp-units::si-imperial + mp-units::si-international + mp-units::si-typographic + mp-units::si-uscs +) add_example(experimental_angle mp-units::core-fmt mp-units::core-io mp-units::si) add_example(foot_pound_second mp-units::core-fmt mp-units::si-fps) add_example(total_energy mp-units::core-io mp-units::si mp-units::isq-natural) @@ -45,9 +52,8 @@ add_example(unknown_dimension mp-units::core-io mp-units::si) if(NOT ${projectPrefix}LIBCXX) add_example(glide_computer_example mp-units::core-fmt mp-units::si-international glide_computer) - target_compile_definitions(glide_computer_example-references PRIVATE - ${projectPrefix}NO_LITERALS - ${projectPrefix}NO_ALIASES + target_compile_definitions( + glide_computer_example-references PRIVATE ${projectPrefix}NO_LITERALS ${projectPrefix}NO_ALIASES ) find_package(wg21_linear_algebra CONFIG REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02545a22..4ed41451 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,10 +21,7 @@ # SOFTWARE. cmake_minimum_required(VERSION 3.15) -project(mp-units - VERSION 0.8.0 - LANGUAGES CXX -) +project(mp-units VERSION 0.8.0 LANGUAGES CXX) set(projectPrefix UNITS_) @@ -47,12 +44,7 @@ add_subdirectory(systems) # project-wide wrapper add_library(mp-units INTERFACE) -target_link_libraries(mp-units INTERFACE - mp-units::core - mp-units::core-io - mp-units::core-fmt - mp-units::systems -) +target_link_libraries(mp-units INTERFACE mp-units::core mp-units::core-io mp-units::core-fmt mp-units::systems) add_library(mp-units::mp-units ALIAS mp-units) install(TARGETS mp-units EXPORT mp-unitsTargets) @@ -63,11 +55,8 @@ include(CMakePackageConfigHelpers) write_basic_package_version_file(mp-unitsConfigVersion.cmake COMPATIBILITY SameMajorVersion) # installation -install(EXPORT mp-unitsTargets - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mp-units - NAMESPACE mp-units:: -) +install(EXPORT mp-unitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mp-units NAMESPACE mp-units::) install(FILES mp-unitsConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/mp-unitsConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mp-units + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mp-units ) diff --git a/src/cmake/AddUnitsModule.cmake b/src/cmake/AddUnitsModule.cmake index 9a9dc023..bac9a57d 100644 --- a/src/cmake/AddUnitsModule.cmake +++ b/src/cmake/AddUnitsModule.cmake @@ -28,9 +28,9 @@ cmake_minimum_required(VERSION 3.15) function(add_units_module name) add_library(mp-units-${name} INTERFACE) target_link_libraries(mp-units-${name} INTERFACE ${ARGN}) - target_include_directories(mp-units-${name} ${unitsAsSystem} INTERFACE - $ - $ + target_include_directories( + mp-units-${name} ${unitsAsSystem} INTERFACE $ + $ ) set_target_properties(mp-units-${name} PROPERTIES EXPORT_NAME ${name}) add_library(mp-units::${name} ALIAS mp-units-${name}) diff --git a/src/core-fmt/CMakeLists.txt b/src/core-fmt/CMakeLists.txt index 8ecbae40..1ee5e6f7 100644 --- a/src/core-fmt/CMakeLists.txt +++ b/src/core-fmt/CMakeLists.txt @@ -29,6 +29,6 @@ add_units_module(core-fmt mp-units::core) target_compile_definitions(mp-units-core-fmt INTERFACE ${projectPrefix}USE_LIBFMT=$) if(${projectPrefix}USE_LIBFMT) - find_package(fmt CONFIG REQUIRED) - target_link_libraries(mp-units-core-fmt INTERFACE fmt::fmt) + find_package(fmt CONFIG REQUIRED) + target_link_libraries(mp-units-core-fmt INTERFACE fmt::fmt) endif() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 31900e53..4a4682be 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -36,12 +36,10 @@ check_libcxx_in_use(${projectPrefix}LIBCXX) # core library definition add_library(mp-units-core INTERFACE) target_compile_features(mp-units-core INTERFACE cxx_std_20) -target_link_libraries(mp-units-core INTERFACE - gsl::gsl-lite -) -target_include_directories(mp-units-core ${unitsAsSystem} INTERFACE - $ - $ +target_link_libraries(mp-units-core INTERFACE gsl::gsl-lite) +target_include_directories( + mp-units-core ${unitsAsSystem} INTERFACE $ + $ ) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -50,8 +48,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_link_libraries(mp-units-core INTERFACE range-v3::range-v3) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_options(mp-units-core INTERFACE - /utf-8 # Specifies both the source character set and the execution character set as UTF-8 + target_compile_options( + mp-units-core + INTERFACE /utf-8 # Specifies both the source character set and the execution character set as UTF-8 ) endif() @@ -59,7 +58,9 @@ if(DEFINED ${projectPrefix}DOWNCAST_MODE) set(downcast_mode_options OFF ON AUTO) list(FIND downcast_mode_options "${${projectPrefix}DOWNCAST_MODE}" downcast_mode) if(downcast_mode EQUAL -1) - message(FATAL_ERROR "'${projectPrefix}DOWNCAST_MODE' should be one of ${downcast_mode_options} ('${${projectPrefix}DOWNCAST_MODE}' received)") + message(FATAL_ERROR + "'${projectPrefix}DOWNCAST_MODE' should be one of ${downcast_mode_options} ('${${projectPrefix}DOWNCAST_MODE}' received)" + ) else() message(STATUS "${projectPrefix}DOWNCAST_MODE: ${${projectPrefix}DOWNCAST_MODE}") target_compile_definitions(mp-units-core INTERFACE ${projectPrefix}DOWNCAST_MODE=${downcast_mode}) diff --git a/src/systems/CMakeLists.txt b/src/systems/CMakeLists.txt index 6c89c8f8..41adc78e 100644 --- a/src/systems/CMakeLists.txt +++ b/src/systems/CMakeLists.txt @@ -38,19 +38,21 @@ add_subdirectory(si-uscs) # wrapper for all the systems add_library(mp-units-systems INTERFACE) -target_link_libraries(mp-units-systems INTERFACE - mp-units::isq - mp-units::isq-iec80000 - mp-units::isq-natural - mp-units::si - mp-units::si-cgs - mp-units::si-fps - mp-units::si-hep - mp-units::si-iau - mp-units::si-imperial - mp-units::si-international - mp-units::si-typographic - mp-units::si-uscs +target_link_libraries( + mp-units-systems + INTERFACE + mp-units::isq + mp-units::isq-iec80000 + mp-units::isq-natural + mp-units::si + mp-units::si-cgs + mp-units::si-fps + mp-units::si-hep + mp-units::si-iau + mp-units::si-imperial + mp-units::si-international + mp-units::si-typographic + mp-units::si-uscs ) add_library(mp-units::systems ALIAS mp-units-systems) set_target_properties(mp-units-systems PROPERTIES EXPORT_NAME systems) diff --git a/test/metabench/CMakeLists.txt b/test/metabench/CMakeLists.txt index b5206de1..0186dc1a 100644 --- a/test/metabench/CMakeLists.txt +++ b/test/metabench/CMakeLists.txt @@ -25,17 +25,10 @@ cmake_minimum_required(VERSION 3.12) function(add_metabench_test target name erb_path range) metabench_add_dataset(${target} "${erb_path}" "${range}" NAME "${name}") target_compile_features(${target} PUBLIC cxx_std_20) - target_link_libraries(${target} - PUBLIC - range-v3::range-v3> - ) - target_compile_options(${target} - PUBLIC - -fconcepts - ) + target_link_libraries(${target} PUBLIC range-v3::range-v3>) + target_compile_options(${target} PUBLIC -fconcepts) endfunction() - include(metabench) if(NOT METABENCH_DIR) return() diff --git a/test/metabench/list/CMakeLists.txt b/test/metabench/list/CMakeLists.txt index cfc4b97b..383efcad 100644 --- a/test/metabench/list/CMakeLists.txt +++ b/test/metabench/list/CMakeLists.txt @@ -22,34 +22,44 @@ cmake_minimum_required(VERSION 3.2) -add_metabench_test(metabench.data.list.type_list.concepts_all "all concepts" type_list_concepts_all.cpp.erb "[3, 6, 9, 12, 15]") -add_metabench_test(metabench.data.list.type_list.concepts_iface "concepts in interface" type_list_concepts_iface.cpp.erb "[3, 6, 9, 12, 15]") -add_metabench_test(metabench.data.list.type_list.concepts_no "no concepts" type_list_concepts_no.cpp.erb "[3, 6, 9, 12, 15]") -metabench_add_chart(metabench.chart.list.concepts +add_metabench_test( + metabench.data.list.type_list.concepts_all "all concepts" type_list_concepts_all.cpp.erb "[3, 6, 9, 12, 15]" +) +add_metabench_test( + metabench.data.list.type_list.concepts_iface "concepts in interface" type_list_concepts_iface.cpp.erb + "[3, 6, 9, 12, 15]" +) +add_metabench_test( + metabench.data.list.type_list.concepts_no "no concepts" type_list_concepts_no.cpp.erb "[3, 6, 9, 12, 15]" +) +metabench_add_chart( + metabench.chart.list.concepts TITLE "Sorting a list of size N" SUBTITLE "(lower is better)" - DATASETS - metabench.data.list.type_list.concepts_all - metabench.data.list.type_list.concepts_iface - metabench.data.list.type_list.concepts_no + DATASETS metabench.data.list.type_list.concepts_all metabench.data.list.type_list.concepts_iface + metabench.data.list.type_list.concepts_no ) -add_metabench_test(metabench.data.list.type_list.conditional_std "std::conditional" type_list_conditional_std.cpp.erb "[3, 6, 9, 12, 15]") -add_metabench_test(metabench.data.list.type_list.conditional_alias "alias conditional" type_list_conditional_alias.cpp.erb "[3, 6, 9, 12, 15]") -add_metabench_test(metabench.data.list.type_list.conditional_alias_hard "alias conditional hard" type_list_conditional_alias_hard.cpp.erb "[3, 6, 9, 12, 15]") -metabench_add_chart(metabench.chart.list.conditional +add_metabench_test( + metabench.data.list.type_list.conditional_std "std::conditional" type_list_conditional_std.cpp.erb + "[3, 6, 9, 12, 15]" +) +add_metabench_test( + metabench.data.list.type_list.conditional_alias "alias conditional" type_list_conditional_alias.cpp.erb + "[3, 6, 9, 12, 15]" +) +add_metabench_test( + metabench.data.list.type_list.conditional_alias_hard "alias conditional hard" + type_list_conditional_alias_hard.cpp.erb "[3, 6, 9, 12, 15]" +) +metabench_add_chart( + metabench.chart.list.conditional TITLE "Sorting a list of size N" SUBTITLE "(lower is better)" - DATASETS - metabench.data.list.type_list.conditional_std - metabench.data.list.type_list.conditional_alias - metabench.data.list.type_list.conditional_alias_hard + DATASETS metabench.data.list.type_list.conditional_std metabench.data.list.type_list.conditional_alias + metabench.data.list.type_list.conditional_alias_hard ) -add_custom_target(metabench.chart.list - DEPENDS - metabench.chart.list.concepts - metabench.chart.list.conditional -) +add_custom_target(metabench.chart.list DEPENDS metabench.chart.list.concepts metabench.chart.list.conditional) add_dependencies(metabench metabench.chart.list) diff --git a/test/metabench/make_dimension/CMakeLists.txt b/test/metabench/make_dimension/CMakeLists.txt index e0af061c..354c7c0a 100644 --- a/test/metabench/make_dimension/CMakeLists.txt +++ b/test/metabench/make_dimension/CMakeLists.txt @@ -23,15 +23,18 @@ cmake_minimum_required(VERSION 3.2) add_metabench_test(metabench.data.make_dimension.no_concepts "no concepts" no_concepts.cpp.erb "[1, 2, 3, 4, 6, 8, 10]") -add_metabench_test(metabench.data.make_dimension.concepts_iface "concepts iface" concepts_iface.cpp.erb "[1, 2, 3, 4, 6, 8, 10]") -add_metabench_test(metabench.data.make_dimension.concepts_all "concepts all" concepts_all.cpp.erb "[1, 2, 3, 4, 6, 8, 10]") -metabench_add_chart(metabench.chart.make_dimension +add_metabench_test( + metabench.data.make_dimension.concepts_iface "concepts iface" concepts_iface.cpp.erb "[1, 2, 3, 4, 6, 8, 10]" +) +add_metabench_test( + metabench.data.make_dimension.concepts_all "concepts all" concepts_all.cpp.erb "[1, 2, 3, 4, 6, 8, 10]" +) +metabench_add_chart( + metabench.chart.make_dimension TITLE "100 x make_dimension" SUBTITLE "(lower is better)" - DATASETS - metabench.data.make_dimension.no_concepts - metabench.data.make_dimension.concepts_iface - metabench.data.make_dimension.concepts_all + DATASETS metabench.data.make_dimension.no_concepts metabench.data.make_dimension.concepts_iface + metabench.data.make_dimension.concepts_all ) add_dependencies(metabench metabench.chart.make_dimension) diff --git a/test/metabench/ratio/CMakeLists.txt b/test/metabench/ratio/CMakeLists.txt index b18e286d..a2c38c31 100644 --- a/test/metabench/ratio/CMakeLists.txt +++ b/test/metabench/ratio/CMakeLists.txt @@ -22,52 +22,65 @@ cmake_minimum_required(VERSION 3.2) -add_metabench_test(metabench.data.ratio.create.std_ratio "std::ratio" create_std_ratio.cpp.erb "[1000, 2500, 5000, 7500, 10000]") -add_metabench_test(metabench.data.ratio.create.ratio_type_constexpr "ratio with constexpr" create_ratio_type_constexpr.cpp.erb "[1000, 2500, 5000, 7500, 10000]") -metabench_add_chart(metabench.chart.ratio.create +add_metabench_test( + metabench.data.ratio.create.std_ratio "std::ratio" create_std_ratio.cpp.erb "[1000, 2500, 5000, 7500, 10000]" +) +add_metabench_test( + metabench.data.ratio.create.ratio_type_constexpr "ratio with constexpr" create_ratio_type_constexpr.cpp.erb + "[1000, 2500, 5000, 7500, 10000]" +) +metabench_add_chart( + metabench.chart.ratio.create TITLE "Creation of 2*N ratios" SUBTITLE "(lower is better)" - DATASETS - metabench.data.ratio.create.std_ratio - metabench.data.ratio.create.ratio_type_constexpr + DATASETS metabench.data.ratio.create.std_ratio metabench.data.ratio.create.ratio_type_constexpr ) -add_metabench_test(metabench.data.ratio.multiply_divide.std_ratio "std::ratio" multiply_divide_std_ratio.cpp.erb "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]") -add_metabench_test(metabench.data.ratio.multiply_divide.ratio_type_constexpr "ratio constexpr" multiply_divide_ratio_type_constexpr.cpp.erb "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]") -metabench_add_chart(metabench.chart.ratio.multiply_divide +add_metabench_test( + metabench.data.ratio.multiply_divide.std_ratio "std::ratio" multiply_divide_std_ratio.cpp.erb + "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]" +) +add_metabench_test( + metabench.data.ratio.multiply_divide.ratio_type_constexpr "ratio constexpr" + multiply_divide_ratio_type_constexpr.cpp.erb "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]" +) +metabench_add_chart( + metabench.chart.ratio.multiply_divide TITLE "N ratio multiply + divide operations" SUBTITLE "(lower is better)" - DATASETS - metabench.data.ratio.multiply_divide.std_ratio - metabench.data.ratio.multiply_divide.ratio_type_constexpr + DATASETS metabench.data.ratio.multiply_divide.std_ratio metabench.data.ratio.multiply_divide.ratio_type_constexpr ) -add_metabench_test(metabench.data.ratio.common_ratio.std_ratio "std::ratio" common_ratio_std_ratio.cpp.erb "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]") -add_metabench_test(metabench.data.ratio.common_ratio.ratio_type_constexpr "ratio constexpr" common_ratio_ratio_type_constexpr.cpp.erb "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]") -metabench_add_chart(metabench.chart.ratio.common_ratio +add_metabench_test( + metabench.data.ratio.common_ratio.std_ratio "std::ratio" common_ratio_std_ratio.cpp.erb + "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]" +) +add_metabench_test( + metabench.data.ratio.common_ratio.ratio_type_constexpr "ratio constexpr" common_ratio_ratio_type_constexpr.cpp.erb + "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]" +) +metabench_add_chart( + metabench.chart.ratio.common_ratio TITLE "N common_ratio operations" SUBTITLE "(lower is better)" - DATASETS - metabench.data.ratio.common_ratio.std_ratio - metabench.data.ratio.common_ratio.ratio_type_constexpr + DATASETS metabench.data.ratio.common_ratio.std_ratio metabench.data.ratio.common_ratio.ratio_type_constexpr ) add_metabench_test(metabench.data.ratio.all.std_ratio "std::ratio" all_std_ratio.cpp.erb "[10, 50, 100, 500, 1000]") -add_metabench_test(metabench.data.ratio.all.ratio_type_constexpr "ratio with constexpr" all_ratio_type_constexpr.cpp.erb "[10, 50, 100, 500, 1000]") -metabench_add_chart(metabench.chart.ratio.all +add_metabench_test( + metabench.data.ratio.all.ratio_type_constexpr "ratio with constexpr" all_ratio_type_constexpr.cpp.erb + "[10, 50, 100, 500, 1000]" +) +metabench_add_chart( + metabench.chart.ratio.all TITLE "N x all ratio operations" SUBTITLE "(lower is better)" - DATASETS - metabench.data.ratio.all.std_ratio - metabench.data.ratio.all.ratio_type_constexpr + DATASETS metabench.data.ratio.all.std_ratio metabench.data.ratio.all.ratio_type_constexpr ) -add_custom_target(metabench.chart.ratio - DEPENDS - metabench.chart.ratio.create - metabench.chart.ratio.multiply_divide - metabench.chart.ratio.common_ratio - metabench.chart.ratio.all +add_custom_target( + metabench.chart.ratio DEPENDS metabench.chart.ratio.create metabench.chart.ratio.multiply_divide + metabench.chart.ratio.common_ratio metabench.chart.ratio.all ) add_dependencies(metabench metabench.chart.ratio) diff --git a/test/unit_test/runtime/CMakeLists.txt b/test/unit_test/runtime/CMakeLists.txt index ba919690..9e2c70b2 100644 --- a/test/unit_test/runtime/CMakeLists.txt +++ b/test/unit_test/runtime/CMakeLists.txt @@ -24,22 +24,15 @@ cmake_minimum_required(VERSION 3.2) find_package(Catch2 CONFIG REQUIRED) -add_executable(unit_tests_runtime - catch_main.cpp - math_test.cpp - magnitude_test.cpp - fmt_test.cpp - fmt_units_test.cpp - distribution_test.cpp -) -target_link_libraries(unit_tests_runtime PRIVATE - mp-units::mp-units - Catch2::Catch2 +add_executable( + unit_tests_runtime catch_main.cpp math_test.cpp magnitude_test.cpp fmt_test.cpp fmt_units_test.cpp + distribution_test.cpp ) +target_link_libraries(unit_tests_runtime PRIVATE mp-units::mp-units Catch2::Catch2) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_options(unit_tests_runtime PRIVATE - /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data + target_compile_options( + unit_tests_runtime PRIVATE /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data ) endif() diff --git a/test/unit_test/static/CMakeLists.txt b/test/unit_test/static/CMakeLists.txt index 2d974c9f..f3cb7def 100644 --- a/test/unit_test/static/CMakeLists.txt +++ b/test/unit_test/static/CMakeLists.txt @@ -22,23 +22,17 @@ cmake_minimum_required(VERSION 3.2) -add_library(unit_tests_static_truncating - quantity_test.cpp -) +add_library(unit_tests_static_truncating quantity_test.cpp) if(NOT ${projectPrefix}LIBCXX) - target_sources(unit_tests_static_truncating PRIVATE - quantity_kind_test.cpp - quantity_point_kind_test.cpp - ) + target_sources(unit_tests_static_truncating PRIVATE quantity_kind_test.cpp quantity_point_kind_test.cpp) endif() -target_link_libraries(unit_tests_static_truncating PRIVATE - mp-units::mp-units -) -target_compile_options(unit_tests_static_truncating PRIVATE - $,/wd4242 /wd4244,-Wno-conversion> +target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::mp-units) +target_compile_options( + unit_tests_static_truncating PRIVATE $,/wd4242 /wd4244,-Wno-conversion> ) -add_library(unit_tests_static +add_library( + unit_tests_static cgs_test.cpp chrono_test.cpp concepts_test.cpp @@ -66,13 +60,7 @@ add_library(unit_tests_static ) if(NOT ${projectPrefix}LIBCXX) - target_sources(unit_tests_static PRIVATE - custom_rep_test_min_impl.cpp - quantity_point_test.cpp - ) + target_sources(unit_tests_static PRIVATE custom_rep_test_min_impl.cpp quantity_point_test.cpp) endif() -target_link_libraries(unit_tests_static PRIVATE - unit_tests_static_truncating - mp-units::mp-units -) +target_link_libraries(unit_tests_static PRIVATE unit_tests_static_truncating mp-units::mp-units) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 8a5eec85..ce2cf5b1 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -21,9 +21,7 @@ # SOFTWARE. cmake_minimum_required(VERSION 3.15) -project(test_package - LANGUAGES CXX -) +project(test_package LANGUAGES CXX) find_package(mp-units CONFIG REQUIRED) From b221dace3ffe2ca7e8b93c94ee78aaedfe7df851 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 2 Apr 2022 21:36:42 +0200 Subject: [PATCH 05/50] style: clang-format applied to the remaining files --- example/aliases/avg_speed.cpp | 49 ++-- example/aliases/box_example.cpp | 15 +- example/aliases/capacitor_time_curve.cpp | 2 +- example/aliases/foot_pound_second.cpp | 57 +++- example/aliases/glide_computer_example.cpp | 37 +-- example/aliases/linear_algebra.cpp | 72 ++--- example/aliases/measurement.cpp | 3 +- example/aliases/total_energy.cpp | 12 +- example/aliases/unknown_dimension.cpp | 15 +- example/conversion_factor.cpp | 5 +- example/custom_systems.cpp | 5 +- example/glide_computer/geographic.cpp | 3 +- example/glide_computer/glide_computer.cpp | 32 +- example/glide_computer/include/geographic.h | 1 - .../glide_computer/include/glide_computer.h | 26 +- example/hello_units.cpp | 23 +- example/kalman_filter/kalman.h | 67 +++-- .../kalman_filter/kalman_filter-example_1.cpp | 16 +- .../kalman_filter/kalman_filter-example_2.cpp | 12 +- .../kalman_filter/kalman_filter-example_3.cpp | 12 +- .../kalman_filter/kalman_filter-example_4.cpp | 15 +- .../kalman_filter/kalman_filter-example_5.cpp | 18 +- .../kalman_filter/kalman_filter-example_6.cpp | 33 +-- .../kalman_filter/kalman_filter-example_7.cpp | 33 +-- .../kalman_filter/kalman_filter-example_8.cpp | 33 +-- example/literals/avg_speed.cpp | 53 ++-- example/literals/box_example.cpp | 13 +- example/literals/capacitor_time_curve.cpp | 2 +- example/literals/foot_pound_second.cpp | 63 +++- example/literals/glide_computer_example.cpp | 37 +-- example/literals/linear_algebra.cpp | 72 ++--- example/literals/total_energy.cpp | 12 +- example/literals/unknown_dimension.cpp | 15 +- example/measurement.cpp | 6 +- example/references/avg_speed.cpp | 49 ++-- example/references/box_example.cpp | 13 +- example/references/capacitor_time_curve.cpp | 2 +- example/references/clcpp_response.cpp | 12 +- example/references/experimental_angle.cpp | 6 +- example/references/foot_pound_second.cpp | 65 ++++- example/references/glide_computer_example.cpp | 37 +-- example/references/linear_algebra.cpp | 72 ++--- example/references/total_energy.cpp | 10 +- example/references/unknown_dimension.cpp | 15 +- src/core/include/units/generic/angle.h | 10 +- .../include/units/isq/si/fps/acceleration.h | 13 +- .../si-fps/include/units/isq/si/fps/area.h | 17 +- .../si-fps/include/units/isq/si/fps/density.h | 15 +- .../si-fps/include/units/isq/si/fps/energy.h | 24 +- .../si-fps/include/units/isq/si/fps/force.h | 33 ++- .../si-fps/include/units/isq/si/fps/fps.h | 7 +- .../include/units/isq/si/fps/pressure.h | 40 ++- .../si-fps/include/units/isq/si/fps/speed.h | 37 ++- .../si-hep/include/units/isq/si/hep/area.h | 63 +++- .../include/units/isq/si/international/area.h | 15 +- .../isq/si/international/international.h | 3 +- .../si/include/units/isq/si/absorbed_dose.h | 195 ++++++++++--- .../si/include/units/isq/si/acceleration.h | 13 +- .../units/isq/si/amount_of_substance.h | 15 +- .../include/units/isq/si/angular_velocity.h | 16 +- src/systems/si/include/units/isq/si/area.h | 204 ++++++++++--- .../si/include/units/isq/si/capacitance.h | 197 ++++++++++--- .../si/include/units/isq/si/concentration.h | 18 +- .../si/include/units/isq/si/conductance.h | 161 +++++++--- src/systems/si/include/units/isq/si/density.h | 15 +- src/systems/si/include/units/isq/si/energy.h | 180 +++++++++--- src/systems/si/include/units/isq/si/force.h | 195 ++++++++++--- .../si/include/units/isq/si/luminance.h | 13 +- .../include/units/isq/si/luminous_intensity.h | 195 ++++++++++--- .../si/include/units/isq/si/molar_energy.h | 18 +- .../si/include/units/isq/si/pressure.h | 195 ++++++++++--- .../si/include/units/isq/si/radioactivity.h | 195 ++++++++++--- src/systems/si/include/units/isq/si/voltage.h | 195 ++++++++++--- test/metabench/list/type_list_concepts_all.h | 229 ++++++++------- .../metabench/list/type_list_concepts_iface.h | 251 ++++++++-------- test/metabench/list/type_list_concepts_no.h | 235 +++++++-------- .../list/type_list_conditional_alias.h | 251 ++++++++-------- .../list/type_list_conditional_alias_hard.h | 242 ++++++++-------- .../list/type_list_conditional_std.h | 223 +++++++------- .../make_dimension/dimension_concepts_all.h | 259 ++++++++--------- .../make_dimension/dimension_concepts_iface.h | 259 ++++++++--------- .../make_dimension/dimension_no_concepts.h | 221 +++++++------- .../make_dimension/downcasting_concepts_all.h | 29 +- .../make_dimension/downcasting_no_concepts.h | 20 +- test/metabench/make_dimension/hacks.h | 14 +- .../make_dimension/ratio_concepts_all.h | 153 +++++----- .../make_dimension/ratio_concepts_iface.h | 153 +++++----- .../make_dimension/ratio_no_concepts.h | 135 ++++----- .../make_dimension/type_list_concepts_all.h | 223 +++++++------- .../make_dimension/type_list_concepts_iface.h | 223 +++++++------- .../make_dimension/type_list_no_concepts.h | 207 ++++++------- test/metabench/make_dimension/type_traits.h | 30 +- test/metabench/ratio/ratio_type_constexpr.h | 140 ++++----- test/metabench/ratio/std_ratio.h | 49 ++-- .../static/dimensions_concepts_test.cpp | 11 +- test/unit_test/static/fixed_string_test.cpp | 2 +- test/unit_test/static/fps_test.cpp | 5 +- test/unit_test/static/quantity_kind_test.cpp | 2 +- test/unit_test/static/quantity_point_test.cpp | 164 ++++++----- test/unit_test/static/quantity_test.cpp | 274 +++++++++++------- test/unit_test/static/ratio_test.cpp | 2 +- test/unit_test/static/references_test.cpp | 39 +-- test/unit_test/static/si_cgs_test.cpp | 43 +-- test/unit_test/static/si_fps_test.cpp | 84 +++--- test/unit_test/static/si_hep_test.cpp | 12 +- test/unit_test/static/si_test.cpp | 13 +- test/unit_test/static/symbol_text_test.cpp | 2 +- test/unit_test/static/type_list_test.cpp | 29 +- test/unit_test/static/unit_test.cpp | 11 +- 109 files changed, 4546 insertions(+), 3140 deletions(-) diff --git a/example/aliases/avg_speed.cpp b/example/aliases/avg_speed.cpp index e9b2272b..d09b2571 100644 --- a/example/aliases/avg_speed.cpp +++ b/example/aliases/avg_speed.cpp @@ -21,12 +21,12 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include +#include #include #include #include @@ -35,38 +35,31 @@ namespace { using namespace units::isq; -constexpr si::speed -fixed_int_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_int_si_avg_speed(si::length d, + si::time t) { return d / t; } -constexpr si::speed -fixed_double_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_double_si_avg_speed(si::length d, si::time t) { return d / t; } template -constexpr Speed auto si_avg_speed(si::length d, - si::time t) +constexpr Speed auto si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr Speed auto avg_speed(Length auto d, Time auto t) -{ - return d / t; -} +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } template void print_result(D distance, T duration, V speed) { const auto result_in_kmph = units::quantity_cast>(speed); - std::cout << "Average speed of a car that makes " << distance << " in " - << duration << " is " << result_in_kmph << ".\n"; + std::cout << "Average speed of a car that makes " << distance << " in " << duration << " is " << result_in_kmph + << ".\n"; } void example() @@ -94,7 +87,8 @@ void example() std::cout << "\nSI units with 'double' as representation\n"; // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); + print_result(distance, duration, + fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -130,7 +124,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // also it is not possible to make a lossless conversion of miles to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -169,7 +165,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // it is not possible to make a lossless conversion of centimeters to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); @@ -178,20 +176,17 @@ void example() print_result(distance, duration, avg_speed(distance, duration)); } - } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/aliases/box_example.cpp b/example/aliases/box_example.cpp index 869c337d..048cdb46 100644 --- a/example/aliases/box_example.cpp +++ b/example/aliases/box_example.cpp @@ -29,7 +29,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -40,7 +40,7 @@ namespace { using namespace units::aliases::isq::si; -inline constexpr auto g = units::isq::si::si2019::standard_gravity<>; +inline constexpr auto g = units::isq::si::si2019::standard_gravity<>; // NOLINT(readability-identifier-length) inline constexpr auto air_density = kg_per_m3<>(1.225); class Box { @@ -48,7 +48,10 @@ class Box { length::m<> height_; density::kg_per_m3<> density_ = air_density; public: - constexpr Box(const length::m<>& length, const length::m<>& width, length::m<> height): base_(length * width), height_(std::move(height)) {} + constexpr Box(const length::m<>& length, const length::m<>& width, length::m<> height) : + base_(length * width), height_(std::move(height)) + { + } [[nodiscard]] constexpr force::N<> filled_weight() const { @@ -86,13 +89,13 @@ int main() auto box = Box(mm<>(1000.0), mm<>(500.0), height); box.set_contents_density(kg_per_m3<>(1000.0)); - const auto fill_time = s<>(200.0); // time since starting fill - const auto measured_mass = kg<>(20.0); // measured mass at fill_time + const auto fill_time = s<>(200.0); // time since starting fill + const auto measured_mass = kg<>(20.0); // measured mass at fill_time const Length auto fill_level = box.fill_level(measured_mass); const Dimensionless auto fill_percent = quantity_cast(fill_level / height); const Volume auto spare_capacity = box.spare_capacity(measured_mass); - const auto input_flow_rate = measured_mass / fill_time; // unknown dimension + const auto input_flow_rate = measured_mass / fill_time; // unknown dimension const Speed auto float_rise_rate = fill_level / fill_time; const Time auto fill_time_left = (height / fill_level - 1) * fill_time; diff --git a/example/aliases/capacitor_time_curve.cpp b/example/aliases/capacitor_time_curve.cpp index fc2eeff9..ab20cf78 100644 --- a/example/aliases/capacitor_time_curve.cpp +++ b/example/aliases/capacitor_time_curve.cpp @@ -25,7 +25,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include diff --git a/example/aliases/foot_pound_second.cpp b/example/aliases/foot_pound_second.cpp index 3b2dcab5..588e328d 100644 --- a/example/aliases/foot_pound_second.cpp +++ b/example/aliases/foot_pound_second.cpp @@ -52,7 +52,7 @@ struct Ship { }; // Print 'a' in its current units and print its value cast to the units in each of Args -template +template auto fmt_line(const Q a) { return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast(a)) + ...); @@ -63,16 +63,21 @@ void print_details(std::string_view description, const Ship& ship) { const auto waterDensity = si::fps::density::lb_per_ft3<>(62.4); std::cout << STD_FMT::format("{}\n", description); - std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length::m<>>(ship.length)) - << STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length::m<>>(ship.draft)) - << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) - << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) - << STD_FMT::format("{:20} : {}\n", "speed", fmt_line, si::speed::km_per_h<>>(ship.speed)) - << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) - << STD_FMT::format("{:20} : {}\n", "main guns", fmt_line, si::length::mm<>>(ship.mainGuns)) - << STD_FMT::format("{:20} : {}\n", "fire shells weighing",fmt_line, si::mass::kg<>>(ship.shellMass)) - << STD_FMT::format("{:20} : {}\n", "fire shells at",fmt_line, si::speed::km_per_h<>>(ship.shellSpeed)) - << STD_FMT::format("{:20} : {}\n", "volume underwater", fmt_line, si::volume::l<>>(ship.mass / waterDensity)); + std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length::m<>>(ship.length)) + << STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length::m<>>(ship.draft)) + << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) + << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) + << STD_FMT::format("{:20} : {}\n", "speed", + fmt_line, si::speed::km_per_h<>>(ship.speed)) + << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) + << STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length::mm<>>(ship.mainGuns)) + << STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass::kg<>>(ship.shellMass)) + << STD_FMT::format("{:20} : {}\n", "fire shells at", + fmt_line, si::speed::km_per_h<>>(ship.shellSpeed)) + << STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume::l<>>(ship.mass / waterDensity)); } int main() @@ -82,13 +87,37 @@ int main() using units::aliases::isq::si::fps::length::ft; // to disambiguate from si::femptotonne // KMS Bismark, using the units the Germans would use, taken from Wiki - auto bismark = Ship{.length{m<>(251.)}, .draft{m<>(9.3)}, .beam{m<>(36)}, .speed{km_per_h<>(56)}, .mass{t<>(50'300)}, .mainGuns{mm<>(380)}, .shellMass{kg<>(800)}, .shellSpeed{m_per_s<>(820.)}, .power{kW<>(110.45)}}; + auto bismark = Ship{.length{m<>(251.)}, + .draft{m<>(9.3)}, + .beam{m<>(36)}, + .speed{km_per_h<>(56)}, + .mass{t<>(50'300)}, + .mainGuns{mm<>(380)}, + .shellMass{kg<>(800)}, + .shellSpeed{m_per_s<>(820.)}, + .power{kW<>(110.45)}}; // USS Iowa, using units from the foot-pound-second system - auto iowa = Ship{.length{ft<>(860.)}, .draft{ft<>(37.) + in<>(2.)}, .beam{ft<>(108.) + in<>(2.)}, .speed{knot<>(33)}, .mass{lton<>(57'540)}, .mainGuns{in<>(16)}, .shellMass{lb<>(2700)}, .shellSpeed{ft_per_s<>(2690.)}, .power{hp<>(212'000)}}; + auto iowa = Ship{.length{ft<>(860.)}, + .draft{ft<>(37.) + in<>(2.)}, + .beam{ft<>(108.) + in<>(2.)}, + .speed{knot<>(33)}, + .mass{lton<>(57'540)}, + .mainGuns{in<>(16)}, + .shellMass{lb<>(2700)}, + .shellSpeed{ft_per_s<>(2690.)}, + .power{hp<>(212'000)}}; // HMS King George V, using units from the foot-pound-second system - auto kgv = Ship{.length{ft<>(745.1)}, .draft{ft<>(33.) + in<>(7.5)}, .beam{ft<>(103.2) + in<>(2.5)}, .speed{knot<>(28.3)}, .mass{lton<>(42'245)}, .mainGuns{in<>(14)}, .shellMass{lb<>(1'590)}, .shellSpeed{ft_per_s<>(2483)}, .power{hp<>(110'000)}}; + auto kgv = Ship{.length{ft<>(745.1)}, + .draft{ft<>(33.) + in<>(7.5)}, + .beam{ft<>(103.2) + in<>(2.5)}, + .speed{knot<>(28.3)}, + .mass{lton<>(42'245)}, + .mainGuns{in<>(14)}, + .shellMass{lb<>(1'590)}, + .shellSpeed{ft_per_s<>(2483)}, + .power{hp<>(110'000)}}; print_details("KMS Bismark, defined in appropriate units from the SI system", bismark); std::cout << "\n\n"; diff --git a/example/aliases/glide_computer_example.cpp b/example/aliases/glide_computer_example.cpp index 11d40e6e..0be12c1c 100644 --- a/example/aliases/glide_computer_example.cpp +++ b/example/aliases/glide_computer_example.cpp @@ -25,7 +25,6 @@ #include #include #include - #include #include #include @@ -43,14 +42,14 @@ using namespace units::isq; auto get_gliders() { using namespace units::aliases::isq::si; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES static const std::array gliders = { - glider{"SZD-30 Pirat", {velocity(km_per_h<>(83)), rate_of_climb(m_per_s<>(-0.7389))}}, - glider{"SZD-51 Junior", {velocity(km_per_h<>(80)), rate_of_climb(m_per_s<>(-0.6349))}}, - glider{"SZD-48 Jantar Std 3", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.77355))}}, - glider{"SZD-56 Diana", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.63657))}}}; -UNITS_DIAGNOSTIC_POP + glider{"SZD-30 Pirat", {velocity(km_per_h<>(83)), rate_of_climb(m_per_s<>(-0.7389))}}, + glider{"SZD-51 Junior", {velocity(km_per_h<>(80)), rate_of_climb(m_per_s<>(-0.6349))}}, + glider{"SZD-48 Jantar Std 3", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.77355))}}, + glider{"SZD-56 Diana", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.63657))}}}; + UNITS_DIAGNOSTIC_POP return gliders; } @@ -58,9 +57,9 @@ auto get_weather_conditions() { using namespace units::aliases::isq::si; static const std::array weather_conditions = { - std::pair("Good", weather{height(m<>(1900)), rate_of_climb(m_per_s<>(4.3))}), - std::pair("Medium", weather{height(m<>(1550)), rate_of_climb(m_per_s<>(2.8))}), - std::pair("Bad", weather{height(m<>(850)), rate_of_climb(m_per_s<>(1.8))})}; + std::pair("Good", weather{height(m<>(1900)), rate_of_climb(m_per_s<>(4.3))}), + std::pair("Medium", weather{height(m<>(1550)), rate_of_climb(m_per_s<>(2.8))}), + std::pair("Bad", weather{height(m<>(850)), rate_of_climb(m_per_s<>(1.8))})}; return weather_conditions; } @@ -69,14 +68,14 @@ auto get_waypoints() using namespace geographic::literals; using namespace units::aliases::isq::si::international; static const std::array waypoints = { - waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(ft<>(16))}, // N54°14'51.8" E18°40'28.2" - waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(ft<>(115))} // N53°31'27.9" E18°50'58.1" + waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(ft<>(16))}, // N54°14'51.8" E18°40'28.2" + waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(ft<>(115))} // N53°31'27.9" E18°50'58.1" }; return waypoints; } template - requires std::same_as, glider> + requires(std::same_as, glider>) void print(const R& gliders) { std::cout << "Gliders:\n"; @@ -85,13 +84,14 @@ void print(const R& gliders) std::cout << "- Name: " << g.name << "\n"; std::cout << "- Polar:\n"; for (const auto& p : g.polar) - std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast(glide_ratio(g.polar[0]))); + std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, + units::quantity_cast(glide_ratio(g.polar[0]))); std::cout << "\n"; } } template - requires std::same_as, std::pair> + requires(std::same_as, std::pair>) void print(const R& conditions) { std::cout << "Weather:\n"; @@ -106,7 +106,7 @@ void print(const R& conditions) } template - requires std::same_as, waypoint> + requires(std::same_as, waypoint>) void print(const R& waypoints) { std::cout << "Waypoints:\n"; @@ -125,7 +125,8 @@ void print(const task& t) std::cout << "- Finish: " << t.get_finish().name << "\n"; std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n"; - std::cout << "- Legs: " << "\n"; + std::cout << "- Legs: " + << "\n"; for (const auto& l : t.get_legs()) std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length()); std::cout << "\n"; diff --git a/example/aliases/linear_algebra.cpp b/example/aliases/linear_algebra.cpp index 79ef9f52..b624ad3e 100644 --- a/example/aliases/linear_algebra.cpp +++ b/example/aliases/linear_algebra.cpp @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include +#include // IWYU pragma: keep #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include -#include #include +#include namespace STD_LA { @@ -72,9 +72,9 @@ void vector_of_quantity_add() { std::cout << "\nvector_of_quantity_add:\n"; - vector> v = { m<>(1), m<>(2), m<>(3) }; - vector> u = { m<>(3), m<>(2), m<>(1) }; - vector> t = { km<>(3), km<>(2), km<>(1) }; + vector> v = {m<>(1), m<>(2), m<>(3)}; + vector> u = {m<>(3), m<>(2), m<>(1)}; + vector> t = {km<>(3), km<>(2), km<>(1)}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -89,8 +89,8 @@ void vector_of_quantity_multiply_same() { std::cout << "\nvector_of_quantity_multiply_same:\n"; - vector> v = { m<>(1), m<>(2), m<>(3) }; - vector> u = { m<>(3), m<>(2), m<>(1) }; + vector> v = {m<>(1), m<>(2), m<>(3)}; + vector> u = {m<>(3), m<>(2), m<>(1)}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -103,8 +103,8 @@ void vector_of_quantity_multiply_different() { std::cout << "\nvector_of_quantity_multiply_different:\n"; - vector> v = { N<>(1), N<>(2), N<>(3) }; - vector> u = { m<>(3), m<>(2), m<>(1) }; + vector> v = {N<>(1), N<>(2), N<>(3)}; + vector> u = {m<>(3), m<>(2), m<>(1)}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -118,7 +118,7 @@ void vector_of_quantity_divide_by_scalar() { std::cout << "\nvector_of_quantity_divide_by_scalar:\n"; - vector> v = { m<>(4), m<>(8), m<>(12) }; + vector> v = {m<>(4), m<>(8), m<>(12)}; std::cout << "v = " << v << "\n"; @@ -139,9 +139,9 @@ void matrix_of_quantity_add() { std::cout << "\nmatrix_of_quantity_add:\n"; - matrix> v = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; - matrix> u = {{ m<>(3), m<>(2), m<>(1) }, { m<>(3), m<>(2), m<>(1) }, { m<>(3), m<>(2), m<>(1) }}; - matrix> t = {{ mm<>(3), mm<>(2), mm<>(1) }, { mm<>(3), mm<>(2), mm<>(1) }, { mm<>(3), mm<>(2), mm<>(1) }}; + matrix> v = {{m<>(1), m<>(2), m<>(3)}, {m<>(4), m<>(5), m<>(6)}, {m<>(7), m<>(8), m<>(9)}}; + matrix> u = {{m<>(3), m<>(2), m<>(1)}, {m<>(3), m<>(2), m<>(1)}, {m<>(3), m<>(2), m<>(1)}}; + matrix> t = {{mm<>(3), mm<>(2), mm<>(1)}, {mm<>(3), mm<>(2), mm<>(1)}, {mm<>(3), mm<>(2), mm<>(1)}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -158,8 +158,8 @@ void matrix_of_quantity_multiply_same() { std::cout << "\nmatrix_of_quantity_multiply_same:\n"; - matrix> v = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; - vector> u = { m<>(3), m<>(2), m<>(1) }; + matrix> v = {{m<>(1), m<>(2), m<>(3)}, {m<>(4), m<>(5), m<>(6)}, {m<>(7), m<>(8), m<>(9)}}; + vector> u = {m<>(3), m<>(2), m<>(1)}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -172,8 +172,8 @@ void matrix_of_quantity_multiply_different() { std::cout << "\nmatrix_of_quantity_multiply_different:\n"; - vector> v = { N<>(1), N<>(2), N<>(3) }; - matrix> u = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; + vector> v = {N<>(1), N<>(2), N<>(3)}; + matrix> u = {{m<>(1), m<>(2), m<>(3)}, {m<>(4), m<>(5), m<>(6)}, {m<>(7), m<>(8), m<>(9)}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -187,7 +187,7 @@ void matrix_of_quantity_divide_by_scalar() { std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n"; - matrix> v = {{ m<>(2), m<>(4), m<>(6) }, { m<>(4), m<>(6), m<>(8) }, { m<>(8), m<>(4), m<>(2) }}; + matrix> v = {{m<>(2), m<>(4), m<>(6)}, {m<>(4), m<>(6), m<>(8)}, {m<>(8), m<>(4), m<>(2)}}; std::cout << "v =\n" << v << "\n"; @@ -216,9 +216,9 @@ void quantity_of_vector_add() { std::cout << "\nquantity_of_vector_add:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); - length_v t(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); + length_v t(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -233,8 +233,8 @@ void quantity_of_vector_multiply_same() { std::cout << "\nquantity_of_vector_multiply_same:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -247,8 +247,8 @@ void quantity_of_vector_multiply_different() { std::cout << "\nquantity_of_vector_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + force_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -262,7 +262,7 @@ void quantity_of_vector_divide_by_scalar() { std::cout << "\nquantity_of_vector_divide_by_scalar:\n"; - length_v<> v(vector<>{ 4, 8, 12 }); + length_v<> v(vector<>{4, 8, 12}); std::cout << "v = " << v << "\n"; @@ -286,9 +286,9 @@ void quantity_of_matrix_add() { std::cout << "\nquantity_of_matrix_add:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_m<> u(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); - length_m t(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_m<> u(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); + length_m t(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -305,8 +305,8 @@ void quantity_of_matrix_multiply_same() { std::cout << "\nquantity_of_matrix_multiply_same:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_v<> u(vector<>{ 3, 2, 1 }); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -319,8 +319,8 @@ void quantity_of_matrix_multiply_different() { std::cout << "\nquantity_of_matrix_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_m<> u(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + force_v<> v(vector<>{1, 2, 3}); + length_m<> u(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -334,7 +334,7 @@ void quantity_of_matrix_divide_by_scalar() { std::cout << "\nquantity_of_matrix_divide_by_scalar:\n"; - length_m<> v(matrix<>{{ 2, 4, 6 }, { 4, 6, 8 }, { 8, 4, 2 }}); + length_m<> v(matrix<>{{2, 4, 6}, {4, 6, 8}, {8, 4, 2}}); std::cout << "v =\n" << v << "\n"; diff --git a/example/aliases/measurement.cpp b/example/aliases/measurement.cpp index ff91d62b..c952387b 100644 --- a/example/aliases/measurement.cpp +++ b/example/aliases/measurement.cpp @@ -38,8 +38,7 @@ public: measurement() = default; - constexpr explicit measurement(const value_type& val, const value_type& err = {}) : - value_(val) + constexpr explicit measurement(const value_type& val, const value_type& err = {}) : value_(val) { // it sucks that using declaration cannot be provided for a constructor initializer list using namespace std; diff --git a/example/aliases/total_energy.cpp b/example/aliases/total_energy.cpp index 693b47e4..0ad4c132 100644 --- a/example/aliases/total_energy.cpp +++ b/example/aliases/total_energy.cpp @@ -21,11 +21,11 @@ // SOFTWARE. #include +#include #include #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include #include #include @@ -85,18 +85,16 @@ void natural_example() << "E = " << E << "\n"; } -} // namespace +} // namespace int main() { try { si_example(); natural_example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/aliases/unknown_dimension.cpp b/example/aliases/unknown_dimension.cpp index 42df205e..5256abe8 100644 --- a/example/aliases/unknown_dimension.cpp +++ b/example/aliases/unknown_dimension.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -44,8 +44,9 @@ void example() Time auto t1 = s<>(10); Speed auto v1 = avg_speed(d1, t1); - auto temp1 = v1 * m<>(50); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - Speed auto v2 = temp1 / m<>(100); // back to known dimensions again + auto temp1 = + v1 * m<>(50); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' + Speed auto v2 = temp1 / m<>(100); // back to known dimensions again Length auto d2 = v2 * s<>(60); std::cout << "d1 = " << d1 << '\n'; @@ -56,17 +57,15 @@ void example() std::cout << "d2 = " << d2 << '\n'; } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/conversion_factor.cpp b/example/conversion_factor.cpp index 665b16e2..0858e954 100644 --- a/example/conversion_factor.cpp +++ b/example/conversion_factor.cpp @@ -54,7 +54,8 @@ int main() std::cout << STD_FMT::format("therefore ratio lengthA / lengthB == {}\n\n", lengthA / lengthB); - std::cout << STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n", lengthA, lengthB) + std::cout << STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n", lengthA, + lengthB) << STD_FMT::format("lengthB.number( {} ) == lengthA.number( {} ) * conversion_factor( {} )\n", - lengthB.number(), lengthA.number(), conversion_factor(lengthB, lengthA)); + lengthB.number(), lengthA.number(), conversion_factor(lengthB, lengthA)); } diff --git a/example/custom_systems.cpp b/example/custom_systems.cpp index f3264aed..f8dfd28f 100644 --- a/example/custom_systems.cpp +++ b/example/custom_systems.cpp @@ -66,10 +66,7 @@ using length = quantity; } // namespace si template -concept castable_to = Quantity && Unit && - requires (Q q) { - quantity_cast(q); - }; +concept castable_to = Quantity && Unit && requires(Q q) { quantity_cast(q); }; void conversions() { diff --git a/example/glide_computer/geographic.cpp b/example/glide_computer/geographic.cpp index 5d6073b3..4150c792 100644 --- a/example/glide_computer/geographic.cpp +++ b/example/glide_computer/geographic.cpp @@ -49,7 +49,8 @@ distance spherical_distance(position from, position to) if constexpr (sizeof(rep) >= 8) { // spherical law of cosines const auto central_angle = acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)); - // const auto central_angle = 2 * asin(sqrt(0.5 - cos(lat2 - lat1) / 2 + cos(lat1) * cos(lat2) * (1 - cos(lon2 - lon1)) / 2)); + // const auto central_angle = 2 * asin(sqrt(0.5 - cos(lat2 - lat1) / 2 + cos(lat1) * cos(lat2) * (1 - cos(lon2 - + // lon1)) / 2)); return distance(earth_radius * central_angle); } else { // the haversine formula diff --git a/example/glide_computer/glide_computer.cpp b/example/glide_computer/glide_computer.cpp index 79d325c1..fe7b7d62 100644 --- a/example/glide_computer/glide_computer.cpp +++ b/example/glide_computer/glide_computer.cpp @@ -34,7 +34,8 @@ task::legs task::make_legs(const waypoints& wpts) task::legs res; res.reserve(wpts.size() - 1); auto to_leg = [](const waypoint& w1, const waypoint& w2) { return task::leg(w1, w2); }; - std::ranges::transform(wpts.cbegin(), prev(wpts.cend()), next(wpts.cbegin()), wpts.cend(), std::back_inserter(res), to_leg); + std::ranges::transform(wpts.cbegin(), prev(wpts.cend()), next(wpts.cbegin()), wpts.cend(), std::back_inserter(res), + to_leg); return res; } @@ -64,24 +65,23 @@ distance glide_distance(const flight_point& pos, const glider& g, const task& t, ((ground_alt - t.get_finish().alt) / dist_to_finish - 1 / glide_ratio(g.polar[0]))); } -} +} // namespace glide_computer namespace { using namespace glide_computer; -void print(std::string_view phase_name, timestamp start_ts, const glide_computer::flight_point& point, const glide_computer::flight_point& new_point) +void print(std::string_view phase_name, timestamp start_ts, const glide_computer::flight_point& point, + const glide_computer::flight_point& new_point) { std::cout << STD_FMT::format( - "| {:<12} | {:>9%.1Q %q} (Total: {:>9%.1Q %q}) | {:>8%.1Q %q} (Total: {:>8%.1Q %q}) | {:>7%.0Q %q} ({:>6%.0Q %q}) |\n", - phase_name, quantity_cast(new_point.ts - point.ts), quantity_cast(new_point.ts - start_ts), - new_point.dist - point.dist, new_point.dist, new_point.alt - point.alt, new_point.alt); + "| {:<12} | {:>9%.1Q %q} (Total: {:>9%.1Q %q}) | {:>8%.1Q %q} (Total: {:>8%.1Q %q}) | {:>7%.0Q %q} ({:>6%.0Q %q}) " + "|\n", + phase_name, quantity_cast(new_point.ts - point.ts), quantity_cast(new_point.ts - start_ts), + new_point.dist - point.dist, new_point.dist, new_point.alt - point.alt, new_point.alt); } -flight_point takeoff(timestamp start_ts, const task& t) -{ - return {start_ts, t.get_start().alt}; -} +flight_point takeoff(timestamp start_ts, const task& t) { return {start_ts, t.get_start().alt}; } flight_point tow(timestamp start_ts, const flight_point& pos, const aircraft_tow& at) { @@ -92,7 +92,8 @@ flight_point tow(timestamp start_ts, const flight_point& pos, const aircraft_tow return new_pos; } -flight_point circle(timestamp start_ts, const flight_point& pos, const glider& g, const weather& w, const task& t, height& height_to_gain) +flight_point circle(timestamp start_ts, const flight_point& pos, const glider& g, const weather& w, const task& t, + height& height_to_gain) { const height h_agl = agl(pos.alt, terrain_level_alt(t, pos)); const height circling_height = std::min(w.cloud_base - h_agl, height_to_gain); @@ -114,7 +115,8 @@ flight_point glide(timestamp start_ts, const flight_point& pos, const glider& g, const auto alt = ground_alt + s.min_agl_height; const auto l3d = length_3d(dist, pos.alt - alt); const duration d = l3d / g.polar[0].v.common(); - const flight_point new_pos{pos.ts + d, terrain_level_alt(t, pos) + s.min_agl_height, t.get_leg_index(new_distance), new_distance}; + const flight_point new_pos{pos.ts + d, terrain_level_alt(t, pos) + s.min_agl_height, t.get_leg_index(new_distance), + new_distance}; print("Glide", start_ts, pos, new_pos); return new_pos; @@ -135,9 +137,11 @@ flight_point final_glide(timestamp start_ts, const flight_point& pos, const glid namespace glide_computer { -void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s, const aircraft_tow& at) +void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s, + const aircraft_tow& at) { - std::cout << STD_FMT::format("| {:<12} | {:^28} | {:^26} | {:^21} |\n", "Flight phase", "Duration", "Distance", "Height"); + std::cout << STD_FMT::format("| {:<12} | {:^28} | {:^26} | {:^21} |\n", "Flight phase", "Duration", "Distance", + "Height"); std::cout << STD_FMT::format("|{0:-^14}|{0:-^30}|{0:-^28}|{0:-^23}|\n", ""); // ready to takeoff diff --git a/example/glide_computer/include/geographic.h b/example/glide_computer/include/geographic.h index 5deb1b1c..44290080 100644 --- a/example/glide_computer/include/geographic.h +++ b/example/glide_computer/include/geographic.h @@ -25,7 +25,6 @@ #include #include #include - #include #include diff --git a/example/glide_computer/include/glide_computer.h b/example/glide_computer/include/glide_computer.h index 7202005a..d545ea7a 100644 --- a/example/glide_computer/include/glide_computer.h +++ b/example/glide_computer/include/glide_computer.h @@ -32,14 +32,14 @@ #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include // An example of a really simplified tactical glide computer @@ -69,7 +69,7 @@ namespace glide_computer { template constexpr units::Dimensionless auto operator/(const QK1& lhs, const QK2& rhs) - requires(!units::QuantityKindRelatedTo) && requires { lhs.common() / rhs.common();} + requires(!units::QuantityKindRelatedTo) && requires { lhs.common() / rhs.common(); } { return lhs.common() / rhs.common(); } @@ -149,7 +149,7 @@ public: const waypoint* end_; distance length_ = geographic::spherical_distance(begin().pos, end().pos); public: - leg(const waypoint& b, const waypoint& e) noexcept: begin_(&b), end_(&e) {} + leg(const waypoint& b, const waypoint& e) noexcept : begin_(&b), end_(&e) {} constexpr const waypoint& begin() const { return *begin_; }; constexpr const waypoint& end() const { return *end_; } constexpr const distance get_length() const { return length_; } @@ -157,8 +157,11 @@ public: using legs = std::vector; template - requires std::same_as, waypoint> - explicit task(const R& r) : waypoints_(std::ranges::begin(r), std::ranges::end(r)) {} + requires std::same_as, + waypoint> explicit task(const R& r) : + waypoints_(std::ranges::begin(r), std::ranges::end(r)) + { + } task(std::initializer_list wpts) : waypoints_(wpts) {} @@ -170,10 +173,14 @@ public: distance get_length() const { return length_; } - distance get_leg_dist_offset(std::size_t leg_index) const { return leg_index == 0 ? distance{} : leg_total_distances_[leg_index - 1]; } + distance get_leg_dist_offset(std::size_t leg_index) const + { + return leg_index == 0 ? distance{} : leg_total_distances_[leg_index - 1]; + } std::size_t get_leg_index(distance dist) const { - return static_cast(std::ranges::distance(leg_total_distances_.cbegin(), std::ranges::lower_bound(leg_total_distances_, dist))); + return static_cast( + std::ranges::distance(leg_total_distances_.cbegin(), std::ranges::lower_bound(leg_total_distances_, dist))); } private: @@ -214,6 +221,7 @@ inline units::isq::si::length length_3d(distance dist distance glide_distance(const flight_point& pos, const glider& g, const task& t, const safety& s, altitude ground_alt); -void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s, const aircraft_tow& at); +void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s, + const aircraft_tow& at); } // namespace glide_computer diff --git a/example/hello_units.cpp b/example/hello_units.cpp index 6b339036..5bfbc860 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -22,19 +22,16 @@ #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include using namespace units::isq; -constexpr Speed auto avg_speed(Length auto d, Time auto t) -{ - return d / t; -} +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } int main() { @@ -55,11 +52,11 @@ int main() #endif constexpr Speed auto v7 = quantity_cast(v6); - std::cout << v1 << '\n'; // 110 km/h - std::cout << v2 << '\n'; // 70 mi/h - std::cout << STD_FMT::format("{}", v3) << '\n'; // 110 km/h - std::cout << STD_FMT::format("{:*^14}", v4) << '\n'; // ***70 mi/h**** - std::cout << STD_FMT::format("{:%Q in %q}", v5) << '\n'; // 30.5556 in m/s - std::cout << STD_FMT::format("{0:%Q} in {0:%q}", v6) << '\n'; // 31.2928 in m/s - std::cout << STD_FMT::format("{:%Q}", v7) << '\n'; // 31 + std::cout << v1 << '\n'; // 110 km/h + std::cout << v2 << '\n'; // 70 mi/h + std::cout << STD_FMT::format("{}", v3) << '\n'; // 110 km/h + std::cout << STD_FMT::format("{:*^14}", v4) << '\n'; // ***70 mi/h**** + std::cout << STD_FMT::format("{:%Q in %q}", v5) << '\n'; // 30.5556 in m/s + std::cout << STD_FMT::format("{0:%Q} in {0:%q}", v6) << '\n'; // 31.2928 in m/s + std::cout << STD_FMT::format("{:%Q}", v7) << '\n'; // 31 } diff --git a/example/kalman_filter/kalman.h b/example/kalman_filter/kalman.h index 46b0354f..16a21375 100644 --- a/example/kalman_filter/kalman.h +++ b/example/kalman_filter/kalman.h @@ -34,7 +34,8 @@ namespace kalman { template -concept QuantityOrQuantityPoint = units::Quantity || units::QuantityPoint; // TODO Should it also account for `kinds`? +concept QuantityOrQuantityPoint = + units::Quantity || units::QuantityPoint; // TODO Should it also account for `kinds`? template inline constexpr bool are_derivatives = false; @@ -44,34 +45,42 @@ inline constexpr bool are_derivatives = true; template inline constexpr bool are_derivatives = - units::DimensionOfT && // TODO Think on how to simplify this + units::DimensionOfT && // TODO Think on how to simplify this are_derivatives; // state template - requires (sizeof...(QQPs) > 0) && (sizeof...(QQPs) <= 3) && are_derivatives + requires(sizeof...(QQPs) > 0) && (sizeof...(QQPs) <= 3) && are_derivatives struct state { std::tuple variables_; - constexpr state(QQPs... qqps): variables_(std::move(qqps)...) {} + constexpr state(QQPs... qqps) : variables_(std::move(qqps)...) {} }; template concept State = units::is_specialization_of; template -constexpr auto& get(state& s) { return get(s.variables_); } +constexpr auto& get(state& s) +{ + return get(s.variables_); +} template -constexpr const auto& get(const state& s) { return get(s.variables_); } +constexpr const auto& get(const state& s) +{ + return get(s.variables_); +} // estimation template struct estimation { private: using uncertainty_ref = decltype(QQP::reference * QQP::reference); - using uncertainty_type = units::quantity; + using uncertainty_type = + units::quantity; public: - kalman::state state; // TODO extend kalman functions to work with this variadic patermater list + kalman::state state; // TODO extend kalman functions to work with this variadic patermater list uncertainty_type uncertainty; }; @@ -94,7 +103,7 @@ template requires units::equivalent constexpr state state_update(const state& predicted, QM measured, K gain) { - return { get<0>(predicted) + gain * (measured - get<0>(predicted)) }; + return {get<0>(predicted) + gain * (measured - get<0>(predicted))}; } template @@ -103,17 +112,18 @@ constexpr state state_update(const state& predicted, QM measured { const auto q1 = get<0>(predicted) + get<0>(gain) * (measured - get<0>(predicted)); const auto q2 = get<1>(predicted) + get<1>(gain) * (measured - get<0>(predicted)) / interval; - return { q1, q2 }; + return {q1, q2}; } template requires units::equivalent -constexpr state state_update(const state& predicted, QM measured, std::array gain, T interval) +constexpr state state_update(const state& predicted, QM measured, std::array gain, + T interval) { const auto q1 = get<0>(predicted) + get<0>(gain) * (measured - get<0>(predicted)); const auto q2 = get<1>(predicted) + get<1>(gain) * (measured - get<0>(predicted)) / interval; const auto q3 = get<2>(predicted) + get<2>(gain) * (measured - get<0>(predicted)) / (interval * interval / 2); - return { q1, q2, q3 }; + return {q1, q2, q3}; } // covariance update @@ -129,7 +139,7 @@ constexpr state state_extrapolation(const state& estimated, T in { const auto q1 = get<0>(estimated) + get<1>(estimated) * interval; const auto q2 = get<1>(estimated); - return { q1, q2 }; + return {q1, q2}; } template @@ -138,7 +148,7 @@ constexpr state state_extrapolation(const state& estimat const auto q1 = get<0>(estimated) + get<1>(estimated) * interval + get<2>(estimated) * pow<2>(interval) / 2; const auto q2 = get<1>(estimated) + get<2>(estimated) * interval; const auto q3 = get<2>(estimated); - return { q1, q2, q3 }; + return {q1, q2, q3}; } // covariance extrapolation @@ -164,24 +174,26 @@ struct STD_FMT::formatter> { std::string value_buffer; auto to_value_buffer = std::back_inserter(value_buffer); if (specs.precision != -1) { - if constexpr(sizeof...(Qs) == 1) + if constexpr (sizeof...(Qs) == 1) STD_FMT::format_to(to_value_buffer, "{1:%.{0}Q %q}", specs.precision, kalman::get<0>(s)); - else if constexpr(sizeof...(Qs) == 2) - STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), kalman::get<1>(s)); + else if constexpr (sizeof...(Qs) == 2) + STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), + kalman::get<1>(s)); else - STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q}, {3:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s)); - } - else { - if constexpr(sizeof...(Qs) == 1) + STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q}, {3:%.{0}Q %q} }}", specs.precision, + kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s)); + } else { + if constexpr (sizeof...(Qs) == 1) STD_FMT::format_to(to_value_buffer, "{}", kalman::get<0>(s)); - else if constexpr(sizeof...(Qs) == 2) + else if constexpr (sizeof...(Qs) == 2) STD_FMT::format_to(to_value_buffer, "{{ {}, {} }}", kalman::get<0>(s), kalman::get<1>(s)); else - STD_FMT::format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s)); + STD_FMT::format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s), + kalman::get<2>(s)); } std::string global_format_buffer; - units::detail::quantity_global_format_specs global_specs = { specs.fill, specs.align, specs.width }; + units::detail::quantity_global_format_specs global_specs = {specs.fill, specs.align, specs.width}; units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs); return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer)); @@ -202,7 +214,7 @@ struct STD_FMT::formatter> { auto format(kalman::estimation e, FormatContext& ctx) { units::Quantity auto q = [](const Q& t) { - if constexpr(units::Quantity) + if constexpr (units::Quantity) return t; else return t.relative(); @@ -212,13 +224,12 @@ struct STD_FMT::formatter> { auto to_value_buffer = std::back_inserter(value_buffer); if (specs.precision != -1) { STD_FMT::format_to(to_value_buffer, "{0:%.{2}Q} ± {1:%.{2}Q} {0:%q}", q, sqrt(e.uncertainty), specs.precision); - } - else { + } else { STD_FMT::format_to(to_value_buffer, "{0:%Q} ± {1:%Q} {0:%q}", q, sqrt(e.uncertainty)); } std::string global_format_buffer; - units::detail::quantity_global_format_specs global_specs = { specs.fill, specs.align, specs.width }; + units::detail::quantity_global_format_specs global_specs = {specs.fill, specs.align, specs.width}; units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs); return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer)); diff --git a/example/kalman_filter/kalman_filter-example_1.cpp b/example/kalman_filter/kalman_filter-example_1.cpp index 91057277..efd624ae 100644 --- a/example/kalman_filter/kalman_filter-example_1.cpp +++ b/example/kalman_filter/kalman_filter-example_1.cpp @@ -21,9 +21,9 @@ // SOFTWARE. #include "kalman.h" -#include #include #include +#include #include #include @@ -34,10 +34,12 @@ using namespace units; void print_header(const kalman::State auto& initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>9} | {:>8} | {:>14} | {:>14}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>9} | {:>8} | {:>14} | {:>14}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } -void print(auto iteration, Dimensionless auto gain, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next) +void print(auto iteration, Dimensionless auto gain, Quantity auto measured, const kalman::State auto& current, + const kalman::State auto& next) { std::cout << STD_FMT::format("{:2} | {:9} | {:8} | {:14} | {:14}\n", iteration, gain, measured, current, next); } @@ -48,13 +50,13 @@ int main() using namespace units::isq::si::references; using state = kalman::state>; - const state initial = { 1 * kg }; - const std::array measurements = { 1030 * g, 989 * g, 1017 * g, 1009 * g, 1013 * g, - 979 * g, 1008 * g, 1042 * g, 1012 * g, 1011 * g }; + const state initial = {1 * kg}; + const std::array measurements = {1030 * g, 989 * g, 1017 * g, 1009 * g, 1013 * g, + 979 * g, 1008 * g, 1042 * g, 1012 * g, 1011 * g}; print_header(initial); state next = initial; - for(int index = 1; const auto& m : measurements) { + for (int index = 1; const auto& m : measurements) { const auto& previous = next; const dimensionless gain = 1. / index; const auto current = state_update(previous, m, gain); diff --git a/example/kalman_filter/kalman_filter-example_2.cpp b/example/kalman_filter/kalman_filter-example_2.cpp index 222bd165..23ea2bbf 100644 --- a/example/kalman_filter/kalman_filter-example_2.cpp +++ b/example/kalman_filter/kalman_filter-example_2.cpp @@ -21,11 +21,11 @@ // SOFTWARE. #include "kalman.h" +#include +#include #include #include #include -#include -#include #include #include @@ -51,14 +51,14 @@ int main() using state = kalman::state, si::speed>; const auto interval = 5 * s; - const state initial = { 30 * km, 40 * (m / s) }; - const std::array measurements = { 30110 * m, 30265 * m, 30740 * m, 30750 * m, 31135 * m, - 31015 * m, 31180 * m, 31610 * m, 31960 * m, 31865 * m }; + const state initial = {30 * km, 40 * (m / s)}; + const std::array measurements = {30110 * m, 30265 * m, 30740 * m, 30750 * m, 31135 * m, + 31015 * m, 31180 * m, 31610 * m, 31960 * m, 31865 * m}; std::array gain = {dimensionless(0.2), dimensionless(0.1)}; print_header(initial); state next = state_extrapolation(initial, interval); - for(int index = 1; const auto& measured : measurements) { + for (int index = 1; const auto& measured : measurements) { const auto& previous = next; const auto current = state_update(previous, measured, gain, interval); next = state_extrapolation(current, interval); diff --git a/example/kalman_filter/kalman_filter-example_3.cpp b/example/kalman_filter/kalman_filter-example_3.cpp index 7a7c0291..267e8a3d 100644 --- a/example/kalman_filter/kalman_filter-example_3.cpp +++ b/example/kalman_filter/kalman_filter-example_3.cpp @@ -21,11 +21,11 @@ // SOFTWARE. #include "kalman.h" +#include +#include #include #include #include -#include -#include #include #include @@ -51,14 +51,14 @@ int main() using state = kalman::state, si::speed>; const auto interval = 5 * s; - const state initial = { 30 * km, 50 * (m / s) }; - const std::array measurements = { 30160 * m, 30365 * m, 30890 * m, 31050 * m, 31785 * m, - 32215 * m, 33130 * m, 34510 * m, 36010 * m, 37265 * m }; + const state initial = {30 * km, 50 * (m / s)}; + const std::array measurements = {30160 * m, 30365 * m, 30890 * m, 31050 * m, 31785 * m, + 32215 * m, 33130 * m, 34510 * m, 36010 * m, 37265 * m}; std::array gain = {dimensionless(0.2), dimensionless(0.1)}; print_header(initial); state next = state_extrapolation(initial, interval); - for(int index = 1; const auto& measured : measurements) { + for (int index = 1; const auto& measured : measurements) { const auto& previous = next; const auto current = state_update(previous, measured, gain, interval); next = state_extrapolation(current, interval); diff --git a/example/kalman_filter/kalman_filter-example_4.cpp b/example/kalman_filter/kalman_filter-example_4.cpp index c6692b12..0ba7e36d 100644 --- a/example/kalman_filter/kalman_filter-example_4.cpp +++ b/example/kalman_filter/kalman_filter-example_4.cpp @@ -21,12 +21,12 @@ // SOFTWARE. #include "kalman.h" +#include +#include #include #include #include #include -#include -#include #include #include @@ -49,19 +49,20 @@ int main() { using namespace units::isq; using namespace units::isq::si::references; - using state = kalman::state, si::speed, si::acceleration>; + using state = + kalman::state, si::speed, si::acceleration>; constexpr auto mps = m / s; constexpr auto mps2 = mps / s; const auto interval = 5. * s; - const state initial = { 30 * km, 50 * mps, 0 * mps2 }; - const std::array measurements = { 30160 * m, 30365 * m, 30890 * m, 31050 * m, 31785 * m, - 32215 * m, 33130 * m, 34510 * m, 36010 * m, 37265 * m }; + const state initial = {30 * km, 50 * mps, 0 * mps2}; + const std::array measurements = {30160 * m, 30365 * m, 30890 * m, 31050 * m, 31785 * m, + 32215 * m, 33130 * m, 34510 * m, 36010 * m, 37265 * m}; std::array gain = {dimensionless(0.5), dimensionless(0.4), dimensionless(0.1)}; print_header(initial); state next = state_extrapolation(initial, interval); - for(int index = 1; const auto& measured : measurements) { + for (int index = 1; const auto& measured : measurements) { const auto& previous = next; const auto current = state_update(previous, measured, gain, interval); next = state_extrapolation(current, interval); diff --git a/example/kalman_filter/kalman_filter-example_5.cpp b/example/kalman_filter/kalman_filter-example_5.cpp index 47db0134..d68f9601 100644 --- a/example/kalman_filter/kalman_filter-example_5.cpp +++ b/example/kalman_filter/kalman_filter-example_5.cpp @@ -21,8 +21,8 @@ // SOFTWARE. #include "kalman.h" -#include #include +#include #include #include #include @@ -35,13 +35,15 @@ template void print_header(kalman::estimation initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>5} | {:>8} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>5} | {:>8} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } template void print(auto iteration, K gain, Q measured, kalman::estimation current, kalman::estimation next) { - std::cout << STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured, current, next); + std::cout << STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured, current, + next); } int main() @@ -50,20 +52,20 @@ int main() using namespace units::isq; using namespace units::isq::si::references; - const estimation initial = { state{ 60. * m }, pow<2>(15. * m) }; - const std::array measurements = { 48.54 * m, 47.11 * m, 55.01 * m, 55.15 * m, 49.89 * m, - 40.85 * m, 46.72 * m, 50.05 * m, 51.27 * m, 49.95 * m }; + const estimation initial = {state{60. * m}, pow<2>(15. * m)}; + const std::array measurements = {48.54 * m, 47.11 * m, 55.01 * m, 55.15 * m, 49.89 * m, + 40.85 * m, 46.72 * m, 50.05 * m, 51.27 * m, 49.95 * m}; const auto measurement_uncertainty = pow<2>(5. * m); auto update = [=](const estimation& previous, const Q& meassurement, Dimensionless auto gain) { - return estimation{ state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain) }; + return estimation{state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain)}; }; auto predict = [](const estimation& current) { return current; }; print_header(initial); estimation next = predict(initial); - for(int index = 1; const auto& measured : measurements) { + for (int index = 1; const auto& measured : measurements) { const auto& previous = next; const auto gain = kalman_gain(previous.uncertainty, measurement_uncertainty); const estimation current = update(previous, measured, gain); diff --git a/example/kalman_filter/kalman_filter-example_6.cpp b/example/kalman_filter/kalman_filter-example_6.cpp index e17045da..fac8c34b 100644 --- a/example/kalman_filter/kalman_filter-example_6.cpp +++ b/example/kalman_filter/kalman_filter-example_6.cpp @@ -21,8 +21,8 @@ // SOFTWARE. #include "kalman.h" -#include #include +#include #include #include #include @@ -56,13 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { - std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, measured.relative(), current, next); + std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, + measured.relative(), current, next); } int main() @@ -72,32 +74,25 @@ int main() using namespace units::isq::si::references; const auto process_noise_variance = 0.0001 * (deg_C * deg_C); - const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) }; - const std::array measurements = { - quantity_point(49.95 * deg_C), - quantity_point(49.967 * deg_C), - quantity_point(50.1 * deg_C), - quantity_point(50.106 * deg_C), - quantity_point(49.992 * deg_C), - quantity_point(49.819 * deg_C), - quantity_point(49.933 * deg_C), - quantity_point(50.007 * deg_C), - quantity_point(50.023 * deg_C), - quantity_point(49.99 * deg_C) - }; + const estimation initial = {state{quantity_point(10. * deg_C)}, pow<2>(100. * deg_C)}; + const std::array measurements = {quantity_point(49.95 * deg_C), quantity_point(49.967 * deg_C), + quantity_point(50.1 * deg_C), quantity_point(50.106 * deg_C), + quantity_point(49.992 * deg_C), quantity_point(49.819 * deg_C), + quantity_point(49.933 * deg_C), quantity_point(50.007 * deg_C), + quantity_point(50.023 * deg_C), quantity_point(49.99 * deg_C)}; const auto measurement_uncertainty = pow<2>(0.1 * deg_C); auto update = [=](const estimation& previous, const QP& meassurement, Dimensionless auto gain) { - return estimation{ state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain) }; + return estimation{state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain)}; }; auto predict = [=](const estimation& current) { - return estimation{ current.state, covariance_extrapolation(current.uncertainty, process_noise_variance) }; + return estimation{current.state, covariance_extrapolation(current.uncertainty, process_noise_variance)}; }; print_header(initial); estimation next = predict(initial); - for(int index = 1; const auto& m : measurements) { + for (int index = 1; const auto& m : measurements) { const auto& previous = next; const auto gain = kalman_gain(previous.uncertainty, measurement_uncertainty); const estimation current = update(previous, m, gain); diff --git a/example/kalman_filter/kalman_filter-example_7.cpp b/example/kalman_filter/kalman_filter-example_7.cpp index 743a0916..42ce7025 100644 --- a/example/kalman_filter/kalman_filter-example_7.cpp +++ b/example/kalman_filter/kalman_filter-example_7.cpp @@ -21,8 +21,8 @@ // SOFTWARE. #include "kalman.h" -#include #include +#include #include #include #include @@ -56,13 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { - std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, measured.relative(), current, next); + std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, + measured.relative(), current, next); } int main() @@ -72,32 +74,25 @@ int main() using namespace units::isq::si::references; const auto process_noise_variance = 0.0001 * (deg_C * deg_C); - const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) }; - const std::array measurements = { - quantity_point(50.45 * deg_C), - quantity_point(50.967 * deg_C), - quantity_point(51.6 * deg_C), - quantity_point(52.106 * deg_C), - quantity_point(52.492 * deg_C), - quantity_point(52.819 * deg_C), - quantity_point(53.433 * deg_C), - quantity_point(54.007 * deg_C), - quantity_point(54.523 * deg_C), - quantity_point(54.99 * deg_C) - }; + const estimation initial = {state{quantity_point(10. * deg_C)}, pow<2>(100. * deg_C)}; + const std::array measurements = {quantity_point(50.45 * deg_C), quantity_point(50.967 * deg_C), + quantity_point(51.6 * deg_C), quantity_point(52.106 * deg_C), + quantity_point(52.492 * deg_C), quantity_point(52.819 * deg_C), + quantity_point(53.433 * deg_C), quantity_point(54.007 * deg_C), + quantity_point(54.523 * deg_C), quantity_point(54.99 * deg_C)}; const auto measurement_uncertainty = pow<2>(0.1 * deg_C); auto update = [=](const estimation& previous, const QP& meassurement, Dimensionless auto gain) { - return estimation{ state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain) }; + return estimation{state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain)}; }; auto predict = [=](const estimation& current) { - return estimation{ current.state, covariance_extrapolation(current.uncertainty, process_noise_variance) }; + return estimation{current.state, covariance_extrapolation(current.uncertainty, process_noise_variance)}; }; print_header(initial); estimation next = predict(initial); - for(int index = 1; const auto& m : measurements) { + for (int index = 1; const auto& m : measurements) { const auto& previous = next; const auto gain = kalman_gain(previous.uncertainty, measurement_uncertainty); const estimation current = update(previous, m, gain); diff --git a/example/kalman_filter/kalman_filter-example_8.cpp b/example/kalman_filter/kalman_filter-example_8.cpp index 13f379f1..3b81ae70 100644 --- a/example/kalman_filter/kalman_filter-example_8.cpp +++ b/example/kalman_filter/kalman_filter-example_8.cpp @@ -21,8 +21,8 @@ // SOFTWARE. #include "kalman.h" -#include #include +#include #include #include #include @@ -56,13 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << STD_FMT::format("Initial: {}\n", initial); - std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", + "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { - std::cout << STD_FMT::format("{:2} | {:7%.3Q} | {:10%.3Q %q} | {:>16.2} | {:>16.2}\n", iteration, gain, measured.relative(), current, next); + std::cout << STD_FMT::format("{:2} | {:7%.3Q} | {:10%.3Q %q} | {:>16.2} | {:>16.2}\n", iteration, gain, + measured.relative(), current, next); } int main() @@ -72,32 +74,25 @@ int main() using namespace units::isq::si::references; const auto process_noise_variance = 0.15 * (deg_C * deg_C); - const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) }; - const std::array measurements = { - quantity_point(50.45 * deg_C), - quantity_point(50.967 * deg_C), - quantity_point(51.6 * deg_C), - quantity_point(52.106 * deg_C), - quantity_point(52.492 * deg_C), - quantity_point(52.819 * deg_C), - quantity_point(53.433 * deg_C), - quantity_point(54.007 * deg_C), - quantity_point(54.523 * deg_C), - quantity_point(54.99 * deg_C) - }; + const estimation initial = {state{quantity_point(10. * deg_C)}, pow<2>(100. * deg_C)}; + const std::array measurements = {quantity_point(50.45 * deg_C), quantity_point(50.967 * deg_C), + quantity_point(51.6 * deg_C), quantity_point(52.106 * deg_C), + quantity_point(52.492 * deg_C), quantity_point(52.819 * deg_C), + quantity_point(53.433 * deg_C), quantity_point(54.007 * deg_C), + quantity_point(54.523 * deg_C), quantity_point(54.99 * deg_C)}; const auto measurement_uncertainty = pow<2>(0.1 * deg_C); auto update = [=](const estimation& previous, const QP& meassurement, Dimensionless auto gain) { - return estimation{ state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain) }; + return estimation{state_update(previous.state, meassurement, gain), covariance_update(previous.uncertainty, gain)}; }; auto predict = [=](const estimation& current) { - return estimation{ current.state, covariance_extrapolation(current.uncertainty, process_noise_variance) }; + return estimation{current.state, covariance_extrapolation(current.uncertainty, process_noise_variance)}; }; print_header(initial); estimation next = predict(initial); - for(int index = 1; const auto& m : measurements) { + for (int index = 1; const auto& m : measurements) { const auto& previous = next; const auto gain = kalman_gain(previous.uncertainty, measurement_uncertainty); const estimation current = update(previous, m, gain); diff --git a/example/literals/avg_speed.cpp b/example/literals/avg_speed.cpp index 2c13fae9..5a3f3e05 100644 --- a/example/literals/avg_speed.cpp +++ b/example/literals/avg_speed.cpp @@ -21,12 +21,12 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include +#include #include #include #include @@ -35,38 +35,31 @@ namespace { using namespace units::isq; -constexpr si::speed -fixed_int_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_int_si_avg_speed(si::length d, + si::time t) { return d / t; } -constexpr si::speed -fixed_double_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_double_si_avg_speed(si::length d, si::time t) { return d / t; } template -constexpr Speed auto si_avg_speed(si::length d, - si::time t) +constexpr Speed auto si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr Speed auto avg_speed(Length auto d, Time auto t) -{ - return d / t; -} +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } template void print_result(D distance, T duration, V speed) { const auto result_in_kmph = units::quantity_cast>(speed); - std::cout << "Average speed of a car that makes " << distance << " in " - << duration << " is " << result_in_kmph << ".\n"; + std::cout << "Average speed of a car that makes " << distance << " in " << duration << " is " << result_in_kmph + << ".\n"; } void example() @@ -94,7 +87,8 @@ void example() std::cout << "\nSI units with 'double' as representation\n"; // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); + print_result(distance, duration, + fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -130,7 +124,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // also it is not possible to make a lossless conversion of miles to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -141,7 +137,7 @@ void example() { using namespace units::isq::si::cgs::literals; constexpr auto distance = 22'000'000_q_cm; - constexpr si::cgs::time duration(2); // cannot use an SI literal here + constexpr si::cgs::time duration(2); // cannot use an SI literal here std::cout << "\nCGS units with 'int' as representation\n"; @@ -160,14 +156,16 @@ void example() { using namespace units::isq::si::cgs::literals; constexpr auto distance = 22'000'000._q_cm; - constexpr si::cgs::time duration(2); // cannot use an SI literal here + constexpr si::cgs::time duration(2); // cannot use an SI literal here std::cout << "\nCGS units with 'double' as representation\n"; // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // it is not possible to make a lossless conversion of centimeters to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); @@ -176,20 +174,17 @@ void example() print_result(distance, duration, avg_speed(distance, duration)); } - } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/literals/box_example.cpp b/example/literals/box_example.cpp index a736f6bd..7716d787 100644 --- a/example/literals/box_example.cpp +++ b/example/literals/box_example.cpp @@ -29,7 +29,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -56,7 +56,10 @@ class Box { si::length height_; si::density density_ = air_density; public: - constexpr Box(const si::length& length, const si::length& width, si::length height) : base_(length * width), height_(std::move(height)) {} + constexpr Box(const si::length& length, const si::length& width, si::length height) : + base_(length * width), height_(std::move(height)) + { + } [[nodiscard]] constexpr si::force filled_weight() const { @@ -94,13 +97,13 @@ int main() auto box = Box(1000.0_q_mm, 500.0_q_mm, height); box.set_contents_density(1000.0_q_kg_per_m3); - const auto fill_time = 200.0_q_s; // time since starting fill - const auto measured_mass = 20.0_q_kg; // measured mass at fill_time + const auto fill_time = 200.0_q_s; // time since starting fill + const auto measured_mass = 20.0_q_kg; // measured mass at fill_time const Length auto fill_level = box.fill_level(measured_mass); const Dimensionless auto fill_percent = quantity_cast(fill_level / height); const Volume auto spare_capacity = box.spare_capacity(measured_mass); - const auto input_flow_rate = measured_mass / fill_time; // unknown dimension + const auto input_flow_rate = measured_mass / fill_time; // unknown dimension const Speed auto float_rise_rate = fill_level / fill_time; const Time auto fill_time_left = (height / fill_level - 1) * fill_time; diff --git a/example/literals/capacitor_time_curve.cpp b/example/literals/capacitor_time_curve.cpp index e1300e91..e844f359 100644 --- a/example/literals/capacitor_time_curve.cpp +++ b/example/literals/capacitor_time_curve.cpp @@ -26,7 +26,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include diff --git a/example/literals/foot_pound_second.cpp b/example/literals/foot_pound_second.cpp index 317b127c..69df4f51 100644 --- a/example/literals/foot_pound_second.cpp +++ b/example/literals/foot_pound_second.cpp @@ -53,7 +53,7 @@ struct Ship { }; // Print 'a' in its current units and print its value cast to the units in each of Args -template +template auto fmt_line(const Q a) { return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast(a)) + ...); @@ -65,16 +65,27 @@ void print_details(std::string_view description, const Ship& ship) using namespace units::isq::si::fps::literals; const auto waterDensity = 62.4_q_lb_per_ft3; std::cout << STD_FMT::format("{}\n", description); - std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length>(ship.length)) - << STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length>(ship.draft)) - << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length>(ship.beam)) - << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass>(ship.mass)) - << STD_FMT::format("{:20} : {}\n", "speed", fmt_line, si::speed>(ship.speed)) - << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power>(ship.power)) - << STD_FMT::format("{:20} : {}\n", "main guns", fmt_line, si::length>(ship.mainGuns)) - << STD_FMT::format("{:20} : {}\n", "fire shells weighing",fmt_line, si::mass>(ship.shellMass)) - << STD_FMT::format("{:20} : {}\n", "fire shells at",fmt_line, si::speed>(ship.shellSpeed)) - << STD_FMT::format("{:20} : {}\n", "volume underwater", fmt_line, si::volume>(ship.mass / waterDensity)); + std::cout << STD_FMT::format("{:20} : {}\n", "length", + fmt_line, si::length>(ship.length)) + << STD_FMT::format("{:20} : {}\n", "draft", + fmt_line, si::length>(ship.draft)) + << STD_FMT::format("{:20} : {}\n", "beam", + fmt_line, si::length>(ship.beam)) + << STD_FMT::format("{:20} : {}\n", "mass", + fmt_line, si::mass>(ship.mass)) + << STD_FMT::format("{:20} : {}\n", "speed", + fmt_line, si::speed>(ship.speed)) + << STD_FMT::format("{:20} : {}\n", "power", + fmt_line, si::power>(ship.power)) + << STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length>(ship.mainGuns)) + << STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass>(ship.shellMass)) + << STD_FMT::format( + "{:20} : {}\n", "fire shells at", + fmt_line, si::speed>(ship.shellSpeed)) + << STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume>(ship.mass / waterDensity)); } int main() @@ -83,13 +94,37 @@ int main() using namespace units::isq::si::fps::literals; // KMS Bismark, using the units the Germans would use, taken from Wiki - auto bismark = Ship{.length{251._q_m}, .draft{9.3_q_m}, .beam{36_q_m}, .speed{56_q_km_per_h}, .mass{50'300_q_t}, .mainGuns{380_q_mm}, .shellMass{800_q_kg}, .shellSpeed{820._q_m_per_s}, .power{110.45_q_kW}}; + auto bismark = Ship{.length{251._q_m}, + .draft{9.3_q_m}, + .beam{36_q_m}, + .speed{56_q_km_per_h}, + .mass{50'300_q_t}, + .mainGuns{380_q_mm}, + .shellMass{800_q_kg}, + .shellSpeed{820._q_m_per_s}, + .power{110.45_q_kW}}; // USS Iowa, using units from the foot-pound-second system - auto iowa = Ship{.length{860._q_ft}, .draft{37._q_ft + 2._q_in}, .beam{108._q_ft + 2._q_in}, .speed{33_q_knot}, .mass{57'540_q_lton}, .mainGuns{16_q_in}, .shellMass{2700_q_lb}, .shellSpeed{2690._q_ft_per_s}, .power{212'000_q_hp}}; + auto iowa = Ship{.length{860._q_ft}, + .draft{37._q_ft + 2._q_in}, + .beam{108._q_ft + 2._q_in}, + .speed{33_q_knot}, + .mass{57'540_q_lton}, + .mainGuns{16_q_in}, + .shellMass{2700_q_lb}, + .shellSpeed{2690._q_ft_per_s}, + .power{212'000_q_hp}}; // HMS King George V, using units from the foot-pound-second system - auto kgv = Ship{.length{745.1_q_ft}, .draft{33._q_ft + 7.5_q_in}, .beam{103.2_q_ft + 2.5_q_in}, .speed{28.3_q_knot}, .mass{42'245_q_lton}, .mainGuns{14_q_in}, .shellMass{1'590_q_lb}, .shellSpeed{2483._q_ft_per_s}, .power{110'000_q_hp}}; + auto kgv = Ship{.length{745.1_q_ft}, + .draft{33._q_ft + 7.5_q_in}, + .beam{103.2_q_ft + 2.5_q_in}, + .speed{28.3_q_knot}, + .mass{42'245_q_lton}, + .mainGuns{14_q_in}, + .shellMass{1'590_q_lb}, + .shellSpeed{2483._q_ft_per_s}, + .power{110'000_q_hp}}; print_details("KMS Bismark, defined in appropriate units from the SI system", bismark); std::cout << "\n\n"; diff --git a/example/literals/glide_computer_example.cpp b/example/literals/glide_computer_example.cpp index f3a2a832..60bf096a 100644 --- a/example/literals/glide_computer_example.cpp +++ b/example/literals/glide_computer_example.cpp @@ -25,7 +25,6 @@ #include #include #include - #include #include #include @@ -43,14 +42,14 @@ using namespace units::isq; auto get_gliders() { using namespace si::literals; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES static const std::array gliders = { - glider{"SZD-30 Pirat", {velocity(83_q_km_per_h), rate_of_climb(-0.7389_q_m_per_s)}}, - glider{"SZD-51 Junior", {velocity(80_q_km_per_h), rate_of_climb(-0.6349_q_m_per_s)}}, - glider{"SZD-48 Jantar Std 3", {velocity(110_q_km_per_h), rate_of_climb(-0.77355_q_m_per_s)}}, - glider{"SZD-56 Diana", {velocity(110_q_km_per_h), rate_of_climb(-0.63657_q_m_per_s)}}}; -UNITS_DIAGNOSTIC_POP + glider{"SZD-30 Pirat", {velocity(83_q_km_per_h), rate_of_climb(-0.7389_q_m_per_s)}}, + glider{"SZD-51 Junior", {velocity(80_q_km_per_h), rate_of_climb(-0.6349_q_m_per_s)}}, + glider{"SZD-48 Jantar Std 3", {velocity(110_q_km_per_h), rate_of_climb(-0.77355_q_m_per_s)}}, + glider{"SZD-56 Diana", {velocity(110_q_km_per_h), rate_of_climb(-0.63657_q_m_per_s)}}}; + UNITS_DIAGNOSTIC_POP return gliders; } @@ -58,9 +57,9 @@ auto get_weather_conditions() { using namespace si::literals; static const std::array weather_conditions = { - std::pair("Good", weather{height(1900_q_m), rate_of_climb(4.3_q_m_per_s)}), - std::pair("Medium", weather{height(1550_q_m), rate_of_climb(2.8_q_m_per_s)}), - std::pair("Bad", weather{height(850_q_m), rate_of_climb(1.8_q_m_per_s)})}; + std::pair("Good", weather{height(1900_q_m), rate_of_climb(4.3_q_m_per_s)}), + std::pair("Medium", weather{height(1550_q_m), rate_of_climb(2.8_q_m_per_s)}), + std::pair("Bad", weather{height(850_q_m), rate_of_climb(1.8_q_m_per_s)})}; return weather_conditions; } @@ -69,14 +68,14 @@ auto get_waypoints() using namespace geographic::literals; using namespace units::isq::si::international::literals; static const std::array waypoints = { - waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(16_q_ft)}, // N54°14'51.8" E18°40'28.2" - waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(115_q_ft)} // N53°31'27.9" E18°50'58.1" + waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(16_q_ft)}, // N54°14'51.8" E18°40'28.2" + waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(115_q_ft)} // N53°31'27.9" E18°50'58.1" }; return waypoints; } template - requires std::same_as, glider> + requires(std::same_as, glider>) void print(const R& gliders) { std::cout << "Gliders:\n"; @@ -85,13 +84,14 @@ void print(const R& gliders) std::cout << "- Name: " << g.name << "\n"; std::cout << "- Polar:\n"; for (const auto& p : g.polar) - std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast(glide_ratio(g.polar[0]))); + std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, + units::quantity_cast(glide_ratio(g.polar[0]))); std::cout << "\n"; } } template - requires std::same_as, std::pair> + requires(std::same_as, std::pair>) void print(const R& conditions) { std::cout << "Weather:\n"; @@ -106,7 +106,7 @@ void print(const R& conditions) } template - requires std::same_as, waypoint> + requires(std::same_as, waypoint>) void print(const R& waypoints) { std::cout << "Waypoints:\n"; @@ -125,7 +125,8 @@ void print(const task& t) std::cout << "- Finish: " << t.get_finish().name << "\n"; std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n"; - std::cout << "- Legs: " << "\n"; + std::cout << "- Legs: " + << "\n"; for (const auto& l : t.get_legs()) std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length()); std::cout << "\n"; diff --git a/example/literals/linear_algebra.cpp b/example/literals/linear_algebra.cpp index e10823c8..44201578 100644 --- a/example/literals/linear_algebra.cpp +++ b/example/literals/linear_algebra.cpp @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include +#include // IWYU pragma: keep #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include -#include #include +#include namespace STD_LA { @@ -73,9 +73,9 @@ void vector_of_quantity_add() { std::cout << "\nvector_of_quantity_add:\n"; - vector> v = { 1_q_m, 2_q_m, 3_q_m }; - vector> u = { 3_q_m, 2_q_m, 1_q_m }; - vector> t = { 3_q_km, 2_q_km, 1_q_km }; + vector> v = {1_q_m, 2_q_m, 3_q_m}; + vector> u = {3_q_m, 2_q_m, 1_q_m}; + vector> t = {3_q_km, 2_q_km, 1_q_km}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -90,8 +90,8 @@ void vector_of_quantity_multiply_same() { std::cout << "\nvector_of_quantity_multiply_same:\n"; - vector> v = { 1_q_m, 2_q_m, 3_q_m }; - vector> u = { 3_q_m, 2_q_m, 1_q_m }; + vector> v = {1_q_m, 2_q_m, 3_q_m}; + vector> u = {3_q_m, 2_q_m, 1_q_m}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -104,8 +104,8 @@ void vector_of_quantity_multiply_different() { std::cout << "\nvector_of_quantity_multiply_different:\n"; - vector> v = { 1_q_N, 2_q_N, 3_q_N }; - vector> u = { 3_q_m, 2_q_m, 1_q_m }; + vector> v = {1_q_N, 2_q_N, 3_q_N}; + vector> u = {3_q_m, 2_q_m, 1_q_m}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -119,7 +119,7 @@ void vector_of_quantity_divide_by_scalar() { std::cout << "\nvector_of_quantity_divide_by_scalar:\n"; - vector> v = { 4_q_m, 8_q_m, 12_q_m }; + vector> v = {4_q_m, 8_q_m, 12_q_m}; std::cout << "v = " << v << "\n"; @@ -140,9 +140,9 @@ void matrix_of_quantity_add() { std::cout << "\nmatrix_of_quantity_add:\n"; - matrix> v = {{ 1_q_m, 2_q_m, 3_q_m }, { 4_q_m, 5_q_m, 6_q_m }, { 7_q_m, 8_q_m, 9_q_m }}; - matrix> u = {{ 3_q_m, 2_q_m, 1_q_m }, { 3_q_m, 2_q_m, 1_q_m }, { 3_q_m, 2_q_m, 1_q_m }}; - matrix> t = {{ 3_q_mm, 2_q_mm, 1_q_mm }, { 3_q_mm, 2_q_mm, 1_q_mm }, { 3_q_mm, 2_q_mm, 1_q_mm }}; + matrix> v = {{1_q_m, 2_q_m, 3_q_m}, {4_q_m, 5_q_m, 6_q_m}, {7_q_m, 8_q_m, 9_q_m}}; + matrix> u = {{3_q_m, 2_q_m, 1_q_m}, {3_q_m, 2_q_m, 1_q_m}, {3_q_m, 2_q_m, 1_q_m}}; + matrix> t = {{3_q_mm, 2_q_mm, 1_q_mm}, {3_q_mm, 2_q_mm, 1_q_mm}, {3_q_mm, 2_q_mm, 1_q_mm}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -159,8 +159,8 @@ void matrix_of_quantity_multiply_same() { std::cout << "\nmatrix_of_quantity_multiply_same:\n"; - matrix> v = {{ 1_q_m, 2_q_m, 3_q_m }, { 4_q_m, 5_q_m, 6_q_m }, { 7_q_m, 8_q_m, 9_q_m }}; - vector> u = { 3_q_m, 2_q_m, 1_q_m }; + matrix> v = {{1_q_m, 2_q_m, 3_q_m}, {4_q_m, 5_q_m, 6_q_m}, {7_q_m, 8_q_m, 9_q_m}}; + vector> u = {3_q_m, 2_q_m, 1_q_m}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -173,8 +173,8 @@ void matrix_of_quantity_multiply_different() { std::cout << "\nmatrix_of_quantity_multiply_different:\n"; - vector> v = { 1_q_N, 2_q_N, 3_q_N }; - matrix> u = {{ 1_q_m, 2_q_m, 3_q_m }, { 4_q_m, 5_q_m, 6_q_m }, { 7_q_m, 8_q_m, 9_q_m }}; + vector> v = {1_q_N, 2_q_N, 3_q_N}; + matrix> u = {{1_q_m, 2_q_m, 3_q_m}, {4_q_m, 5_q_m, 6_q_m}, {7_q_m, 8_q_m, 9_q_m}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -188,7 +188,7 @@ void matrix_of_quantity_divide_by_scalar() { std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n"; - matrix> v = {{ 2_q_m, 4_q_m, 6_q_m }, { 4_q_m, 6_q_m, 8_q_m }, { 8_q_m, 4_q_m, 2_q_m }}; + matrix> v = {{2_q_m, 4_q_m, 6_q_m}, {4_q_m, 6_q_m, 8_q_m}, {8_q_m, 4_q_m, 2_q_m}}; std::cout << "v =\n" << v << "\n"; @@ -215,9 +215,9 @@ void quantity_of_vector_add() { std::cout << "\nquantity_of_vector_add:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); - length_v t(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); + length_v t(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -232,8 +232,8 @@ void quantity_of_vector_multiply_same() { std::cout << "\nquantity_of_vector_multiply_same:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -246,8 +246,8 @@ void quantity_of_vector_multiply_different() { std::cout << "\nquantity_of_vector_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + force_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -261,7 +261,7 @@ void quantity_of_vector_divide_by_scalar() { std::cout << "\nquantity_of_vector_divide_by_scalar:\n"; - length_v<> v(vector<>{ 4, 8, 12 }); + length_v<> v(vector<>{4, 8, 12}); std::cout << "v = " << v << "\n"; @@ -285,9 +285,9 @@ void quantity_of_matrix_add() { std::cout << "\nquantity_of_matrix_add:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_m<> u(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); - length_m t(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_m<> u(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); + length_m t(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -304,8 +304,8 @@ void quantity_of_matrix_multiply_same() { std::cout << "\nquantity_of_matrix_multiply_same:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_v<> u(vector<>{ 3, 2, 1 }); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -318,8 +318,8 @@ void quantity_of_matrix_multiply_different() { std::cout << "\nquantity_of_matrix_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_m<> u(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + force_v<> v(vector<>{1, 2, 3}); + length_m<> u(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -333,7 +333,7 @@ void quantity_of_matrix_divide_by_scalar() { std::cout << "\nquantity_of_matrix_divide_by_scalar:\n"; - length_m<> v(matrix<>{{ 2, 4, 6 }, { 4, 6, 8 }, { 8, 4, 2 }}); + length_m<> v(matrix<>{{2, 4, 6}, {4, 6, 8}, {8, 4, 2}}); std::cout << "v =\n" << v << "\n"; diff --git a/example/literals/total_energy.cpp b/example/literals/total_energy.cpp index a81dd789..0cda3706 100644 --- a/example/literals/total_energy.cpp +++ b/example/literals/total_energy.cpp @@ -21,11 +21,11 @@ // SOFTWARE. #include +#include #include #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include #include #include @@ -88,18 +88,16 @@ void natural_example() << "E = " << E << "\n"; } -} // namespace +} // namespace int main() { try { si_example(); natural_example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/literals/unknown_dimension.cpp b/example/literals/unknown_dimension.cpp index aed204d8..fd26ee92 100644 --- a/example/literals/unknown_dimension.cpp +++ b/example/literals/unknown_dimension.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -44,8 +44,9 @@ void example() Time auto t1 = 10_q_s; Speed auto v1 = avg_speed(d1, t1); - auto temp1 = v1 * 50_q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - Speed auto v2 = temp1 / 100_q_m; // back to known dimensions again + auto temp1 = + v1 * 50_q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' + Speed auto v2 = temp1 / 100_q_m; // back to known dimensions again Length auto d2 = v2 * 60_q_s; std::cout << "d1 = " << d1 << '\n'; @@ -56,17 +57,15 @@ void example() std::cout << "d2 = " << d2 << '\n'; } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/measurement.cpp b/example/measurement.cpp index 293a8c9f..ca7df2f3 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -38,8 +38,7 @@ public: measurement() = default; - constexpr explicit measurement(const value_type& val, const value_type& err = {}) : - value_(val) + constexpr explicit measurement(const value_type& val, const value_type& err = {}) : value_(val) { // it sucks that using declaration cannot be provided for a constructor initializer list using namespace std; @@ -133,7 +132,8 @@ void example() const Speed auto v1 = a * t; #if UNITS_DOWNCAST_MODE == 0 - std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast(v1) << '\n'; + std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast(v1) + << '\n'; #else std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast(v1) << '\n'; #endif diff --git a/example/references/avg_speed.cpp b/example/references/avg_speed.cpp index aba1123e..3c9cecca 100644 --- a/example/references/avg_speed.cpp +++ b/example/references/avg_speed.cpp @@ -21,12 +21,12 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include +#include #include #include #include @@ -35,38 +35,31 @@ namespace { using namespace units::isq; -constexpr si::speed -fixed_int_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_int_si_avg_speed(si::length d, + si::time t) { return d / t; } -constexpr si::speed -fixed_double_si_avg_speed(si::length d, - si::time t) +constexpr si::speed fixed_double_si_avg_speed(si::length d, si::time t) { return d / t; } template -constexpr Speed auto si_avg_speed(si::length d, - si::time t) +constexpr Speed auto si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr Speed auto avg_speed(Length auto d, Time auto t) -{ - return d / t; -} +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } template void print_result(D distance, T duration, V speed) { const auto result_in_kmph = units::quantity_cast>(speed); - std::cout << "Average speed of a car that makes " << distance << " in " - << duration << " is " << result_in_kmph << ".\n"; + std::cout << "Average speed of a car that makes " << distance << " in " << duration << " is " << result_in_kmph + << ".\n"; } void example() @@ -94,7 +87,8 @@ void example() std::cout << "\nSI units with 'double' as representation\n"; // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); + print_result(distance, duration, + fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -130,7 +124,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // also it is not possible to make a lossless conversion of miles to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); print_result(distance, duration, si_avg_speed(distance, duration)); @@ -169,7 +165,9 @@ void example() // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed // it is not possible to make a lossless conversion of centimeters to meters on an integral type // (explicit cast needed) - print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + print_result( + distance, duration, + fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); @@ -178,20 +176,17 @@ void example() print_result(distance, duration, avg_speed(distance, duration)); } - } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/references/box_example.cpp b/example/references/box_example.cpp index 48a8656e..b94c34d2 100644 --- a/example/references/box_example.cpp +++ b/example/references/box_example.cpp @@ -29,7 +29,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -50,7 +50,10 @@ class Box { si::length height_; si::density density_ = air_density; public: - constexpr Box(const si::length& length, const si::length& width, si::length height) : base_(length * width), height_(std::move(height)) {} + constexpr Box(const si::length& length, const si::length& width, si::length height) : + base_(length * width), height_(std::move(height)) + { + } [[nodiscard]] constexpr si::force filled_weight() const { @@ -90,13 +93,13 @@ int main() auto box = Box(1000.0 * mm, 500.0 * mm, height); box.set_contents_density(1000.0 * (kg / m3)); - const auto fill_time = 200.0 * s; // time since starting fill - const auto measured_mass = 20.0 * kg; // measured mass at fill_time + const auto fill_time = 200.0 * s; // time since starting fill + const auto measured_mass = 20.0 * kg; // measured mass at fill_time const Length auto fill_level = box.fill_level(measured_mass); const Dimensionless auto fill_percent = quantity_cast(fill_level / height); const Volume auto spare_capacity = box.spare_capacity(measured_mass); - const auto input_flow_rate = measured_mass / fill_time; // unknown dimension + const auto input_flow_rate = measured_mass / fill_time; // unknown dimension const Speed auto float_rise_rate = fill_level / fill_time; const Time auto fill_time_left = (height / fill_level - 1) * fill_time; diff --git a/example/references/capacitor_time_curve.cpp b/example/references/capacitor_time_curve.cpp index 844bf4d2..45e1c45b 100644 --- a/example/references/capacitor_time_curve.cpp +++ b/example/references/capacitor_time_curve.cpp @@ -26,7 +26,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include diff --git a/example/references/clcpp_response.cpp b/example/references/clcpp_response.cpp index 758dafa9..c19eb459 100644 --- a/example/references/clcpp_response.cpp +++ b/example/references/clcpp_response.cpp @@ -39,15 +39,15 @@ void simple_quantities() using distance = si::length; using duration = si::time; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_SHADOW + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_SHADOW constexpr distance km = 1.0 * references::km; constexpr distance miles = 1.0 * mi; constexpr duration sec = 1 * s; constexpr duration min = 1 * references::min; constexpr duration hr = 1 * h; -UNITS_DIAGNOSTIC_POP + UNITS_DIAGNOSTIC_POP std::cout << "A physical quantities library can choose the simple\n"; std::cout << "option to provide output using a single type for each base unit:\n\n"; @@ -66,8 +66,8 @@ void quantities_with_typed_units() using namespace units::isq::si::international; using namespace units::isq::si::international::references; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_SHADOW + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_SHADOW constexpr length km = 1.0 * si::references::km; constexpr length miles = 1.0 * mi; @@ -76,7 +76,7 @@ UNITS_DIAGNOSTIC_IGNORE_SHADOW constexpr si::time sec = 1 * s; constexpr si::time min = 1 * si::references::min; constexpr si::time hr = 1 * h; -UNITS_DIAGNOSTIC_POP + UNITS_DIAGNOSTIC_POP std::cout << "A more flexible option is to provide separate types for each unit,\n\n"; std::cout << km << '\n'; diff --git a/example/references/experimental_angle.cpp b/example/references/experimental_angle.cpp index 76a1e6a8..61421f2c 100644 --- a/example/references/experimental_angle.cpp +++ b/example/references/experimental_angle.cpp @@ -20,17 +20,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include // IWYU pragma: keep UNITS_DIAGNOSTIC_PUSH UNITS_DIAGNOSTIC_IGNORE_SHADOW -#include // 'N' (Newton) shadows a template parameter traditionally used as a size of the array +#include // 'N' (Newton) shadows a template parameter traditionally used as a size of the array UNITS_DIAGNOSTIC_POP #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include diff --git a/example/references/foot_pound_second.cpp b/example/references/foot_pound_second.cpp index b76a2b53..f947ed4c 100644 --- a/example/references/foot_pound_second.cpp +++ b/example/references/foot_pound_second.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -56,7 +56,7 @@ struct Ship { }; // Print 'a' in its current units and print its value cast to the units in each of Args -template +template auto fmt_line(const Q a) { return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast(a)) + ...); @@ -68,16 +68,27 @@ void print_details(std::string_view description, const Ship& ship) using namespace units::isq::si::fps::references; const auto waterDensity = 62.4 * (lb / ft3); std::cout << STD_FMT::format("{}\n", description); - std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length>(ship.length)) - << STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length>(ship.draft)) - << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length>(ship.beam)) - << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass>(ship.mass)) - << STD_FMT::format("{:20} : {}\n", "speed", fmt_line, si::speed>(ship.speed)) - << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power>(ship.power)) - << STD_FMT::format("{:20} : {}\n", "main guns", fmt_line, si::length>(ship.mainGuns)) - << STD_FMT::format("{:20} : {}\n", "fire shells weighing", fmt_line, si::mass>(ship.shellMass)) - << STD_FMT::format("{:20} : {}\n", "fire shells at", fmt_line, si::speed>(ship.shellSpeed)) - << STD_FMT::format("{:20} : {}\n", "volume underwater", fmt_line, si::volume>(ship.mass / waterDensity)); + std::cout << STD_FMT::format("{:20} : {}\n", "length", + fmt_line, si::length>(ship.length)) + << STD_FMT::format("{:20} : {}\n", "draft", + fmt_line, si::length>(ship.draft)) + << STD_FMT::format("{:20} : {}\n", "beam", + fmt_line, si::length>(ship.beam)) + << STD_FMT::format("{:20} : {}\n", "mass", + fmt_line, si::mass>(ship.mass)) + << STD_FMT::format("{:20} : {}\n", "speed", + fmt_line, si::speed>(ship.speed)) + << STD_FMT::format("{:20} : {}\n", "power", + fmt_line, si::power>(ship.power)) + << STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length>(ship.mainGuns)) + << STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass>(ship.shellMass)) + << STD_FMT::format( + "{:20} : {}\n", "fire shells at", + fmt_line, si::speed>(ship.shellSpeed)) + << STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume>(ship.mass / waterDensity)); } int main() @@ -87,13 +98,37 @@ int main() using units::isq::si::fps::references::ft; // collides with si::femtotonne (alias unit of mass) // KMS Bismark, using the units the Germans would use, taken from Wiki - auto bismark = Ship{.length{251. * m}, .draft{9.3 * m}, .beam{36 * m}, .speed{56 * (km / h)}, .mass{50'300 * t}, .mainGuns{380 * mm}, .shellMass{800 * kg}, .shellSpeed{820. * (m / s)}, .power{110.45 * kW}}; + auto bismark = Ship{.length{251. * m}, + .draft{9.3 * m}, + .beam{36 * m}, + .speed{56 * (km / h)}, + .mass{50'300 * t}, + .mainGuns{380 * mm}, + .shellMass{800 * kg}, + .shellSpeed{820. * (m / s)}, + .power{110.45 * kW}}; // USS Iowa, using units from the foot-pound-second system - auto iowa = Ship{.length{860. * ft}, .draft{37. * ft + 2. * in}, .beam{108. * ft + 2. * in}, .speed{33 * knot}, .mass{57'540 * lton}, .mainGuns{16 * in}, .shellMass{2700 * lb}, .shellSpeed{2690. * (ft / s)}, .power{212'000 * hp}}; + auto iowa = Ship{.length{860. * ft}, + .draft{37. * ft + 2. * in}, + .beam{108. * ft + 2. * in}, + .speed{33 * knot}, + .mass{57'540 * lton}, + .mainGuns{16 * in}, + .shellMass{2700 * lb}, + .shellSpeed{2690. * (ft / s)}, + .power{212'000 * hp}}; // HMS King George V, using units from the foot-pound-second system - auto kgv = Ship{.length{745.1 * ft}, .draft{33. * ft + 7.5 * in}, .beam{103.2 * ft + 2.5 * in}, .speed{28.3 * knot}, .mass{42'245 * lton}, .mainGuns{14 * in}, .shellMass{1'590 * lb}, .shellSpeed{2483. * (ft / s)}, .power{110'000 * hp}}; + auto kgv = Ship{.length{745.1 * ft}, + .draft{33. * ft + 7.5 * in}, + .beam{103.2 * ft + 2.5 * in}, + .speed{28.3 * knot}, + .mass{42'245 * lton}, + .mainGuns{14 * in}, + .shellMass{1'590 * lb}, + .shellSpeed{2483. * (ft / s)}, + .power{110'000 * hp}}; print_details("KMS Bismark, defined in appropriate units from the SI system", bismark); std::cout << "\n\n"; diff --git a/example/references/glide_computer_example.cpp b/example/references/glide_computer_example.cpp index 701f04d2..ccfa543c 100644 --- a/example/references/glide_computer_example.cpp +++ b/example/references/glide_computer_example.cpp @@ -25,7 +25,6 @@ #include #include #include - #include #include #include @@ -43,14 +42,14 @@ using namespace units::isq; auto get_gliders() { using namespace si::references; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES static const std::array gliders = { - glider{"SZD-30 Pirat", {velocity(83 * (km / h)), rate_of_climb(-0.7389 * (m / s))}}, - glider{"SZD-51 Junior", {velocity(80 * (km / h)), rate_of_climb(-0.6349 * (m / s))}}, - glider{"SZD-48 Jantar Std 3", {velocity(110 * (km / h)), rate_of_climb(-0.77355 * (m / s))}}, - glider{"SZD-56 Diana", {velocity(110 * (km / h)), rate_of_climb(-0.63657 * (m / s))}}}; -UNITS_DIAGNOSTIC_POP + glider{"SZD-30 Pirat", {velocity(83 * (km / h)), rate_of_climb(-0.7389 * (m / s))}}, + glider{"SZD-51 Junior", {velocity(80 * (km / h)), rate_of_climb(-0.6349 * (m / s))}}, + glider{"SZD-48 Jantar Std 3", {velocity(110 * (km / h)), rate_of_climb(-0.77355 * (m / s))}}, + glider{"SZD-56 Diana", {velocity(110 * (km / h)), rate_of_climb(-0.63657 * (m / s))}}}; + UNITS_DIAGNOSTIC_POP return gliders; } @@ -58,9 +57,9 @@ auto get_weather_conditions() { using namespace si::references; static const std::array weather_conditions = { - std::pair("Good", weather{height(1900 * m), rate_of_climb(4.3 * (m / s))}), - std::pair("Medium", weather{height(1550 * m), rate_of_climb(2.8 * (m / s))}), - std::pair("Bad", weather{height(850 * m), rate_of_climb(1.8 * (m / s))})}; + std::pair("Good", weather{height(1900 * m), rate_of_climb(4.3 * (m / s))}), + std::pair("Medium", weather{height(1550 * m), rate_of_climb(2.8 * (m / s))}), + std::pair("Bad", weather{height(850 * m), rate_of_climb(1.8 * (m / s))})}; return weather_conditions; } @@ -69,14 +68,14 @@ auto get_waypoints() using namespace geographic::literals; using namespace units::isq::si::international::references; static const std::array waypoints = { - waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(16 * ft)}, // N54°14'51.8" E18°40'28.2" - waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(115 * ft)} // N53°31'27.9" E18°50'58.1" + waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(16 * ft)}, // N54°14'51.8" E18°40'28.2" + waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(115 * ft)} // N53°31'27.9" E18°50'58.1" }; return waypoints; } template - requires std::same_as, glider> + requires(std::same_as, glider>) void print(const R& gliders) { std::cout << "Gliders:\n"; @@ -85,13 +84,14 @@ void print(const R& gliders) std::cout << "- Name: " << g.name << "\n"; std::cout << "- Polar:\n"; for (const auto& p : g.polar) - std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast(glide_ratio(g.polar[0]))); + std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, + units::quantity_cast(glide_ratio(g.polar[0]))); std::cout << "\n"; } } template - requires std::same_as, std::pair> + requires(std::same_as, std::pair>) void print(const R& conditions) { std::cout << "Weather:\n"; @@ -106,7 +106,7 @@ void print(const R& conditions) } template - requires std::same_as, waypoint> + requires(std::same_as, waypoint>) void print(const R& waypoints) { std::cout << "Waypoints:\n"; @@ -125,7 +125,8 @@ void print(const task& t) std::cout << "- Finish: " << t.get_finish().name << "\n"; std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n"; - std::cout << "- Legs: " << "\n"; + std::cout << "- Legs: " + << "\n"; for (const auto& l : t.get_legs()) std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length()); std::cout << "\n"; diff --git a/example/references/linear_algebra.cpp b/example/references/linear_algebra.cpp index f3b23a49..39d1fefe 100644 --- a/example/references/linear_algebra.cpp +++ b/example/references/linear_algebra.cpp @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include +#include // IWYU pragma: keep #include #include -#include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include -#include #include +#include namespace STD_LA { @@ -73,9 +73,9 @@ void vector_of_quantity_add() { std::cout << "\nvector_of_quantity_add:\n"; - vector> v = { 1 * m, 2 * m, 3 * m }; - vector> u = { 3 * m, 2 * m, 1 * m }; - vector> t = { 3 * km, 2 * km, 1 * km }; + vector> v = {1 * m, 2 * m, 3 * m}; + vector> u = {3 * m, 2 * m, 1 * m}; + vector> t = {3 * km, 2 * km, 1 * km}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -90,8 +90,8 @@ void vector_of_quantity_multiply_same() { std::cout << "\nvector_of_quantity_multiply_same:\n"; - vector> v = { 1 * m, 2 * m, 3 * m }; - vector> u = { 3 * m, 2 * m, 1 * m }; + vector> v = {1 * m, 2 * m, 3 * m}; + vector> u = {3 * m, 2 * m, 1 * m}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -104,8 +104,8 @@ void vector_of_quantity_multiply_different() { std::cout << "\nvector_of_quantity_multiply_different:\n"; - vector> v = { 1 * N, 2 * N, 3 * N }; - vector> u = { 3 * m, 2 * m, 1 * m }; + vector> v = {1 * N, 2 * N, 3 * N}; + vector> u = {3 * m, 2 * m, 1 * m}; std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -119,7 +119,7 @@ void vector_of_quantity_divide_by_scalar() { std::cout << "\nvector_of_quantity_divide_by_scalar:\n"; - vector> v = { 4 * m, 8 * m, 12 * m }; + vector> v = {4 * m, 8 * m, 12 * m}; std::cout << "v = " << v << "\n"; @@ -140,9 +140,9 @@ void matrix_of_quantity_add() { std::cout << "\nmatrix_of_quantity_add:\n"; - matrix> v = {{ 1 * m, 2 * m, 3 * m }, { 4 * m, 5 * m, 6 * m }, { 7 * m, 8 * m, 9 * m }}; - matrix> u = {{ 3 * m, 2 * m, 1 * m }, { 3 * m, 2 * m, 1 * m }, { 3 * m, 2 * m, 1 * m }}; - matrix> t = {{ 3 * mm, 2 * mm, 1 * mm }, { 3 * mm, 2 * mm, 1 * mm }, { 3 * mm, 2 * mm, 1 * mm }}; + matrix> v = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}}; + matrix> u = {{3 * m, 2 * m, 1 * m}, {3 * m, 2 * m, 1 * m}, {3 * m, 2 * m, 1 * m}}; + matrix> t = {{3 * mm, 2 * mm, 1 * mm}, {3 * mm, 2 * mm, 1 * mm}, {3 * mm, 2 * mm, 1 * mm}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -159,8 +159,8 @@ void matrix_of_quantity_multiply_same() { std::cout << "\nmatrix_of_quantity_multiply_same:\n"; - matrix> v = {{ 1 * m, 2 * m, 3 * m }, { 4 * m, 5 * m, 6 * m }, { 7 * m, 8 * m, 9 * m }}; - vector> u = { 3 * m, 2 * m, 1 * m }; + matrix> v = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}}; + vector> u = {3 * m, 2 * m, 1 * m}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -173,8 +173,8 @@ void matrix_of_quantity_multiply_different() { std::cout << "\nmatrix_of_quantity_multiply_different:\n"; - vector> v = { 1 * N, 2 * N, 3 * N }; - matrix> u = {{ 1 * m, 2 * m, 3 * m }, { 4 * m, 5 * m, 6 * m }, { 7 * m, 8 * m, 9 * m }}; + vector> v = {1 * N, 2 * N, 3 * N}; + matrix> u = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}}; std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -188,7 +188,7 @@ void matrix_of_quantity_divide_by_scalar() { std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n"; - matrix> v = {{ 2 * m, 4 * m, 6 * m }, { 4 * m, 6 * m, 8 * m }, { 8 * m, 4 * m, 2 * m }}; + matrix> v = {{2 * m, 4 * m, 6 * m}, {4 * m, 6 * m, 8 * m}, {8 * m, 4 * m, 2 * m}}; std::cout << "v =\n" << v << "\n"; @@ -215,9 +215,9 @@ void quantity_of_vector_add() { std::cout << "\nquantity_of_vector_add:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); - length_v t(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); + length_v t(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -232,8 +232,8 @@ void quantity_of_vector_multiply_same() { std::cout << "\nquantity_of_vector_multiply_same:\n"; - length_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + length_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -246,8 +246,8 @@ void quantity_of_vector_multiply_different() { std::cout << "\nquantity_of_vector_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_v<> u(vector<>{ 3, 2, 1 }); + force_v<> v(vector<>{1, 2, 3}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v = " << v << "\n"; std::cout << "u = " << u << "\n"; @@ -261,7 +261,7 @@ void quantity_of_vector_divide_by_scalar() { std::cout << "\nquantity_of_vector_divide_by_scalar:\n"; - length_v<> v(vector<>{ 4, 8, 12 }); + length_v<> v(vector<>{4, 8, 12}); std::cout << "v = " << v << "\n"; @@ -285,9 +285,9 @@ void quantity_of_matrix_add() { std::cout << "\nquantity_of_matrix_add:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_m<> u(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); - length_m t(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_m<> u(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); + length_m t(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -304,8 +304,8 @@ void quantity_of_matrix_multiply_same() { std::cout << "\nquantity_of_matrix_multiply_same:\n"; - length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); - length_v<> u(vector<>{ 3, 2, 1 }); + length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); + length_v<> u(vector<>{3, 2, 1}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -318,8 +318,8 @@ void quantity_of_matrix_multiply_different() { std::cout << "\nquantity_of_matrix_multiply_different:\n"; - force_v<> v(vector<>{ 1, 2, 3 }); - length_m<> u(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + force_v<> v(vector<>{1, 2, 3}); + length_m<> u(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); std::cout << "v =\n" << v << "\n"; std::cout << "u =\n" << u << "\n"; @@ -333,7 +333,7 @@ void quantity_of_matrix_divide_by_scalar() { std::cout << "\nquantity_of_matrix_divide_by_scalar:\n"; - length_m<> v(matrix<>{{ 2, 4, 6 }, { 4, 6, 8 }, { 8, 4, 2 }}); + length_m<> v(matrix<>{{2, 4, 6}, {4, 6, 8}, {8, 4, 2}}); std::cout << "v =\n" << v << "\n"; diff --git a/example/references/total_energy.cpp b/example/references/total_energy.cpp index e6c911bf..ec6e8f3e 100644 --- a/example/references/total_energy.cpp +++ b/example/references/total_energy.cpp @@ -25,7 +25,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -87,18 +87,16 @@ void natural_example() << "E = " << E << "\n"; } -} // namespace +} // namespace int main() { try { si_example(); natural_example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/example/references/unknown_dimension.cpp b/example/references/unknown_dimension.cpp index 8e5fe29a..d2ea9c47 100644 --- a/example/references/unknown_dimension.cpp +++ b/example/references/unknown_dimension.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include @@ -44,8 +44,9 @@ void example() Time auto t1 = 10 * s; Speed auto v1 = avg_speed(d1, t1); - auto temp1 = v1 * (50 * m); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - Speed auto v2 = temp1 / (100 * m); // back to known dimensions again + auto temp1 = + v1 * (50 * m); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' + Speed auto v2 = temp1 / (100 * m); // back to known dimensions again Length auto d2 = v2 * (60 * s); std::cout << "d1 = " << d1 << '\n'; @@ -56,17 +57,15 @@ void example() std::cout << "d2 = " << d2 << '\n'; } -} // namespace +} // namespace int main() { try { example(); - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; - } - catch (...) { + } catch (...) { std::cerr << "Unhandled unknown exception caught\n"; } } diff --git a/src/core/include/units/generic/angle.h b/src/core/include/units/generic/angle.h index 00c723dc..9aefafbb 100644 --- a/src/core/include/units/generic/angle.h +++ b/src/core/include/units/generic/angle.h @@ -48,12 +48,16 @@ using angle = quantity, U, Rep>; inline namespace literals { // rad -constexpr auto operator"" _q_rad(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return angle(static_cast(l)); } +constexpr auto operator"" _q_rad(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return angle(static_cast(l)); +} constexpr auto operator"" _q_rad(long double l) { return angle(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -69,6 +73,6 @@ using namespace angle_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units diff --git a/src/systems/si-fps/include/units/isq/si/fps/acceleration.h b/src/systems/si-fps/include/units/isq/si/fps/acceleration.h index 507495e7..97990439 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/acceleration.h +++ b/src/systems/si-fps/include/units/isq/si/fps/acceleration.h @@ -44,12 +44,16 @@ using acceleration = quantity; inline namespace literals { // ft/s2 -constexpr auto operator"" _q_ft_per_s2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return acceleration(static_cast(l)); } +constexpr auto operator"" _q_ft_per_s2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return acceleration(static_cast(l)); +} constexpr auto operator"" _q_ft_per_s2(long double l) { return acceleration(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::fps @@ -57,8 +61,9 @@ constexpr auto operator"" _q_ft_per_s2(long double l) { return acceleration using ft_per_s2 = units::isq::si::fps::acceleration; +template +using ft_per_s2 = units::isq::si::fps::acceleration; } // namespace units::aliases::isq::si::fps::inline acceleration -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/area.h b/src/systems/si-fps/include/units/isq/si/fps/area.h index d02e5732..acafd67f 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/area.h +++ b/src/systems/si-fps/include/units/isq/si/fps/area.h @@ -46,12 +46,16 @@ using area = quantity; inline namespace literals { // ft2 -constexpr auto operator"" _q_ft2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ft2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ft2(long double l) { return area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -67,7 +71,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -75,8 +79,9 @@ using namespace area_references; namespace units::aliases::isq::si::fps::inline area { -template using ft2 = units::isq::si::fps::area; +template +using ft2 = units::isq::si::fps::area; -} // namespace units::aliases::isq::si::fps::inlipne area +} // namespace units::aliases::isq::si::fps::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/density.h b/src/systems/si-fps/include/units/isq/si/fps/density.h index 1d807c25..f2aa0e65 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/density.h +++ b/src/systems/si-fps/include/units/isq/si/fps/density.h @@ -28,8 +28,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si::fps { @@ -46,12 +46,16 @@ using density = quantity; inline namespace literals { // lb/ft³ -constexpr auto operator"" _q_lb_per_ft3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return density(static_cast(l)); } +constexpr auto operator"" _q_lb_per_ft3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return density(static_cast(l)); +} constexpr auto operator"" _q_lb_per_ft3(long double l) { return density(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::fps @@ -59,8 +63,9 @@ constexpr auto operator"" _q_lb_per_ft3(long double l) { return density using lb_per_ft3 = units::isq::si::fps::density; +template +using lb_per_ft3 = units::isq::si::fps::density; } // namespace units::aliases::isq::si::fps::inline density -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/energy.h b/src/systems/si-fps/include/units/isq/si/fps/energy.h index 7d430d4f..7278f016 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/energy.h +++ b/src/systems/si-fps/include/units/isq/si/fps/energy.h @@ -40,7 +40,7 @@ struct foot_poundal : unit {}; struct dim_energy : isq::dim_energy {}; // https://en.wikipedia.org/wiki/Foot-pound_(energy) - struct foot_pound_force : derived_unit {}; +struct foot_pound_force : derived_unit {}; template U, Representation Rep = double> using energy = quantity; @@ -50,16 +50,24 @@ using energy = quantity; inline namespace literals { // foot poundal -constexpr auto operator"" _q_ft_pdl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_ft_pdl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_ft_pdl(long double l) { return energy(l); } // foot_pound force -constexpr auto operator"" _q_ft_lbf(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_ft_lbf(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_ft_lbf(long double l) { return energy(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::fps @@ -67,9 +75,11 @@ constexpr auto operator"" _q_ft_lbf(long double l) { return energy using ft_pdl = units::isq::si::fps::energy; -template using ft_lbf = units::isq::si::fps::energy; +template +using ft_pdl = units::isq::si::fps::energy; +template +using ft_lbf = units::isq::si::fps::energy; } // namespace units::aliases::isq::si::fps::inline energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/force.h b/src/systems/si-fps/include/units/isq/si/fps/force.h index ebccdb3a..8958ca44 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/force.h +++ b/src/systems/si-fps/include/units/isq/si/fps/force.h @@ -57,20 +57,32 @@ using force = quantity; inline namespace literals { // poundal -constexpr auto operator"" _q_pdl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_pdl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_pdl(long double l) { return force(l); } // pound force -constexpr auto operator"" _q_lbf(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_lbf(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_lbf(long double l) { return force(l); } // kilopound force -constexpr auto operator"" _q_klbf(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_klbf(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_klbf(long double l) { return force(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -88,7 +100,7 @@ using namespace force_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -96,10 +108,13 @@ using namespace force_references; namespace units::aliases::isq::si::fps::inline force { -template using pdl = units::isq::si::fps::force; -template using lbf = units::isq::si::fps::force; -template using klbf = units::isq::si::fps::force; +template +using pdl = units::isq::si::fps::force; +template +using lbf = units::isq::si::fps::force; +template +using klbf = units::isq::si::fps::force; } // namespace units::aliases::isq::si::fps::inline force -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/fps.h b/src/systems/si-fps/include/units/isq/si/fps/fps.h index 1bf09cd9..6bd88132 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/fps.h +++ b/src/systems/si-fps/include/units/isq/si/fps/fps.h @@ -23,17 +23,16 @@ #pragma once // IWYU pragma: begin_exports -#include -#include -#include - #include #include #include #include #include +#include +#include #include #include #include +#include #include // IWYU pragma: end_exports diff --git a/src/systems/si-fps/include/units/isq/si/fps/pressure.h b/src/systems/si-fps/include/units/isq/si/fps/pressure.h index 9a0706b0..2c87269f 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/pressure.h +++ b/src/systems/si-fps/include/units/isq/si/fps/pressure.h @@ -43,9 +43,12 @@ struct dim_pressure : isq::dim_pressure U, Representation Rep = double> using pressure = quantity; -struct pound_force_per_foot_sq : named_scaled_unit {}; +struct pound_force_per_foot_sq : + named_scaled_unit {}; -struct pound_force_per_inch_sq : named_scaled_unit {}; +struct pound_force_per_inch_sq : + named_scaled_unit {}; struct kilopound_force_per_inch_sq : prefixed_unit {}; @@ -54,20 +57,32 @@ struct kilopound_force_per_inch_sq : prefixed_unit(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_pdl_per_ft2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_pdl_per_ft2(long double l) { return pressure(l); } // Pounds per square inch -constexpr auto operator"" _q_psi(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_psi(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_psi(long double l) { return pressure(l); } // kilopounds per square inch -constexpr auto operator"" _q_kpsi(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_kpsi(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_kpsi(long double l) { return pressure(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -84,7 +99,7 @@ using namespace pressure_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -92,10 +107,13 @@ using namespace pressure_references; namespace units::aliases::isq::si::fps::inline pressure { -template using pdl_per_ft2 = units::isq::si::fps::pressure; -template using psi = units::isq::si::fps::pressure; -template using kpsi = units::isq::si::fps::pressure; +template +using pdl_per_ft2 = units::isq::si::fps::pressure; +template +using psi = units::isq::si::fps::pressure; +template +using kpsi = units::isq::si::fps::pressure; } // namespace units::aliases::isq::si::fps::inline pressure -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/speed.h b/src/systems/si-fps/include/units/isq/si/fps/speed.h index 098498d5..04302b86 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/speed.h +++ b/src/systems/si-fps/include/units/isq/si/fps/speed.h @@ -41,8 +41,8 @@ struct dim_speed : isq::dim_speed U, Representation Rep = double> using speed = quantity; -struct mile_per_hour : derived_unit{}; -struct nautical_mile_per_hour : derived_unit{}; +struct mile_per_hour : derived_unit {}; +struct nautical_mile_per_hour : derived_unit {}; struct knot : alias_unit {}; #ifndef UNITS_NO_LITERALS @@ -50,20 +50,32 @@ struct knot : alias_unit {}; inline namespace literals { // ft/s -constexpr auto operator"" _q_ft_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_ft_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_ft_per_s(long double l) { return speed(l); } // mph -constexpr auto operator"" _q_mph(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_mph(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_mph(long double l) { return speed(l); } // kn -constexpr auto operator"" _q_knot(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_knot(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_knot(long double l) { return speed(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -80,7 +92,7 @@ using namespace speed_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -88,10 +100,13 @@ using namespace speed_references; namespace units::aliases::isq::si::fps::inline speed { -template using ft_per_s = units::isq::si::fps::speed; -template using mph = units::isq::si::fps::speed; -template using knot = units::isq::si::fps::speed; +template +using ft_per_s = units::isq::si::fps::speed; +template +using mph = units::isq::si::fps::speed; +template +using knot = units::isq::si::fps::speed; } // namespace units::aliases::isq::si::fps::inline speed -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-hep/include/units/isq/si/hep/area.h b/src/systems/si-hep/include/units/isq/si/hep/area.h index 53aa3603..9718fb2d 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/area.h +++ b/src/systems/si-hep/include/units/isq/si/hep/area.h @@ -50,27 +50,63 @@ struct milli_barn : prefixed_unit {}; #ifndef UNITS_NO_LITERALS inline namespace literals { -constexpr auto operator"" _q_yb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_yb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_yb(long double l) { return area(l); } -constexpr auto operator"" _q_zb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_zb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_zb(long double l) { return area(l); } -constexpr auto operator"" _q_ab(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ab(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ab(long double l) { return area(l); } -constexpr auto operator"" _q_fb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_fb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_fb(long double l) { return area(l); } -constexpr auto operator"" _q_pb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_pb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_pb(long double l) { return area(l); } -constexpr auto operator"" _q_nb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_nb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_nb(long double l) { return area(l); } -constexpr auto operator"" _q_ub(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ub(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ub(long double l) { return area(l); } -constexpr auto operator"" _q_mb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_mb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_mb(long double l) { return area(l); } -constexpr auto operator"" _q_b(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_b(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_b(long double l) { return area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -86,7 +122,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::hep @@ -94,8 +130,9 @@ using namespace area_references; namespace units::aliases::isq::si::hep::inline area { -template using barn = units::isq::si::area; +template +using barn = units::isq::si::area; } // namespace units::aliases::isq::si::hep::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/area.h b/src/systems/si-international/include/units/isq/si/international/area.h index 5a5489d9..74bd6ad1 100644 --- a/src/systems/si-international/include/units/isq/si/international/area.h +++ b/src/systems/si-international/include/units/isq/si/international/area.h @@ -42,12 +42,16 @@ struct square_foot : derived_unit(l)); return si::area(static_cast(l)); } +constexpr auto operator"" _q_ft2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::area(static_cast(l)); +} constexpr auto operator"" _q_ft2(long double l) { return si::area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -63,7 +67,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::international @@ -71,8 +75,9 @@ using namespace area_references; namespace units::aliases::isq::si::international::inline area { -template using ft2 = units::isq::si::area; +template +using ft2 = units::isq::si::area; } // namespace units::aliases::isq::si::international::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/international.h b/src/systems/si-international/include/units/isq/si/international/international.h index 9bdc7ec4..f3a8f2ab 100644 --- a/src/systems/si-international/include/units/isq/si/international/international.h +++ b/src/systems/si-international/include/units/isq/si/international/international.h @@ -23,9 +23,8 @@ #pragma once // IWYU pragma: begin_exports -#include - #include +#include #include #include // IWYU pragma: end_exports diff --git a/src/systems/si/include/units/isq/si/absorbed_dose.h b/src/systems/si/include/units/isq/si/absorbed_dose.h index 4be7370e..965665e8 100644 --- a/src/systems/si/include/units/isq/si/absorbed_dose.h +++ b/src/systems/si/include/units/isq/si/absorbed_dose.h @@ -67,92 +67,176 @@ using absorbed_dose = quantity; inline namespace literals { // Gy -constexpr auto operator"" _q_Gy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_Gy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_Gy(long double l) { return absorbed_dose(l); } // yGy -constexpr auto operator"" _q_yGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_yGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_yGy(long double l) { return absorbed_dose(l); } // zGy -constexpr auto operator"" _q_zGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_zGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_zGy(long double l) { return absorbed_dose(l); } // aGy -constexpr auto operator"" _q_aGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_aGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_aGy(long double l) { return absorbed_dose(l); } // fGy -constexpr auto operator"" _q_fGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_fGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_fGy(long double l) { return absorbed_dose(l); } // pGy -constexpr auto operator"" _q_pGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_pGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_pGy(long double l) { return absorbed_dose(l); } // nGy -constexpr auto operator"" _q_nGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_nGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_nGy(long double l) { return absorbed_dose(l); } // uGy -constexpr auto operator"" _q_uGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_uGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_uGy(long double l) { return absorbed_dose(l); } // mGy -constexpr auto operator"" _q_mGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_mGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_mGy(long double l) { return absorbed_dose(l); } // cGy -constexpr auto operator"" _q_cGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_cGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_cGy(long double l) { return absorbed_dose(l); } // dGy -constexpr auto operator"" _q_dGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_dGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_dGy(long double l) { return absorbed_dose(l); } // daGy -constexpr auto operator"" _q_daGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_daGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_daGy(long double l) { return absorbed_dose(l); } // hGy -constexpr auto operator"" _q_hGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_hGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_hGy(long double l) { return absorbed_dose(l); } // kGy -constexpr auto operator"" _q_kGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_kGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_kGy(long double l) { return absorbed_dose(l); } // MGy -constexpr auto operator"" _q_MGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_MGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_MGy(long double l) { return absorbed_dose(l); } // GGy -constexpr auto operator"" _q_GGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_GGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_GGy(long double l) { return absorbed_dose(l); } // TGy -constexpr auto operator"" _q_TGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_TGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_TGy(long double l) { return absorbed_dose(l); } // PGy -constexpr auto operator"" _q_PGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_PGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_PGy(long double l) { return absorbed_dose(l); } // EGy -constexpr auto operator"" _q_EGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_EGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_EGy(long double l) { return absorbed_dose(l); } // ZGy -constexpr auto operator"" _q_ZGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_ZGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_ZGy(long double l) { return absorbed_dose(l); } // YGy -constexpr auto operator"" _q_YGy(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return absorbed_dose(static_cast(l)); } +constexpr auto operator"" _q_YGy(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return absorbed_dose(static_cast(l)); +} constexpr auto operator"" _q_YGy(long double l) { return absorbed_dose(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -188,7 +272,7 @@ using namespace absorbed_dose_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -196,28 +280,49 @@ using namespace absorbed_dose_references; namespace units::aliases::isq::si::inline absorbed_dose { -template using Gy = units::isq::si::absorbed_dose; -template using yGy = units::isq::si::absorbed_dose; -template using zGy = units::isq::si::absorbed_dose; -template using aGy = units::isq::si::absorbed_dose; -template using fGy = units::isq::si::absorbed_dose; -template using pGy = units::isq::si::absorbed_dose; -template using nGy = units::isq::si::absorbed_dose; -template using uGy = units::isq::si::absorbed_dose; -template using mGy = units::isq::si::absorbed_dose; -template using cGy = units::isq::si::absorbed_dose; -template using dGy = units::isq::si::absorbed_dose; -template using daGy = units::isq::si::absorbed_dose; -template using hGy = units::isq::si::absorbed_dose; -template using kGy = units::isq::si::absorbed_dose; -template using MGy = units::isq::si::absorbed_dose; -template using GGy = units::isq::si::absorbed_dose; -template using TGy = units::isq::si::absorbed_dose; -template using PGy = units::isq::si::absorbed_dose; -template using EGy = units::isq::si::absorbed_dose; -template using ZGy = units::isq::si::absorbed_dose; -template using YGy = units::isq::si::absorbed_dose; +template +using Gy = units::isq::si::absorbed_dose; +template +using yGy = units::isq::si::absorbed_dose; +template +using zGy = units::isq::si::absorbed_dose; +template +using aGy = units::isq::si::absorbed_dose; +template +using fGy = units::isq::si::absorbed_dose; +template +using pGy = units::isq::si::absorbed_dose; +template +using nGy = units::isq::si::absorbed_dose; +template +using uGy = units::isq::si::absorbed_dose; +template +using mGy = units::isq::si::absorbed_dose; +template +using cGy = units::isq::si::absorbed_dose; +template +using dGy = units::isq::si::absorbed_dose; +template +using daGy = units::isq::si::absorbed_dose; +template +using hGy = units::isq::si::absorbed_dose; +template +using kGy = units::isq::si::absorbed_dose; +template +using MGy = units::isq::si::absorbed_dose; +template +using GGy = units::isq::si::absorbed_dose; +template +using TGy = units::isq::si::absorbed_dose; +template +using PGy = units::isq::si::absorbed_dose; +template +using EGy = units::isq::si::absorbed_dose; +template +using ZGy = units::isq::si::absorbed_dose; +template +using YGy = units::isq::si::absorbed_dose; } // namespace units::aliases::isq::si::inline absorbed_dose -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/acceleration.h b/src/systems/si/include/units/isq/si/acceleration.h index c6e8110e..313c1df5 100644 --- a/src/systems/si/include/units/isq/si/acceleration.h +++ b/src/systems/si/include/units/isq/si/acceleration.h @@ -44,12 +44,16 @@ using acceleration = quantity; inline namespace literals { // m/s2 -constexpr auto operator"" _q_m_per_s2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return acceleration(static_cast(l)); } +constexpr auto operator"" _q_m_per_s2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return acceleration(static_cast(l)); +} constexpr auto operator"" _q_m_per_s2(long double l) { return acceleration(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -57,8 +61,9 @@ constexpr auto operator"" _q_m_per_s2(long double l) { return acceleration using m_per_s2 = units::isq::si::acceleration; +template +using m_per_s2 = units::isq::si::acceleration; } // namespace units::aliases::isq::si::inline acceleration -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/amount_of_substance.h b/src/systems/si/include/units/isq/si/amount_of_substance.h index 79282af9..e5d40c80 100644 --- a/src/systems/si/include/units/isq/si/amount_of_substance.h +++ b/src/systems/si/include/units/isq/si/amount_of_substance.h @@ -46,12 +46,16 @@ using amount_of_substance = quantity; inline namespace literals { // mol -constexpr auto operator"" _q_mol(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return amount_of_substance(static_cast(l)); } +constexpr auto operator"" _q_mol(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return amount_of_substance(static_cast(l)); +} constexpr auto operator"" _q_mol(long double l) { return amount_of_substance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -67,7 +71,7 @@ using namespace amount_of_substance_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -75,8 +79,9 @@ using namespace amount_of_substance_references; namespace units::aliases::isq::si::inline amount_of_substance { -template using mol = units::isq::si::amount_of_substance; +template +using mol = units::isq::si::amount_of_substance; } // namespace units::aliases::isq::si::inline amount_of_substance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/angular_velocity.h b/src/systems/si/include/units/isq/si/angular_velocity.h index 52fd092b..fbb6e5c6 100644 --- a/src/systems/si/include/units/isq/si/angular_velocity.h +++ b/src/systems/si/include/units/isq/si/angular_velocity.h @@ -36,7 +36,8 @@ namespace units::isq::si { struct radian_per_second : named_unit {}; -struct dim_angular_velocity : isq::dim_angular_velocity, dim_time> {}; +struct dim_angular_velocity : + isq::dim_angular_velocity, dim_time> {}; template U, Representation Rep = double> using angular_velocity = quantity; @@ -46,12 +47,16 @@ using angular_velocity = quantity; inline namespace literals { // rad / s -constexpr auto operator"" _q_rad_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return angular_velocity(static_cast(l)); } +constexpr auto operator"" _q_rad_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return angular_velocity(static_cast(l)); +} constexpr auto operator"" _q_rad_per_s(long double l) { return angular_velocity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -59,8 +64,9 @@ constexpr auto operator"" _q_rad_per_s(long double l) { return angular_velocity< namespace units::aliases::isq::si::inline angular_velocity { -template using rad_per_s = units::isq::si::angular_velocity; +template +using rad_per_s = units::isq::si::angular_velocity; } // namespace units::aliases::isq::si::inline angular_velocity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/area.h b/src/systems/si/include/units/isq/si/area.h index 13d21a1a..98bcb87c 100644 --- a/src/systems/si/include/units/isq/si/area.h +++ b/src/systems/si/include/units/isq/si/area.h @@ -68,96 +68,184 @@ using area = quantity; inline namespace literals { // m2 -constexpr auto operator"" _q_m2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_m2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_m2(long double l) { return area(l); } // ym2 -constexpr auto operator"" _q_ym2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ym2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ym2(long double l) { return area(l); } // zm2 -constexpr auto operator"" _q_zm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_zm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_zm2(long double l) { return area(l); } // am2 -constexpr auto operator"" _q_am2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_am2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_am2(long double l) { return area(l); } // fm2 -constexpr auto operator"" _q_fm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_fm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_fm2(long double l) { return area(l); } // pm2 -constexpr auto operator"" _q_pm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_pm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_pm2(long double l) { return area(l); } // nm2 -constexpr auto operator"" _q_nm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_nm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_nm2(long double l) { return area(l); } // um2 -constexpr auto operator"" _q_um2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_um2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_um2(long double l) { return area(l); } // mm2 -constexpr auto operator"" _q_mm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_mm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_mm2(long double l) { return area(l); } // cm2 -constexpr auto operator"" _q_cm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_cm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_cm2(long double l) { return area(l); } // dm2 -constexpr auto operator"" _q_dm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_dm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_dm2(long double l) { return area(l); } // dam2 -constexpr auto operator"" _q_dam2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_dam2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_dam2(long double l) { return area(l); } // hm2 -constexpr auto operator"" _q_hm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_hm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_hm2(long double l) { return area(l); } // km2 -constexpr auto operator"" _q_km2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_km2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_km2(long double l) { return area(l); } // Mm2 -constexpr auto operator"" _q_Mm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Mm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Mm2(long double l) { return area(l); } // Gm2 -constexpr auto operator"" _q_Gm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Gm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Gm2(long double l) { return area(l); } // Tm2 -constexpr auto operator"" _q_Tm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Tm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Tm2(long double l) { return area(l); } // Pm2 -constexpr auto operator"" _q_Pm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Pm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Pm2(long double l) { return area(l); } // Em2 -constexpr auto operator"" _q_Em2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Em2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Em2(long double l) { return area(l); } // Zm2 -constexpr auto operator"" _q_Zm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Zm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Zm2(long double l) { return area(l); } // Ym2 -constexpr auto operator"" _q_Ym2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_Ym2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_Ym2(long double l) { return area(l); } // ha -constexpr auto operator"" _q_ha(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_ha(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_ha(long double l) { return area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -195,7 +283,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -203,30 +291,52 @@ using namespace area_references; namespace units::aliases::isq::si::inline area { -template using m2 = units::isq::si::area; -template using ym2 = units::isq::si::area; -template using zm2 = units::isq::si::area; -template using am2 = units::isq::si::area; -template using fm2 = units::isq::si::area; -template using pm2 = units::isq::si::area; -template using nm2 = units::isq::si::area; -template using um2 = units::isq::si::area; -template using mm2 = units::isq::si::area; -template using cm2 = units::isq::si::area; -template using dm2 = units::isq::si::area; -template using dam2 = units::isq::si::area; -template using hm2 = units::isq::si::area; -template using km2 = units::isq::si::area; -template using Mm2 = units::isq::si::area; -template using Gm2 = units::isq::si::area; -template using Tm2 = units::isq::si::area; -template using Pm2 = units::isq::si::area; -template using Em2 = units::isq::si::area; -template using Zm2 = units::isq::si::area; -template using Ym2 = units::isq::si::area; +template +using m2 = units::isq::si::area; +template +using ym2 = units::isq::si::area; +template +using zm2 = units::isq::si::area; +template +using am2 = units::isq::si::area; +template +using fm2 = units::isq::si::area; +template +using pm2 = units::isq::si::area; +template +using nm2 = units::isq::si::area; +template +using um2 = units::isq::si::area; +template +using mm2 = units::isq::si::area; +template +using cm2 = units::isq::si::area; +template +using dm2 = units::isq::si::area; +template +using dam2 = units::isq::si::area; +template +using hm2 = units::isq::si::area; +template +using km2 = units::isq::si::area; +template +using Mm2 = units::isq::si::area; +template +using Gm2 = units::isq::si::area; +template +using Tm2 = units::isq::si::area; +template +using Pm2 = units::isq::si::area; +template +using Em2 = units::isq::si::area; +template +using Zm2 = units::isq::si::area; +template +using Ym2 = units::isq::si::area; -template using ha = units::isq::si::area; +template +using ha = units::isq::si::area; } // namespace units::aliases::isq::si::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/capacitance.h b/src/systems/si/include/units/isq/si/capacitance.h index df1ddd8a..ddea6793 100644 --- a/src/systems/si/include/units/isq/si/capacitance.h +++ b/src/systems/si/include/units/isq/si/capacitance.h @@ -30,8 +30,8 @@ // IWYU pragma: end_exports #include -#include #include +#include #include namespace units::isq::si { @@ -68,92 +68,176 @@ using capacitance = quantity; inline namespace literals { // F -constexpr auto operator"" _q_F(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_F(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_F(long double l) { return capacitance(l); } // yF -constexpr auto operator"" _q_yF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_yF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_yF(long double l) { return capacitance(l); } // zF -constexpr auto operator"" _q_zF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_zF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_zF(long double l) { return capacitance(l); } // aF -constexpr auto operator"" _q_aF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_aF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_aF(long double l) { return capacitance(l); } // fF -constexpr auto operator"" _q_fF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_fF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_fF(long double l) { return capacitance(l); } // pF -constexpr auto operator"" _q_pF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_pF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_pF(long double l) { return capacitance(l); } // nF -constexpr auto operator"" _q_nF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_nF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_nF(long double l) { return capacitance(l); } // uF -constexpr auto operator"" _q_uF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_uF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_uF(long double l) { return capacitance(l); } // mF -constexpr auto operator"" _q_mF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_mF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_mF(long double l) { return capacitance(l); } // cF -constexpr auto operator"" _q_cF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_cF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_cF(long double l) { return capacitance(l); } // dF -constexpr auto operator"" _q_dF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_dF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_dF(long double l) { return capacitance(l); } // daF -constexpr auto operator"" _q_daF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_daF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_daF(long double l) { return capacitance(l); } // hF -constexpr auto operator"" _q_hF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_hF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_hF(long double l) { return capacitance(l); } // kF -constexpr auto operator"" _q_kF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_kF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_kF(long double l) { return capacitance(l); } // MF -constexpr auto operator"" _q_MF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_MF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_MF(long double l) { return capacitance(l); } // GF -constexpr auto operator"" _q_GF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_GF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_GF(long double l) { return capacitance(l); } // TF -constexpr auto operator"" _q_TF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_TF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_TF(long double l) { return capacitance(l); } // PF -constexpr auto operator"" _q_PF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_PF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_PF(long double l) { return capacitance(l); } // EF -constexpr auto operator"" _q_EF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_EF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_EF(long double l) { return capacitance(l); } // ZF -constexpr auto operator"" _q_ZF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_ZF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_ZF(long double l) { return capacitance(l); } // YF -constexpr auto operator"" _q_YF(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return capacitance(static_cast(l)); } +constexpr auto operator"" _q_YF(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return capacitance(static_cast(l)); +} constexpr auto operator"" _q_YF(long double l) { return capacitance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -189,7 +273,7 @@ using namespace capacitance_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -197,28 +281,49 @@ using namespace capacitance_references; namespace units::aliases::isq::si::inline capacitance { -template using F = units::isq::si::capacitance; -template using yF = units::isq::si::capacitance; -template using zF = units::isq::si::capacitance; -template using aF = units::isq::si::capacitance; -template using fF = units::isq::si::capacitance; -template using pF = units::isq::si::capacitance; -template using nF = units::isq::si::capacitance; -template using uF = units::isq::si::capacitance; -template using mF = units::isq::si::capacitance; -template using cF = units::isq::si::capacitance; -template using dF = units::isq::si::capacitance; -template using daF = units::isq::si::capacitance; -template using hF = units::isq::si::capacitance; -template using kF = units::isq::si::capacitance; -template using MF = units::isq::si::capacitance; -template using GF = units::isq::si::capacitance; -template using TF = units::isq::si::capacitance; -template using PF = units::isq::si::capacitance; -template using EF = units::isq::si::capacitance; -template using ZF = units::isq::si::capacitance; -template using YF = units::isq::si::capacitance; +template +using F = units::isq::si::capacitance; +template +using yF = units::isq::si::capacitance; +template +using zF = units::isq::si::capacitance; +template +using aF = units::isq::si::capacitance; +template +using fF = units::isq::si::capacitance; +template +using pF = units::isq::si::capacitance; +template +using nF = units::isq::si::capacitance; +template +using uF = units::isq::si::capacitance; +template +using mF = units::isq::si::capacitance; +template +using cF = units::isq::si::capacitance; +template +using dF = units::isq::si::capacitance; +template +using daF = units::isq::si::capacitance; +template +using hF = units::isq::si::capacitance; +template +using kF = units::isq::si::capacitance; +template +using MF = units::isq::si::capacitance; +template +using GF = units::isq::si::capacitance; +template +using TF = units::isq::si::capacitance; +template +using PF = units::isq::si::capacitance; +template +using EF = units::isq::si::capacitance; +template +using ZF = units::isq::si::capacitance; +template +using YF = units::isq::si::capacitance; } // namespace units::aliases::isq::si::inline capacitance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/concentration.h b/src/systems/si/include/units/isq/si/concentration.h index 903f943a..d59b3143 100644 --- a/src/systems/si/include/units/isq/si/concentration.h +++ b/src/systems/si/include/units/isq/si/concentration.h @@ -28,14 +28,15 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si { struct mol_per_metre_cub : unit {}; -struct dim_concentration : isq::dim_concentration {}; +struct dim_concentration : + isq::dim_concentration {}; template U, Representation Rep = double> using concentration = quantity; @@ -45,12 +46,16 @@ using concentration = quantity; inline namespace literals { // mol/m³ -constexpr auto operator"" _q_mol_per_m3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return concentration(static_cast(l)); } +constexpr auto operator"" _q_mol_per_m3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return concentration(static_cast(l)); +} constexpr auto operator"" _q_mol_per_m3(long double l) { return concentration(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -58,8 +63,9 @@ constexpr auto operator"" _q_mol_per_m3(long double l) { return concentration using mol_per_m3 = units::isq::si::concentration; +template +using mol_per_m3 = units::isq::si::concentration; } // namespace units::aliases::isq::si::inline concentration -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/conductance.h b/src/systems/si/include/units/isq/si/conductance.h index 50fd7dee..36b8cc13 100644 --- a/src/systems/si/include/units/isq/si/conductance.h +++ b/src/systems/si/include/units/isq/si/conductance.h @@ -29,8 +29,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si { @@ -63,76 +63,144 @@ using conductance = quantity; inline namespace literals { // R -constexpr auto operator"" _q_S(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_S(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_S(long double l) { return conductance(l); } // yS -constexpr auto operator"" _q_yS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_yS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_yS(long double l) { return conductance(l); } // zS -constexpr auto operator"" _q_zS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_zS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_zS(long double l) { return conductance(l); } // aS -constexpr auto operator"" _q_aS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_aS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_aS(long double l) { return conductance(l); } // fS -constexpr auto operator"" _q_fS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_fS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_fS(long double l) { return conductance(l); } // pS -constexpr auto operator"" _q_pS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_pS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_pS(long double l) { return conductance(l); } // nS -constexpr auto operator"" _q_nS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_nS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_nS(long double l) { return conductance(l); } // µS -constexpr auto operator"" _q_uS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_uS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_uS(long double l) { return conductance(l); } // mS -constexpr auto operator"" _q_mS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_mS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_mS(long double l) { return conductance(l); } // kS -constexpr auto operator"" _q_kS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_kS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_kS(long double l) { return conductance(l); } // MS -constexpr auto operator"" _q_MS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_MS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_MS(long double l) { return conductance(l); } // GS -constexpr auto operator"" _q_GS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_GS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_GS(long double l) { return conductance(l); } // TS -constexpr auto operator"" _q_TS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_TS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_TS(long double l) { return conductance(l); } // PS -constexpr auto operator"" _q_PS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_PS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_PS(long double l) { return conductance(l); } // ES -constexpr auto operator"" _q_ES(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_ES(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_ES(long double l) { return conductance(l); } // ZS -constexpr auto operator"" _q_ZS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_ZS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_ZS(long double l) { return conductance(l); } // YS -constexpr auto operator"" _q_YS(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return conductance(static_cast(l)); } +constexpr auto operator"" _q_YS(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return conductance(static_cast(l)); +} constexpr auto operator"" _q_YS(long double l) { return conductance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -164,7 +232,7 @@ using namespace conductance_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -172,24 +240,41 @@ using namespace conductance_references; namespace units::aliases::isq::si::inline conductance { -template using S = units::isq::si::conductance; -template using yS = units::isq::si::conductance; -template using zS = units::isq::si::conductance; -template using aS = units::isq::si::conductance; -template using fS = units::isq::si::conductance; -template using pS = units::isq::si::conductance; -template using nS = units::isq::si::conductance; -template using uS = units::isq::si::conductance; -template using mS = units::isq::si::conductance; -template using kS = units::isq::si::conductance; -template using MS = units::isq::si::conductance; -template using GS = units::isq::si::conductance; -template using TS = units::isq::si::conductance; -template using PS = units::isq::si::conductance; -template using ES = units::isq::si::conductance; -template using ZS = units::isq::si::conductance; -template using YS = units::isq::si::conductance; +template +using S = units::isq::si::conductance; +template +using yS = units::isq::si::conductance; +template +using zS = units::isq::si::conductance; +template +using aS = units::isq::si::conductance; +template +using fS = units::isq::si::conductance; +template +using pS = units::isq::si::conductance; +template +using nS = units::isq::si::conductance; +template +using uS = units::isq::si::conductance; +template +using mS = units::isq::si::conductance; +template +using kS = units::isq::si::conductance; +template +using MS = units::isq::si::conductance; +template +using GS = units::isq::si::conductance; +template +using TS = units::isq::si::conductance; +template +using PS = units::isq::si::conductance; +template +using ES = units::isq::si::conductance; +template +using ZS = units::isq::si::conductance; +template +using YS = units::isq::si::conductance; } // namespace units::aliases::isq::si::inline conductance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/density.h b/src/systems/si/include/units/isq/si/density.h index 5b0cf016..9a06b479 100644 --- a/src/systems/si/include/units/isq/si/density.h +++ b/src/systems/si/include/units/isq/si/density.h @@ -28,8 +28,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include #include @@ -47,12 +47,16 @@ using density = quantity; inline namespace literals { // kg / m³ -constexpr auto operator"" _q_kg_per_m3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return density(static_cast(l)); } +constexpr auto operator"" _q_kg_per_m3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return density(static_cast(l)); +} constexpr auto operator"" _q_kg_per_m3(long double l) { return density(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -60,8 +64,9 @@ constexpr auto operator"" _q_kg_per_m3(long double l) { return density using kg_per_m3 = units::isq::si::density; +template +using kg_per_m3 = units::isq::si::density; } // namespace units::aliases::isq::si::inline density -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/energy.h b/src/systems/si/include/units/isq/si/energy.h index 99350d2c..2ca2fc9b 100644 --- a/src/systems/si/include/units/isq/si/energy.h +++ b/src/systems/si/include/units/isq/si/energy.h @@ -53,7 +53,8 @@ struct exajoule : prefixed_unit {}; struct zettajoule : prefixed_unit {}; struct yottajoule : prefixed_unit {}; -// N.B. electron charge (and eV) is an exact constant: https://www.bipm.org/documents/20126/41483022/SI-Brochure-9.pdf#page=147 +// N.B. electron charge (and eV) is an exact constant: +// https://www.bipm.org/documents/20126/41483022/SI-Brochure-9.pdf#page=147 struct electronvolt : named_scaled_unit {}; struct gigaelectronvolt : prefixed_unit {}; @@ -67,84 +68,160 @@ using energy = quantity; inline namespace literals { // J -constexpr auto operator"" _q_J(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_J(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_J(long double l) { return energy(l); } // yJ -constexpr auto operator"" _q_yJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_yJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_yJ(long double l) { return energy(l); } // zJ -constexpr auto operator"" _q_zJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_zJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_zJ(long double l) { return energy(l); } // aJ -constexpr auto operator"" _q_aJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_aJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_aJ(long double l) { return energy(l); } // fJ -constexpr auto operator"" _q_fJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_fJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_fJ(long double l) { return energy(l); } // pJ -constexpr auto operator"" _q_pJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_pJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_pJ(long double l) { return energy(l); } // nJ -constexpr auto operator"" _q_nJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_nJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_nJ(long double l) { return energy(l); } // uJ -constexpr auto operator"" _q_uJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_uJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_uJ(long double l) { return energy(l); } // mJ -constexpr auto operator"" _q_mJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_mJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_mJ(long double l) { return energy(l); } // kJ -constexpr auto operator"" _q_kJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_kJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_kJ(long double l) { return energy(l); } // MJ -constexpr auto operator"" _q_MJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_MJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_MJ(long double l) { return energy(l); } // GJ -constexpr auto operator"" _q_GJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_GJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_GJ(long double l) { return energy(l); } // TJ -constexpr auto operator"" _q_TJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_TJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_TJ(long double l) { return energy(l); } // PJ -constexpr auto operator"" _q_PJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_PJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_PJ(long double l) { return energy(l); } // EJ -constexpr auto operator"" _q_EJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_EJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_EJ(long double l) { return energy(l); } // ZJ -constexpr auto operator"" _q_ZJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_ZJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_ZJ(long double l) { return energy(l); } // YJ -constexpr auto operator"" _q_YJ(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_YJ(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_YJ(long double l) { return energy(l); } // eV -constexpr auto operator"" _q_eV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_eV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_eV(long double l) { return energy(l); } // GeV -constexpr auto operator"" _q_GeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_GeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_GeV(long double l) { return energy(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -179,7 +256,7 @@ using namespace energy_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -187,27 +264,46 @@ using namespace energy_references; namespace units::aliases::isq::si::inline energy { -template using J = units::isq::si::energy; -template using yJ = units::isq::si::energy; -template using zJ = units::isq::si::energy; -template using aJ = units::isq::si::energy; -template using fJ = units::isq::si::energy; -template using pJ = units::isq::si::energy; -template using nJ = units::isq::si::energy; -template using uJ = units::isq::si::energy; -template using mJ = units::isq::si::energy; -template using kJ = units::isq::si::energy; -template using MJ = units::isq::si::energy; -template using GJ = units::isq::si::energy; -template using TJ = units::isq::si::energy; -template using PJ = units::isq::si::energy; -template using EJ = units::isq::si::energy; -template using ZJ = units::isq::si::energy; -template using YJ = units::isq::si::energy; +template +using J = units::isq::si::energy; +template +using yJ = units::isq::si::energy; +template +using zJ = units::isq::si::energy; +template +using aJ = units::isq::si::energy; +template +using fJ = units::isq::si::energy; +template +using pJ = units::isq::si::energy; +template +using nJ = units::isq::si::energy; +template +using uJ = units::isq::si::energy; +template +using mJ = units::isq::si::energy; +template +using kJ = units::isq::si::energy; +template +using MJ = units::isq::si::energy; +template +using GJ = units::isq::si::energy; +template +using TJ = units::isq::si::energy; +template +using PJ = units::isq::si::energy; +template +using EJ = units::isq::si::energy; +template +using ZJ = units::isq::si::energy; +template +using YJ = units::isq::si::energy; -template using eV = units::isq::si::energy; -template using GeV = units::isq::si::energy; +template +using eV = units::isq::si::energy; +template +using GeV = units::isq::si::energy; } // namespace units::aliases::isq::si::inline energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/force.h b/src/systems/si/include/units/isq/si/force.h index 484e7aeb..c0977aaf 100644 --- a/src/systems/si/include/units/isq/si/force.h +++ b/src/systems/si/include/units/isq/si/force.h @@ -68,92 +68,176 @@ using force = quantity; inline namespace literals { // N -constexpr auto operator"" _q_N(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_N(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_N(long double l) { return force(l); } // yN -constexpr auto operator"" _q_yN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_yN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_yN(long double l) { return force(l); } // zN -constexpr auto operator"" _q_zN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_zN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_zN(long double l) { return force(l); } // aN -constexpr auto operator"" _q_aN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_aN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_aN(long double l) { return force(l); } // fN -constexpr auto operator"" _q_fN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_fN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_fN(long double l) { return force(l); } // pN -constexpr auto operator"" _q_pN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_pN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_pN(long double l) { return force(l); } // nN -constexpr auto operator"" _q_nN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_nN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_nN(long double l) { return force(l); } // uN -constexpr auto operator"" _q_uN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_uN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_uN(long double l) { return force(l); } // mN -constexpr auto operator"" _q_mN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_mN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_mN(long double l) { return force(l); } // cN -constexpr auto operator"" _q_cN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_cN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_cN(long double l) { return force(l); } // dN -constexpr auto operator"" _q_dN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_dN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_dN(long double l) { return force(l); } // daN -constexpr auto operator"" _q_daN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_daN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_daN(long double l) { return force(l); } // hN -constexpr auto operator"" _q_hN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_hN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_hN(long double l) { return force(l); } // kN -constexpr auto operator"" _q_kN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_kN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_kN(long double l) { return force(l); } // MN -constexpr auto operator"" _q_MN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_MN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_MN(long double l) { return force(l); } // GN -constexpr auto operator"" _q_GN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_GN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_GN(long double l) { return force(l); } // TN -constexpr auto operator"" _q_TN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_TN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_TN(long double l) { return force(l); } // PN -constexpr auto operator"" _q_PN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_PN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_PN(long double l) { return force(l); } // EN -constexpr auto operator"" _q_EN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_EN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_EN(long double l) { return force(l); } // ZN -constexpr auto operator"" _q_ZN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_ZN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_ZN(long double l) { return force(l); } // YN -constexpr auto operator"" _q_YN(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_YN(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_YN(long double l) { return force(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -189,7 +273,7 @@ using namespace force_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -197,28 +281,49 @@ using namespace force_references; namespace units::aliases::isq::si::inline force { -template using N = units::isq::si::force; -template using yN = units::isq::si::force; -template using zN = units::isq::si::force; -template using aN = units::isq::si::force; -template using fN = units::isq::si::force; -template using pN = units::isq::si::force; -template using nN = units::isq::si::force; -template using uN = units::isq::si::force; -template using mN = units::isq::si::force; -template using cN = units::isq::si::force; -template using dN = units::isq::si::force; -template using daN = units::isq::si::force; -template using hN = units::isq::si::force; -template using kN = units::isq::si::force; -template using MN = units::isq::si::force; -template using GN = units::isq::si::force; -template using TN = units::isq::si::force; -template using PN = units::isq::si::force; -template using EN = units::isq::si::force; -template using ZN = units::isq::si::force; -template using YN = units::isq::si::force; +template +using N = units::isq::si::force; +template +using yN = units::isq::si::force; +template +using zN = units::isq::si::force; +template +using aN = units::isq::si::force; +template +using fN = units::isq::si::force; +template +using pN = units::isq::si::force; +template +using nN = units::isq::si::force; +template +using uN = units::isq::si::force; +template +using mN = units::isq::si::force; +template +using cN = units::isq::si::force; +template +using dN = units::isq::si::force; +template +using daN = units::isq::si::force; +template +using hN = units::isq::si::force; +template +using kN = units::isq::si::force; +template +using MN = units::isq::si::force; +template +using GN = units::isq::si::force; +template +using TN = units::isq::si::force; +template +using PN = units::isq::si::force; +template +using EN = units::isq::si::force; +template +using ZN = units::isq::si::force; +template +using YN = units::isq::si::force; } // namespace units::aliases::isq::si::inline force -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/luminance.h b/src/systems/si/include/units/isq/si/luminance.h index d1de3b44..d6c6b74f 100644 --- a/src/systems/si/include/units/isq/si/luminance.h +++ b/src/systems/si/include/units/isq/si/luminance.h @@ -45,12 +45,16 @@ using luminance = quantity; inline namespace literals { // cd/m² -constexpr auto operator"" _q_cd_per_m2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminance(static_cast(l)); } +constexpr auto operator"" _q_cd_per_m2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminance(static_cast(l)); +} constexpr auto operator"" _q_cd_per_m2(long double l) { return luminance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -58,8 +62,9 @@ constexpr auto operator"" _q_cd_per_m2(long double l) { return luminance using cd_per_m2 = units::isq::si::luminance; +template +using cd_per_m2 = units::isq::si::luminance; } // namespace units::aliases::isq::si::inline luminance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/luminous_intensity.h b/src/systems/si/include/units/isq/si/luminous_intensity.h index 7d0a78ec..e4eff3c5 100644 --- a/src/systems/si/include/units/isq/si/luminous_intensity.h +++ b/src/systems/si/include/units/isq/si/luminous_intensity.h @@ -66,92 +66,176 @@ using luminous_intensity = quantity; inline namespace literals { // cd -constexpr auto operator"" _q_cd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_cd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_cd(long double l) { return luminous_intensity(l); } // ycd -constexpr auto operator"" _q_ycd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_ycd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_ycd(long double l) { return luminous_intensity(l); } // zcd -constexpr auto operator"" _q_zcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_zcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_zcd(long double l) { return luminous_intensity(l); } // acd -constexpr auto operator"" _q_acd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_acd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_acd(long double l) { return luminous_intensity(l); } // fcd -constexpr auto operator"" _q_fcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_fcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_fcd(long double l) { return luminous_intensity(l); } // pcd -constexpr auto operator"" _q_pcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_pcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_pcd(long double l) { return luminous_intensity(l); } // ncd -constexpr auto operator"" _q_ncd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_ncd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_ncd(long double l) { return luminous_intensity(l); } // ucd -constexpr auto operator"" _q_ucd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_ucd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_ucd(long double l) { return luminous_intensity(l); } // mcd -constexpr auto operator"" _q_mcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_mcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_mcd(long double l) { return luminous_intensity(l); } // ccd -constexpr auto operator"" _q_ccd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_ccd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_ccd(long double l) { return luminous_intensity(l); } // dcd -constexpr auto operator"" _q_dcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_dcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_dcd(long double l) { return luminous_intensity(l); } // dacd -constexpr auto operator"" _q_dacd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_dacd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_dacd(long double l) { return luminous_intensity(l); } // hcd -constexpr auto operator"" _q_hcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_hcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_hcd(long double l) { return luminous_intensity(l); } // kcd -constexpr auto operator"" _q_kcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_kcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_kcd(long double l) { return luminous_intensity(l); } // Mcd -constexpr auto operator"" _q_Mcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Mcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Mcd(long double l) { return luminous_intensity(l); } // Gcd -constexpr auto operator"" _q_Gcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Gcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Gcd(long double l) { return luminous_intensity(l); } // Tcd -constexpr auto operator"" _q_Tcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Tcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Tcd(long double l) { return luminous_intensity(l); } // Pcd -constexpr auto operator"" _q_Pcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Pcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Pcd(long double l) { return luminous_intensity(l); } // Ecd -constexpr auto operator"" _q_Ecd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Ecd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Ecd(long double l) { return luminous_intensity(l); } // Zcd -constexpr auto operator"" _q_Zcd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Zcd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Zcd(long double l) { return luminous_intensity(l); } // Ycd -constexpr auto operator"" _q_Ycd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return luminous_intensity(static_cast(l)); } +constexpr auto operator"" _q_Ycd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_intensity(static_cast(l)); +} constexpr auto operator"" _q_Ycd(long double l) { return luminous_intensity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -187,7 +271,7 @@ using namespace luminous_intensity_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -195,28 +279,49 @@ using namespace luminous_intensity_references; namespace units::aliases::isq::si::luminous_intensity { -template using cd = units::isq::si::luminous_intensity; -template using ycd = units::isq::si::luminous_intensity; -template using zcd = units::isq::si::luminous_intensity; -template using acd = units::isq::si::luminous_intensity; -template using fcd = units::isq::si::luminous_intensity; -template using pcd = units::isq::si::luminous_intensity; -template using ncd = units::isq::si::luminous_intensity; -template using ucd = units::isq::si::luminous_intensity; -template using mcd = units::isq::si::luminous_intensity; -template using ccd = units::isq::si::luminous_intensity; -template using dcd = units::isq::si::luminous_intensity; -template using dacd = units::isq::si::luminous_intensity; -template using hcd = units::isq::si::luminous_intensity; -template using kcd = units::isq::si::luminous_intensity; -template using Mcd = units::isq::si::luminous_intensity; -template using Gcd = units::isq::si::luminous_intensity; -template using Tcd = units::isq::si::luminous_intensity; -template using Pcd = units::isq::si::luminous_intensity; -template using Ecd = units::isq::si::luminous_intensity; -template using Zcd = units::isq::si::luminous_intensity; -template using Ycd = units::isq::si::luminous_intensity; +template +using cd = units::isq::si::luminous_intensity; +template +using ycd = units::isq::si::luminous_intensity; +template +using zcd = units::isq::si::luminous_intensity; +template +using acd = units::isq::si::luminous_intensity; +template +using fcd = units::isq::si::luminous_intensity; +template +using pcd = units::isq::si::luminous_intensity; +template +using ncd = units::isq::si::luminous_intensity; +template +using ucd = units::isq::si::luminous_intensity; +template +using mcd = units::isq::si::luminous_intensity; +template +using ccd = units::isq::si::luminous_intensity; +template +using dcd = units::isq::si::luminous_intensity; +template +using dacd = units::isq::si::luminous_intensity; +template +using hcd = units::isq::si::luminous_intensity; +template +using kcd = units::isq::si::luminous_intensity; +template +using Mcd = units::isq::si::luminous_intensity; +template +using Gcd = units::isq::si::luminous_intensity; +template +using Tcd = units::isq::si::luminous_intensity; +template +using Pcd = units::isq::si::luminous_intensity; +template +using Ecd = units::isq::si::luminous_intensity; +template +using Zcd = units::isq::si::luminous_intensity; +template +using Ycd = units::isq::si::luminous_intensity; } // namespace units::aliases::isq::si::luminous_intensity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/molar_energy.h b/src/systems/si/include/units/isq/si/molar_energy.h index ff1d888e..fa4cae49 100644 --- a/src/systems/si/include/units/isq/si/molar_energy.h +++ b/src/systems/si/include/units/isq/si/molar_energy.h @@ -28,8 +28,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include #include @@ -37,7 +37,8 @@ namespace units::isq::si { struct joule_per_mole : unit {}; -struct dim_molar_energy : isq::dim_molar_energy {}; +struct dim_molar_energy : + isq::dim_molar_energy {}; template U, Representation Rep = double> using molar_energy = quantity; @@ -47,12 +48,16 @@ using molar_energy = quantity; inline namespace literals { // J/mol -constexpr auto operator"" _q_J_per_mol(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return molar_energy(static_cast(l)); } +constexpr auto operator"" _q_J_per_mol(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return molar_energy(static_cast(l)); +} constexpr auto operator"" _q_J_per_mol(long double l) { return molar_energy(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -60,8 +65,9 @@ constexpr auto operator"" _q_J_per_mol(long double l) { return molar_energy using J_per_mol = units::isq::si::molar_energy; +template +using J_per_mol = units::isq::si::molar_energy; } // namespace units::aliases::isq::si::inline molar_energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/pressure.h b/src/systems/si/include/units/isq/si/pressure.h index ca0448c7..b3c94279 100644 --- a/src/systems/si/include/units/isq/si/pressure.h +++ b/src/systems/si/include/units/isq/si/pressure.h @@ -68,92 +68,176 @@ using pressure = quantity; inline namespace literals { // Pa -constexpr auto operator"" _q_Pa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_Pa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_Pa(long double l) { return pressure(l); } // yPa -constexpr auto operator"" _q_yPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_yPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_yPa(long double l) { return pressure(l); } // zPa -constexpr auto operator"" _q_zPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_zPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_zPa(long double l) { return pressure(l); } // aPa -constexpr auto operator"" _q_aPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_aPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_aPa(long double l) { return pressure(l); } // fPa -constexpr auto operator"" _q_fPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_fPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_fPa(long double l) { return pressure(l); } // pPa -constexpr auto operator"" _q_pPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_pPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_pPa(long double l) { return pressure(l); } // nPa -constexpr auto operator"" _q_nPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_nPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_nPa(long double l) { return pressure(l); } // uPa -constexpr auto operator"" _q_uPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_uPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_uPa(long double l) { return pressure(l); } // mPa -constexpr auto operator"" _q_mPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_mPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_mPa(long double l) { return pressure(l); } // cPa -constexpr auto operator"" _q_cPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_cPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_cPa(long double l) { return pressure(l); } // dPa -constexpr auto operator"" _q_dPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_dPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_dPa(long double l) { return pressure(l); } // daPa -constexpr auto operator"" _q_daPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_daPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_daPa(long double l) { return pressure(l); } // hPa -constexpr auto operator"" _q_hPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_hPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_hPa(long double l) { return pressure(l); } // kPa -constexpr auto operator"" _q_kPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_kPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_kPa(long double l) { return pressure(l); } // MPa -constexpr auto operator"" _q_MPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_MPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_MPa(long double l) { return pressure(l); } // GPa -constexpr auto operator"" _q_GPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_GPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_GPa(long double l) { return pressure(l); } // TPa -constexpr auto operator"" _q_TPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_TPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_TPa(long double l) { return pressure(l); } // PPa -constexpr auto operator"" _q_PPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_PPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_PPa(long double l) { return pressure(l); } // EPa -constexpr auto operator"" _q_EPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_EPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_EPa(long double l) { return pressure(l); } // ZPa -constexpr auto operator"" _q_ZPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_ZPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_ZPa(long double l) { return pressure(l); } // YPa -constexpr auto operator"" _q_YPa(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_YPa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_YPa(long double l) { return pressure(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -189,7 +273,7 @@ using namespace pressure_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -197,28 +281,49 @@ using namespace pressure_references; namespace units::aliases::isq::si::inline pressure { -template using Pa = units::isq::si::pressure; -template using yPa = units::isq::si::pressure; -template using zPa = units::isq::si::pressure; -template using aPa = units::isq::si::pressure; -template using fPa = units::isq::si::pressure; -template using pPa = units::isq::si::pressure; -template using nPa = units::isq::si::pressure; -template using uPa = units::isq::si::pressure; -template using mPa = units::isq::si::pressure; -template using cPa = units::isq::si::pressure; -template using dPa = units::isq::si::pressure; -template using daPa = units::isq::si::pressure; -template using hPa = units::isq::si::pressure; -template using kPa = units::isq::si::pressure; -template using MPa = units::isq::si::pressure; -template using GPa = units::isq::si::pressure; -template using TPa = units::isq::si::pressure; -template using PPa = units::isq::si::pressure; -template using EPa = units::isq::si::pressure; -template using ZPa = units::isq::si::pressure; -template using YPa = units::isq::si::pressure; +template +using Pa = units::isq::si::pressure; +template +using yPa = units::isq::si::pressure; +template +using zPa = units::isq::si::pressure; +template +using aPa = units::isq::si::pressure; +template +using fPa = units::isq::si::pressure; +template +using pPa = units::isq::si::pressure; +template +using nPa = units::isq::si::pressure; +template +using uPa = units::isq::si::pressure; +template +using mPa = units::isq::si::pressure; +template +using cPa = units::isq::si::pressure; +template +using dPa = units::isq::si::pressure; +template +using daPa = units::isq::si::pressure; +template +using hPa = units::isq::si::pressure; +template +using kPa = units::isq::si::pressure; +template +using MPa = units::isq::si::pressure; +template +using GPa = units::isq::si::pressure; +template +using TPa = units::isq::si::pressure; +template +using PPa = units::isq::si::pressure; +template +using EPa = units::isq::si::pressure; +template +using ZPa = units::isq::si::pressure; +template +using YPa = units::isq::si::pressure; } // namespace units::aliases::isq::si::inline pressure -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/radioactivity.h b/src/systems/si/include/units/isq/si/radioactivity.h index 2c2c8dc3..017d8fcf 100644 --- a/src/systems/si/include/units/isq/si/radioactivity.h +++ b/src/systems/si/include/units/isq/si/radioactivity.h @@ -66,92 +66,176 @@ using radioactivity = quantity; inline namespace literals { // Bq -constexpr auto operator"" _q_Bq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_Bq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_Bq(long double l) { return radioactivity(l); } // yBq -constexpr auto operator"" _q_yBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_yBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_yBq(long double l) { return radioactivity(l); } // zBq -constexpr auto operator"" _q_zBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_zBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_zBq(long double l) { return radioactivity(l); } // aBq -constexpr auto operator"" _q_aBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_aBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_aBq(long double l) { return radioactivity(l); } // fBq -constexpr auto operator"" _q_fBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_fBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_fBq(long double l) { return radioactivity(l); } // pBq -constexpr auto operator"" _q_pBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_pBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_pBq(long double l) { return radioactivity(l); } // nBq -constexpr auto operator"" _q_nBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_nBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_nBq(long double l) { return radioactivity(l); } // uBq -constexpr auto operator"" _q_uBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_uBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_uBq(long double l) { return radioactivity(l); } // mBq -constexpr auto operator"" _q_mBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_mBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_mBq(long double l) { return radioactivity(l); } // cBq -constexpr auto operator"" _q_cBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_cBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_cBq(long double l) { return radioactivity(l); } // dBq -constexpr auto operator"" _q_dBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_dBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_dBq(long double l) { return radioactivity(l); } // daBq -constexpr auto operator"" _q_daBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_daBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_daBq(long double l) { return radioactivity(l); } // hBq -constexpr auto operator"" _q_hBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_hBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_hBq(long double l) { return radioactivity(l); } // kBq -constexpr auto operator"" _q_kBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_kBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_kBq(long double l) { return radioactivity(l); } // MBq -constexpr auto operator"" _q_MBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_MBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_MBq(long double l) { return radioactivity(l); } // GBq -constexpr auto operator"" _q_GBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_GBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_GBq(long double l) { return radioactivity(l); } // TBq -constexpr auto operator"" _q_TBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_TBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_TBq(long double l) { return radioactivity(l); } // PBq -constexpr auto operator"" _q_PBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_PBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_PBq(long double l) { return radioactivity(l); } // EBq -constexpr auto operator"" _q_EBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_EBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_EBq(long double l) { return radioactivity(l); } // ZBq -constexpr auto operator"" _q_ZBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_ZBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_ZBq(long double l) { return radioactivity(l); } // YBq -constexpr auto operator"" _q_YBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_YBq(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return radioactivity(static_cast(l)); +} constexpr auto operator"" _q_YBq(long double l) { return radioactivity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -187,7 +271,7 @@ using namespace radioactivity_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -195,28 +279,49 @@ using namespace radioactivity_references; namespace units::aliases::isq::si::inline radioactivity { -template using Bq = units::isq::radioactivity; -template using yBq = units::isq::radioactivity; -template using zBq = units::isq::radioactivity; -template using aBq = units::isq::radioactivity; -template using fBq = units::isq::radioactivity; -template using pBq = units::isq::radioactivity; -template using nBq = units::isq::radioactivity; -template using uBq = units::isq::radioactivity; -template using mBq = units::isq::radioactivity; -template using cBq = units::isq::radioactivity; -template using dBq = units::isq::radioactivity; -template using daBq = units::isq::radioactivity; -template using hBq = units::isq::radioactivity; -template using kBq = units::isq::radioactivity; -template using MBq = units::isq::radioactivity; -template using GBq = units::isq::radioactivity; -template using TBq = units::isq::radioactivity; -template using PBq = units::isq::radioactivity; -template using EBq = units::isq::radioactivity; -template using ZBq = units::isq::radioactivity; -template using YBq = units::isq::radioactivity; +template +using Bq = units::isq::radioactivity; +template +using yBq = units::isq::radioactivity; +template +using zBq = units::isq::radioactivity; +template +using aBq = units::isq::radioactivity; +template +using fBq = units::isq::radioactivity; +template +using pBq = units::isq::radioactivity; +template +using nBq = units::isq::radioactivity; +template +using uBq = units::isq::radioactivity; +template +using mBq = units::isq::radioactivity; +template +using cBq = units::isq::radioactivity; +template +using dBq = units::isq::radioactivity; +template +using daBq = units::isq::radioactivity; +template +using hBq = units::isq::radioactivity; +template +using kBq = units::isq::radioactivity; +template +using MBq = units::isq::radioactivity; +template +using GBq = units::isq::radioactivity; +template +using TBq = units::isq::radioactivity; +template +using PBq = units::isq::radioactivity; +template +using EBq = units::isq::radioactivity; +template +using ZBq = units::isq::radioactivity; +template +using YBq = units::isq::radioactivity; } // namespace units::aliases::isq::si::inline radioactivity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/voltage.h b/src/systems/si/include/units/isq/si/voltage.h index 8f10478f..31922688 100644 --- a/src/systems/si/include/units/isq/si/voltage.h +++ b/src/systems/si/include/units/isq/si/voltage.h @@ -68,92 +68,176 @@ using voltage = quantity; inline namespace literals { // V -constexpr auto operator"" _q_V(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_V(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_V(long double l) { return voltage(l); } // yV -constexpr auto operator"" _q_yV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_yV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_yV(long double l) { return voltage(l); } // zV -constexpr auto operator"" _q_zV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_zV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_zV(long double l) { return voltage(l); } // aV -constexpr auto operator"" _q_aV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_aV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_aV(long double l) { return voltage(l); } // fV -constexpr auto operator"" _q_fV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_fV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_fV(long double l) { return voltage(l); } // pV -constexpr auto operator"" _q_pV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_pV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_pV(long double l) { return voltage(l); } // nV -constexpr auto operator"" _q_nV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_nV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_nV(long double l) { return voltage(l); } // uV -constexpr auto operator"" _q_uV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_uV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_uV(long double l) { return voltage(l); } // mV -constexpr auto operator"" _q_mV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_mV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_mV(long double l) { return voltage(l); } // cV -constexpr auto operator"" _q_cV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_cV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_cV(long double l) { return voltage(l); } // dV -constexpr auto operator"" _q_dV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_dV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_dV(long double l) { return voltage(l); } // daV -constexpr auto operator"" _q_daV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_daV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_daV(long double l) { return voltage(l); } // hV -constexpr auto operator"" _q_hV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_hV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_hV(long double l) { return voltage(l); } // kV -constexpr auto operator"" _q_kV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_kV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_kV(long double l) { return voltage(l); } // MV -constexpr auto operator"" _q_MV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_MV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_MV(long double l) { return voltage(l); } // GV -constexpr auto operator"" _q_GV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_GV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_GV(long double l) { return voltage(l); } // TV -constexpr auto operator"" _q_TV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_TV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_TV(long double l) { return voltage(l); } // PV -constexpr auto operator"" _q_PV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_PV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_PV(long double l) { return voltage(l); } // EV -constexpr auto operator"" _q_EV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_EV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_EV(long double l) { return voltage(l); } // ZV -constexpr auto operator"" _q_ZV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_ZV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_ZV(long double l) { return voltage(l); } // YV -constexpr auto operator"" _q_YV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return voltage(static_cast(l)); } +constexpr auto operator"" _q_YV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return voltage(static_cast(l)); +} constexpr auto operator"" _q_YV(long double l) { return voltage(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -189,7 +273,7 @@ using namespace voltage_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -197,28 +281,49 @@ using namespace voltage_references; namespace units::aliases::isq::si::inline voltage { -template using V = units::isq::si::voltage; -template using yV = units::isq::si::voltage; -template using zV = units::isq::si::voltage; -template using aV = units::isq::si::voltage; -template using fV = units::isq::si::voltage; -template using pV = units::isq::si::voltage; -template using nV = units::isq::si::voltage; -template using uV = units::isq::si::voltage; -template using mV = units::isq::si::voltage; -template using cV = units::isq::si::voltage; -template using dV = units::isq::si::voltage; -template using daV = units::isq::si::voltage; -template using hV = units::isq::si::voltage; -template using kV = units::isq::si::voltage; -template using MV = units::isq::si::voltage; -template using GV = units::isq::si::voltage; -template using TV = units::isq::si::voltage; -template using PV = units::isq::si::voltage; -template using EV = units::isq::si::voltage; -template using ZV = units::isq::si::voltage; -template using YV = units::isq::si::voltage; +template +using V = units::isq::si::voltage; +template +using yV = units::isq::si::voltage; +template +using zV = units::isq::si::voltage; +template +using aV = units::isq::si::voltage; +template +using fV = units::isq::si::voltage; +template +using pV = units::isq::si::voltage; +template +using nV = units::isq::si::voltage; +template +using uV = units::isq::si::voltage; +template +using mV = units::isq::si::voltage; +template +using cV = units::isq::si::voltage; +template +using dV = units::isq::si::voltage; +template +using daV = units::isq::si::voltage; +template +using hV = units::isq::si::voltage; +template +using kV = units::isq::si::voltage; +template +using MV = units::isq::si::voltage; +template +using GV = units::isq::si::voltage; +template +using TV = units::isq::si::voltage; +template +using PV = units::isq::si::voltage; +template +using EV = units::isq::si::voltage; +template +using ZV = units::isq::si::voltage; +template +using YV = units::isq::si::voltage; } // namespace units::aliases::isq::si::inline voltage -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/test/metabench/list/type_list_concepts_all.h b/test/metabench/list/type_list_concepts_all.h index 62255427..d7523912 100644 --- a/test/metabench/list/type_list_concepts_all.h +++ b/test/metabench/list/type_list_concepts_all.h @@ -26,160 +26,159 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - template - using conditional_t = conditional::template type; +template +using conditional_t = conditional::template type; - } +} // namespace detail - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - template - struct type_list_push_front; +template +struct type_list_push_front; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front, NewTypes...> { + using type = List; +}; - template - using type_list_push_front_t = type_list_push_front::type; +template +using type_list_push_front_t = type_list_push_front::type; - // push_back +// push_back - template - struct type_list_push_back; +template +struct type_list_push_back; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back, NewTypes...> { + using type = List; +}; - template - using type_list_push_back_t = type_list_push_back::type; +template +using type_list_push_back_t = type_list_push_back::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using base_first = base::first_list; - using base_second = base::second_list; - using first_list = detail::conditional_t, base_first>; - using second_list = detail::conditional_t>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using base_first = base::first_list; + using base_second = base::second_list; + using first_list = detail::conditional_t < Idx, base_first>; + using second_list = detail::conditional_t < Idx>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - template typename Pred> - struct type_list_merge_sorted; +template typename Pred> +struct type_list_merge_sorted; - template typename Pred> - using type_list_merge_sorted_t = type_list_merge_sorted::type; +template typename Pred> +using type_list_merge_sorted_t = type_list_merge_sorted::type; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted, List, Pred> { - using type = detail::conditional_t< - Pred::value, - type_list_push_front_t, List, Pred>, Lhs1>, - type_list_push_front_t, List, Pred>, Rhs1>>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted, List, Pred> { + using type = detail::conditional_t< + Pred::value, + type_list_push_front_t, List, Pred>, Lhs1>, + type_list_push_front_t, List, Pred>, Rhs1>>; +}; - // sort +// sort - template typename Pred> - struct type_list_sort; +template typename Pred> +struct type_list_sort; - template typename List, template typename Pred> - struct type_list_sort, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort::type; - using right = type_list_sort::type; - using type = type_list_merge_sorted_t; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort::type; + using right = type_list_sort::type; + using type = type_list_merge_sorted_t; +}; - template typename Pred> - using type_list_sort_t = type_list_sort::type; +template typename Pred> +using type_list_sort_t = type_list_sort::type; } // namespace units diff --git a/test/metabench/list/type_list_concepts_iface.h b/test/metabench/list/type_list_concepts_iface.h index 33d4af86..b30478cb 100644 --- a/test/metabench/list/type_list_concepts_iface.h +++ b/test/metabench/list/type_list_concepts_iface.h @@ -26,179 +26,180 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - } +} // namespace detail - template - using conditional = detail::conditional::template type; +template +using conditional = detail::conditional::template type; - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = units::conditional::type, - typename base::first_list>; - using second_list = units::conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + units::conditional < + Idx::type, typename base::first_list>; + using second_list = + units::conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = units::conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/list/type_list_concepts_no.h b/test/metabench/list/type_list_concepts_no.h index ab74a04e..4f480405 100644 --- a/test/metabench/list/type_list_concepts_no.h +++ b/test/metabench/list/type_list_concepts_no.h @@ -26,166 +26,167 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - } +} // namespace detail - template - using conditional = detail::conditional::template type; +template +using conditional = detail::conditional::template type; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = units::conditional::type, - typename base::first_list>; - using second_list = units::conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + units::conditional < + Idx::type, typename base::first_list>; + using second_list = + units::conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = units::conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/list/type_list_conditional_alias.h b/test/metabench/list/type_list_conditional_alias.h index 33d4af86..b30478cb 100644 --- a/test/metabench/list/type_list_conditional_alias.h +++ b/test/metabench/list/type_list_conditional_alias.h @@ -26,179 +26,180 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - } +} // namespace detail - template - using conditional = detail::conditional::template type; +template +using conditional = detail::conditional::template type; - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = units::conditional::type, - typename base::first_list>; - using second_list = units::conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + units::conditional < + Idx::type, typename base::first_list>; + using second_list = + units::conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = units::conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/list/type_list_conditional_alias_hard.h b/test/metabench/list/type_list_conditional_alias_hard.h index b2b9db39..e81eb85c 100644 --- a/test/metabench/list/type_list_conditional_alias_hard.h +++ b/test/metabench/list/type_list_conditional_alias_hard.h @@ -26,172 +26,172 @@ namespace units { - template - struct conditional { - template - using type = F; - }; +template +struct conditional { + template + using type = F; +}; - template<> - struct conditional { - template - using type = T; - }; +template<> +struct conditional { + template + using type = T; +}; - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = conditional::template type< - typename type_list_push_front_impl::type, - typename base::first_list>; - using second_list = conditional::template type< - typename base::second_list, - typename type_list_push_front_impl::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + conditional < Idx::template type::type, + typename base::first_list>; + using second_list = + conditional < Idx::template type::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value>::template type< - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = units::conditional::value>::template type< + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/list/type_list_conditional_std.h b/test/metabench/list/type_list_conditional_std.h index 8626aee2..84c4fce3 100644 --- a/test/metabench/list/type_list_conditional_std.h +++ b/test/metabench/list/type_list_conditional_std.h @@ -26,160 +26,161 @@ namespace units { - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = std::conditional_t::type, - typename base::first_list>; - using second_list = std::conditional_t::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + std::conditional_t < + Idx::type, typename base::first_list>; + using second_list = + std::conditional_t < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = std::conditional_t< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = std::conditional_t< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/dimension_concepts_all.h b/test/metabench/make_dimension/dimension_concepts_all.h index 2833a82c..7d9ae1f0 100644 --- a/test/metabench/make_dimension/dimension_concepts_all.h +++ b/test/metabench/make_dimension/dimension_concepts_all.h @@ -22,193 +22,190 @@ #pragma once -#include "type_list_concepts_all.h" #include "downcasting_concepts_all.h" #include "ratio_concepts_all.h" +#include "type_list_concepts_all.h" #include namespace units { - struct base_dimension { - const char* name; - }; +struct base_dimension { + const char* name; +}; - constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 != *p2) return false; - } - return *p1 == *p2; +constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 != *p2) return false; } + return *p1 == *p2; +} - constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 < *p2) return true; - if(*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); +constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 < *p2) return true; + if (*p2 < *p1) return false; } + return (*p1 == '\0') && (*p2 != '\0'); +} - // base_dimension_less +// base_dimension_less - template - struct base_dimension_less : std::bool_constant { - }; +template + struct base_dimension_less : std::bool_constant < D1 {}; - // exponent +// exponent - template - struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr std::intmax_t num = Num; - static constexpr std::intmax_t den = Den; - }; +template +struct exponent { + static constexpr const base_dimension& dimension = BaseDimension; + static constexpr std::intmax_t num = Num; + static constexpr std::intmax_t den = Den; +}; - // is_exponent - namespace detail { - template - inline constexpr bool is_exponent = false; +// is_exponent +namespace detail { +template +inline constexpr bool is_exponent = false; - template - inline constexpr bool is_exponent> = true; - } // namespace detail +template +inline constexpr bool is_exponent> = true; +} // namespace detail - template - concept Exponent = detail::is_exponent; +template +concept Exponent = detail::is_exponent; - // exp_dim_id_less +// exp_dim_id_less - template - struct exponent_less : base_dimension_less { - }; +template +struct exponent_less : base_dimension_less {}; - // exponent_invert +// exponent_invert - template - struct exponent_invert; +template +struct exponent_invert; - template - struct exponent_invert> { - using type = exponent; - }; +template +struct exponent_invert> { + using type = exponent; +}; - template - using exponent_invert_t = exponent_invert::type; +template +using exponent_invert_t = exponent_invert::type; - // dimension +// dimension - template - struct dimension : downcast_base> {}; +template +struct dimension : downcast_base> {}; - // is_dimension - namespace detail { +// is_dimension +namespace detail { - template - inline constexpr bool is_dimension = false; +template +inline constexpr bool is_dimension = false; - template - inline constexpr bool is_dimension> = true; +template +inline constexpr bool is_dimension> = true; - } // namespace detail +} // namespace detail - template - concept Dimension = - std::is_empty_v && - detail::is_dimension>; +template +concept Dimension = std::is_empty_v && detail::is_dimension>; - // dim_invert +// dim_invert - template - struct dim_invert; +template +struct dim_invert; - template - struct dim_invert> : std::type_identity...>>> {}; +template +struct dim_invert> : std::type_identity...>>> {}; - template - using dim_invert_t = dim_invert::type; +template +using dim_invert_t = dim_invert::type; - // make_dimension +// make_dimension - namespace detail { +namespace detail { - template - struct dim_consolidate; +template +struct dim_consolidate; - template - using dim_consolidate_t = dim_consolidate::type; +template +using dim_consolidate_t = dim_consolidate::type; - template<> - struct dim_consolidate> { - using type = dimension<>; - }; +template<> +struct dim_consolidate> { + using type = dimension<>; +}; - template - struct dim_consolidate> { - using type = dimension; - }; +template +struct dim_consolidate> { + using type = dimension; +}; - template - struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; - }; +template +struct dim_consolidate> { + using rest = dim_consolidate_t>; + using type = conditional>, dimension, type_list_push_front>; +}; - template - struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; - }; +template +struct dim_consolidate, exponent, ERest...>> { + using r1 = std::ratio; + using r2 = std::ratio; + using r = std::ratio_add; + using type = conditional>, + dim_consolidate_t, ERest...>>>; +}; - } // namespace detail +} // namespace detail - template - struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; - }; +template +struct make_dimension { + using type = detail::dim_consolidate_t, exponent_less>>; +}; - template - using make_dimension_t = make_dimension::type; +template +using make_dimension_t = make_dimension::type; - template - struct merge_dimension { - using type = detail::dim_consolidate_t>; - }; +template +struct merge_dimension { + using type = detail::dim_consolidate_t>; +}; - template - using merge_dimension_t = merge_dimension::type; +template +using merge_dimension_t = merge_dimension::type; - // dimension_multiply +// dimension_multiply - template - struct dimension_multiply; +template +struct dimension_multiply; - template - struct dimension_multiply, dimension> : std::type_identity, dimension>>> {}; +template +struct dimension_multiply, dimension> : + std::type_identity, dimension>>> {}; - template - using dimension_multiply_t = dimension_multiply::type; +template +using dimension_multiply_t = dimension_multiply::type; - // dimension_divide +// dimension_divide - template - struct dimension_divide; +template +struct dimension_divide; - template - struct dimension_divide, dimension> - : dimension_multiply, dimension...>> { - }; +template +struct dimension_divide, dimension> : + dimension_multiply, dimension...>> {}; - template - using dimension_divide_t = dimension_divide::type; +template +using dimension_divide_t = dimension_divide::type; } // namespace units diff --git a/test/metabench/make_dimension/dimension_concepts_iface.h b/test/metabench/make_dimension/dimension_concepts_iface.h index 3142bd2a..44b20ce5 100644 --- a/test/metabench/make_dimension/dimension_concepts_iface.h +++ b/test/metabench/make_dimension/dimension_concepts_iface.h @@ -22,193 +22,190 @@ #pragma once -#include "type_list_concepts_iface.h" #include "downcasting_concepts_all.h" #include "ratio_concepts_iface.h" +#include "type_list_concepts_iface.h" #include namespace units { - struct base_dimension { - const char* name; - }; +struct base_dimension { + const char* name; +}; - constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 != *p2) return false; - } - return *p1 == *p2; +constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 != *p2) return false; } + return *p1 == *p2; +} - constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 < *p2) return true; - if(*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); +constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 < *p2) return true; + if (*p2 < *p1) return false; } + return (*p1 == '\0') && (*p2 != '\0'); +} - // base_dimension_less +// base_dimension_less - template - struct base_dimension_less : std::bool_constant { - }; +template + struct base_dimension_less : std::bool_constant < D1 {}; - // exponent +// exponent - template - struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr int num = Num; - static constexpr int den = Den; - }; +template +struct exponent { + static constexpr const base_dimension& dimension = BaseDimension; + static constexpr int num = Num; + static constexpr int den = Den; +}; - // is_exponent - namespace detail { - template - inline constexpr bool is_exponent = false; +// is_exponent +namespace detail { +template +inline constexpr bool is_exponent = false; - template - inline constexpr bool is_exponent> = true; - } // namespace detail +template +inline constexpr bool is_exponent> = true; +} // namespace detail - template - concept Exponent = detail::is_exponent; +template +concept Exponent = detail::is_exponent; - // exp_dim_id_less +// exp_dim_id_less - template - struct exponent_less : base_dimension_less { - }; +template +struct exponent_less : base_dimension_less {}; - // exponent_invert +// exponent_invert - template - struct exponent_invert; +template +struct exponent_invert; - template - struct exponent_invert> { - using type = exponent; - }; +template +struct exponent_invert> { + using type = exponent; +}; - template - using exponent_invert_t = exponent_invert::type; +template +using exponent_invert_t = exponent_invert::type; - // dimension +// dimension - template - struct dimension : downcast_base> {}; +template +struct dimension : downcast_base> {}; - // is_dimension - namespace detail { +// is_dimension +namespace detail { - template - inline constexpr bool is_dimension = false; +template +inline constexpr bool is_dimension = false; - template - inline constexpr bool is_dimension> = true; +template +inline constexpr bool is_dimension> = true; - } // namespace detail +} // namespace detail - template - concept Dimension = - std::is_empty_v && - detail::is_dimension>; +template +concept Dimension = std::is_empty_v && detail::is_dimension>; - // dim_invert +// dim_invert - template - struct dim_invert; +template +struct dim_invert; - template - struct dim_invert> : std::type_identity...>>> {}; +template +struct dim_invert> : std::type_identity...>>> {}; - template - using dim_invert_t = dim_invert::type; +template +using dim_invert_t = dim_invert::type; - // make_dimension +// make_dimension - namespace detail { +namespace detail { - template - struct dim_consolidate; +template +struct dim_consolidate; - template - using dim_consolidate_t = dim_consolidate::type; +template +using dim_consolidate_t = dim_consolidate::type; - template<> - struct dim_consolidate> { - using type = dimension<>; - }; +template<> +struct dim_consolidate> { + using type = dimension<>; +}; - template - struct dim_consolidate> { - using type = dimension; - }; +template +struct dim_consolidate> { + using type = dimension; +}; - template - struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; - }; +template +struct dim_consolidate> { + using rest = dim_consolidate_t>; + using type = conditional>, dimension, type_list_push_front>; +}; - template - struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; - }; +template +struct dim_consolidate, exponent, ERest...>> { + using r1 = std::ratio; + using r2 = std::ratio; + using r = std::ratio_add; + using type = conditional>, + dim_consolidate_t, ERest...>>>; +}; - } // namespace detail +} // namespace detail - template - struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; - }; +template +struct make_dimension { + using type = detail::dim_consolidate_t, exponent_less>>; +}; - template - using make_dimension_t = make_dimension::type; +template +using make_dimension_t = make_dimension::type; - template - struct merge_dimension { - using type = detail::dim_consolidate_t>; - }; +template +struct merge_dimension { + using type = detail::dim_consolidate_t>; +}; - template - using merge_dimension_t = merge_dimension::type; +template +using merge_dimension_t = merge_dimension::type; - // dimension_multiply +// dimension_multiply - template - struct dimension_multiply; +template +struct dimension_multiply; - template - struct dimension_multiply, dimension> : std::type_identity, dimension>>> {}; +template +struct dimension_multiply, dimension> : + std::type_identity, dimension>>> {}; - template - using dimension_multiply_t = dimension_multiply::type; +template +using dimension_multiply_t = dimension_multiply::type; - // dimension_divide +// dimension_divide - template - struct dimension_divide; +template +struct dimension_divide; - template - struct dimension_divide, dimension> - : dimension_multiply, dimension...>> { - }; +template +struct dimension_divide, dimension> : + dimension_multiply, dimension...>> {}; - template - using dimension_divide_t = dimension_divide::type; +template +using dimension_divide_t = dimension_divide::type; } // namespace units diff --git a/test/metabench/make_dimension/dimension_no_concepts.h b/test/metabench/make_dimension/dimension_no_concepts.h index f8b0de38..d8706535 100644 --- a/test/metabench/make_dimension/dimension_no_concepts.h +++ b/test/metabench/make_dimension/dimension_no_concepts.h @@ -22,164 +22,163 @@ #pragma once -#include "type_list_no_concepts.h" #include "downcasting_no_concepts.h" #include "ratio_no_concepts.h" +#include "type_list_no_concepts.h" #include namespace units { - struct base_dimension { - const char* name; - }; +struct base_dimension { + const char* name; +}; - constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 != *p2) return false; - } - return *p1 == *p2; +constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 != *p2) return false; } + return *p1 == *p2; +} - constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) - { - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for(; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if(*p1 < *p2) return true; - if(*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); +constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) +{ + const char* p1 = lhs.name; + const char* p2 = rhs.name; + for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { + if (*p1 < *p2) return true; + if (*p2 < *p1) return false; } + return (*p1 == '\0') && (*p2 != '\0'); +} - // base_dimension_less +// base_dimension_less - template - struct base_dimension_less : std::bool_constant { - }; +template + struct base_dimension_less : std::bool_constant < D1 {}; - // exponent +// exponent - template - struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr std::intmax_t num = Num; - static constexpr std::intmax_t den = Den; - }; +template +struct exponent { + static constexpr const base_dimension& dimension = BaseDimension; + static constexpr std::intmax_t num = Num; + static constexpr std::intmax_t den = Den; +}; - // exp_dim_id_less +// exp_dim_id_less - template - struct exponent_less : base_dimension_less { - }; +template +struct exponent_less : base_dimension_less {}; - // exponent_invert +// exponent_invert - template - struct exponent_invert; +template +struct exponent_invert; - template - struct exponent_invert> { - using type = exponent; - }; +template +struct exponent_invert> { + using type = exponent; +}; - template - using exponent_invert_t = exponent_invert::type; +template +using exponent_invert_t = exponent_invert::type; - // dimension +// dimension - template - struct dimension : downcast_base> {}; +template +struct dimension : downcast_base> {}; - // dim_invert +// dim_invert - template - struct dim_invert; +template +struct dim_invert; - template - struct dim_invert> : std::type_identity...>>> {}; +template +struct dim_invert> : std::type_identity...>>> {}; - template - using dim_invert_t = dim_invert::type; +template +using dim_invert_t = dim_invert::type; - // make_dimension +// make_dimension - namespace detail { +namespace detail { - template - struct dim_consolidate; +template +struct dim_consolidate; - template - using dim_consolidate_t = dim_consolidate::type; +template +using dim_consolidate_t = dim_consolidate::type; - template<> - struct dim_consolidate> { - using type = dimension<>; - }; +template<> +struct dim_consolidate> { + using type = dimension<>; +}; - template - struct dim_consolidate> { - using type = dimension; - }; +template +struct dim_consolidate> { + using type = dimension; +}; - template - struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; - }; +template +struct dim_consolidate> { + using rest = dim_consolidate_t>; + using type = conditional>, dimension, type_list_push_front>; +}; - template - struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; - }; +template +struct dim_consolidate, exponent, ERest...>> { + using r1 = std::ratio; + using r2 = std::ratio; + using r = std::ratio_add; + using type = conditional>, + dim_consolidate_t, ERest...>>>; +}; - } // namespace detail +} // namespace detail - template - struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; - }; +template +struct make_dimension { + using type = detail::dim_consolidate_t, exponent_less>>; +}; - template - using make_dimension_t = make_dimension::type; +template +using make_dimension_t = make_dimension::type; - template - struct merge_dimension { - using type = detail::dim_consolidate_t>; - }; +template +struct merge_dimension { + using type = detail::dim_consolidate_t>; +}; - template - using merge_dimension_t = merge_dimension::type; +template +using merge_dimension_t = merge_dimension::type; - // dimension_multiply +// dimension_multiply - template - struct dimension_multiply; +template +struct dimension_multiply; - template - struct dimension_multiply, dimension> : std::type_identity, dimension>>> {}; +template +struct dimension_multiply, dimension> : + std::type_identity, dimension>>> {}; - template - using dimension_multiply_t = dimension_multiply::type; +template +using dimension_multiply_t = dimension_multiply::type; - // dimension_divide +// dimension_divide - template - struct dimension_divide; +template +struct dimension_divide; - template - struct dimension_divide, dimension> - : dimension_multiply, dimension...>> { - }; +template +struct dimension_divide, dimension> : + dimension_multiply, dimension...>> {}; - template - using dimension_divide_t = dimension_divide::type; +template +using dimension_divide_t = dimension_divide::type; } // namespace units diff --git a/test/metabench/make_dimension/downcasting_concepts_all.h b/test/metabench/make_dimension/downcasting_concepts_all.h index 68bd5230..c08161c9 100644 --- a/test/metabench/make_dimension/downcasting_concepts_all.h +++ b/test/metabench/make_dimension/downcasting_concepts_all.h @@ -27,25 +27,22 @@ namespace units { - template - struct downcast_base { - using downcast_base_type = BaseType; - }; +template +struct downcast_base { + using downcast_base_type = BaseType; +}; - template - concept Downcastable = - requires { - typename T::downcast_base_type; - } && - std::derived_from>; +template +concept Downcastable = + requires { typename T::downcast_base_type; } && std::derived_from>; - template - using downcast_base_t = T::downcast_base_type; +template +using downcast_base_t = T::downcast_base_type; - template - struct downcast_traits : std::type_identity {}; +template +struct downcast_traits : std::type_identity {}; - template - using downcast_traits_t = downcast_traits::type; +template +using downcast_traits_t = downcast_traits::type; } // namespace units diff --git a/test/metabench/make_dimension/downcasting_no_concepts.h b/test/metabench/make_dimension/downcasting_no_concepts.h index 051b0ff5..8b7bec8f 100644 --- a/test/metabench/make_dimension/downcasting_no_concepts.h +++ b/test/metabench/make_dimension/downcasting_no_concepts.h @@ -27,18 +27,18 @@ namespace units { - template - struct downcast_base { - using downcast_base_type = BaseType; - }; +template +struct downcast_base { + using downcast_base_type = BaseType; +}; - template - using downcast_base_t = T::downcast_base_type; +template +using downcast_base_t = T::downcast_base_type; - template - struct downcast_traits : std::type_identity {}; +template +struct downcast_traits : std::type_identity {}; - template - using downcast_traits_t = downcast_traits::type; +template +using downcast_traits_t = downcast_traits::type; } // namespace units diff --git a/test/metabench/make_dimension/hacks.h b/test/metabench/make_dimension/hacks.h index 88b24a11..b95278a9 100644 --- a/test/metabench/make_dimension/hacks.h +++ b/test/metabench/make_dimension/hacks.h @@ -26,11 +26,11 @@ namespace std { - // concepts - using concepts::same_as; - using concepts::derived_from; - using concepts::regular; - using concepts::totally_ordered; - using concepts::convertible_to; +// concepts +using concepts::convertible_to; +using concepts::derived_from; +using concepts::regular; +using concepts::same_as; +using concepts::totally_ordered; -} +} // namespace std diff --git a/test/metabench/make_dimension/ratio_concepts_all.h b/test/metabench/make_dimension/ratio_concepts_all.h index e9aaf95e..344a8511 100644 --- a/test/metabench/make_dimension/ratio_concepts_all.h +++ b/test/metabench/make_dimension/ratio_concepts_all.h @@ -23,115 +23,118 @@ #pragma once #include "hacks.h" -#include -#include #include +#include +#include namespace units { - namespace detail { +namespace detail { - template - [[nodiscard]] constexpr T abs(T v) noexcept { return v < 0 ? -v : v; } +template +[[nodiscard]] constexpr T abs(T v) noexcept +{ + return v < 0 ? -v : v; +} - } +} // namespace detail - template - struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); +template +struct ratio { + static_assert(Den != 0, "zero denominator"); + static_assert(-INTMAX_MAX <= Num, "numerator too negative"); + static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); + static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); + static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - using type = ratio; - }; + using type = ratio; +}; - // is_ratio +// is_ratio - namespace detail { +namespace detail { - template - inline constexpr bool is_ratio = false; +template +inline constexpr bool is_ratio = false; - template - inline constexpr bool is_ratio> = true; +template +inline constexpr bool is_ratio> = true; - } // namespace detail +} // namespace detail - template - concept Ratio = detail::is_ratio; +template +concept Ratio = detail::is_ratio; - // ratio_multiply +// ratio_multiply - namespace detail { +namespace detail { - static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) - { - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); +static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) +{ + constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; + const std::uintmax_t a0 = detail::abs(lhs) % c; + const std::uintmax_t a1 = detail::abs(lhs) / c; + const std::uintmax_t b0 = detail::abs(rhs) % c; + const std::uintmax_t b1 = detail::abs(rhs) / c; - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication + Expects(a1 == 0 || b1 == 0); // overflow in multiplication + Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication + Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication + Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - return lhs * rhs; - } + return lhs * rhs; +} - template - struct ratio_multiply_impl { - private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); +template +struct ratio_multiply_impl { +private: + static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); + static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +public: + using type = ratio; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_multiply = detail::ratio_multiply_impl::type; +template +using ratio_multiply = detail::ratio_multiply_impl::type; - // ratio_divide +// ratio_divide - namespace detail { +namespace detail { - template - struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +template +struct ratio_divide_impl { + static_assert(R2::num != 0, "division by 0"); + using type = ratio_multiply>; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_divide = detail::ratio_divide_impl::type; +template +using ratio_divide = detail::ratio_divide_impl::type; - // common_ratio +// common_ratio - namespace detail { +namespace detail { - template - struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; - }; +template +struct common_ratio_impl { + static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); + static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); + using type = ratio; +}; - } +} // namespace detail - template - using common_ratio = detail::common_ratio_impl::type; +template +using common_ratio = detail::common_ratio_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/ratio_concepts_iface.h b/test/metabench/make_dimension/ratio_concepts_iface.h index e6e5d169..fe59c2ca 100644 --- a/test/metabench/make_dimension/ratio_concepts_iface.h +++ b/test/metabench/make_dimension/ratio_concepts_iface.h @@ -23,115 +23,118 @@ #pragma once #include "hacks.h" -#include -#include #include +#include +#include namespace units { - namespace detail { +namespace detail { - template - [[nodiscard]] constexpr T abs(T v) noexcept { return v < 0 ? -v : v; } +template +[[nodiscard]] constexpr T abs(T v) noexcept +{ + return v < 0 ? -v : v; +} - } +} // namespace detail - template - struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); +template +struct ratio { + static_assert(Den != 0, "zero denominator"); + static_assert(-INTMAX_MAX <= Num, "numerator too negative"); + static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); + static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); + static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - using type = ratio; - }; + using type = ratio; +}; - // is_ratio +// is_ratio - namespace detail { +namespace detail { - template - inline constexpr bool is_ratio = false; +template +inline constexpr bool is_ratio = false; - template - inline constexpr bool is_ratio> = true; +template +inline constexpr bool is_ratio> = true; - } // namespace detail +} // namespace detail - template - concept Ratio = detail::is_ratio; +template +concept Ratio = detail::is_ratio; - // ratio_multiply +// ratio_multiply - namespace detail { +namespace detail { - static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) - { - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); +static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) +{ + constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; + const std::uintmax_t a0 = detail::abs(lhs) % c; + const std::uintmax_t a1 = detail::abs(lhs) / c; + const std::uintmax_t b0 = detail::abs(rhs) % c; + const std::uintmax_t b1 = detail::abs(rhs) / c; - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication + Expects(a1 == 0 || b1 == 0); // overflow in multiplication + Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication + Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication + Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - return lhs * rhs; - } + return lhs * rhs; +} - template - struct ratio_multiply_impl { - private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); +template +struct ratio_multiply_impl { +private: + static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); + static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +public: + using type = ratio; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_multiply = detail::ratio_multiply_impl::type; +template +using ratio_multiply = detail::ratio_multiply_impl::type; - // ratio_divide +// ratio_divide - namespace detail { +namespace detail { - template - struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +template +struct ratio_divide_impl { + static_assert(R2::num != 0, "division by 0"); + using type = ratio_multiply>; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_divide = detail::ratio_divide_impl::type; +template +using ratio_divide = detail::ratio_divide_impl::type; - // common_ratio +// common_ratio - namespace detail { +namespace detail { - template - struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; - }; +template +struct common_ratio_impl { + static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); + static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); + using type = ratio; +}; - } +} // namespace detail - template - using common_ratio = detail::common_ratio_impl::type; +template +using common_ratio = detail::common_ratio_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/ratio_no_concepts.h b/test/metabench/make_dimension/ratio_no_concepts.h index db11488e..fa1b7ba9 100644 --- a/test/metabench/make_dimension/ratio_no_concepts.h +++ b/test/metabench/make_dimension/ratio_no_concepts.h @@ -23,100 +23,103 @@ #pragma once #include "hacks.h" -#include -#include #include +#include +#include namespace units { - namespace detail { +namespace detail { - template - [[nodiscard]] constexpr T abs(T v) noexcept { return v < 0 ? -v : v; } +template +[[nodiscard]] constexpr T abs(T v) noexcept +{ + return v < 0 ? -v : v; +} - } +} // namespace detail - template - struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); +template +struct ratio { + static_assert(Den != 0, "zero denominator"); + static_assert(-INTMAX_MAX <= Num, "numerator too negative"); + static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); + static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); + static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - using type = ratio; - }; + using type = ratio; +}; - // ratio_multiply +// ratio_multiply - namespace detail { +namespace detail { - static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) - { - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); +static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) +{ + constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; + const std::uintmax_t a0 = detail::abs(lhs) % c; + const std::uintmax_t a1 = detail::abs(lhs) / c; + const std::uintmax_t b0 = detail::abs(rhs) % c; + const std::uintmax_t b1 = detail::abs(rhs) / c; - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication + Expects(a1 == 0 || b1 == 0); // overflow in multiplication + Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication + Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication + Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - return lhs * rhs; - } + return lhs * rhs; +} - template - struct ratio_multiply_impl { - private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); +template +struct ratio_multiply_impl { +private: + static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); + static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +public: + using type = ratio; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_multiply = detail::ratio_multiply_impl::type; +template +using ratio_multiply = detail::ratio_multiply_impl::type; - // ratio_divide +// ratio_divide - namespace detail { +namespace detail { - template - struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +template +struct ratio_divide_impl { + static_assert(R2::num != 0, "division by 0"); + using type = ratio_multiply>; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_divide = detail::ratio_divide_impl::type; +template +using ratio_divide = detail::ratio_divide_impl::type; - // common_ratio +// common_ratio - namespace detail { +namespace detail { - template - struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; - }; +template +struct common_ratio_impl { + static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); + static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); + using type = ratio; +}; - } +} // namespace detail - template - using common_ratio = detail::common_ratio_impl::type; +template +using common_ratio = detail::common_ratio_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/type_list_concepts_all.h b/test/metabench/make_dimension/type_list_concepts_all.h index 2195496c..80392b3e 100644 --- a/test/metabench/make_dimension/type_list_concepts_all.h +++ b/test/metabench/make_dimension/type_list_concepts_all.h @@ -26,160 +26,161 @@ namespace units { - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = conditional::type, - typename base::first_list>; - using second_list = conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + conditional < + Idx::type, typename base::first_list>; + using second_list = + conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/type_list_concepts_iface.h b/test/metabench/make_dimension/type_list_concepts_iface.h index 711b8556..0737c88b 100644 --- a/test/metabench/make_dimension/type_list_concepts_iface.h +++ b/test/metabench/make_dimension/type_list_concepts_iface.h @@ -26,160 +26,161 @@ namespace units { - namespace detail { +namespace detail { - template - inline constexpr bool is_type_list = false; +template +inline constexpr bool is_type_list = false; - template typename T, typename... Types> - inline constexpr bool is_type_list> = true; +template typename T, typename... Types> +inline constexpr bool is_type_list> = true; - } // namespace detail +} // namespace detail - template - concept TypeList = detail::is_type_list; +template +concept TypeList = detail::is_type_list; - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = conditional::type, - typename base::first_list>; - using second_list = conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + conditional < + Idx::type, typename base::first_list>; + using second_list = + conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/type_list_no_concepts.h b/test/metabench/make_dimension/type_list_no_concepts.h index c17fda5d..82e40f40 100644 --- a/test/metabench/make_dimension/type_list_no_concepts.h +++ b/test/metabench/make_dimension/type_list_no_concepts.h @@ -26,147 +26,148 @@ namespace units { - // push_front +// push_front - namespace detail { +namespace detail { - template - struct type_list_push_front_impl; +template +struct type_list_push_front_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_front_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_front_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_front = detail::type_list_push_front_impl::type; +template +using type_list_push_front = detail::type_list_push_front_impl::type; - // push_back +// push_back - namespace detail { +namespace detail { - template - struct type_list_push_back_impl; +template +struct type_list_push_back_impl; - template typename List, typename... OldTypes, typename... NewTypes> - struct type_list_push_back_impl, NewTypes...> { - using type = List; - }; +template typename List, typename... OldTypes, typename... NewTypes> +struct type_list_push_back_impl, NewTypes...> { + using type = List; +}; - } +} // namespace detail - template - using type_list_push_back = detail::type_list_push_back_impl::type; +template +using type_list_push_back = detail::type_list_push_back_impl::type; - // split +// split - namespace detail { +namespace detail { - template typename List, std::size_t Idx, std::size_t N, typename... Types> - struct split_impl; +template typename List, std::size_t Idx, std::size_t N, typename... Types> +struct split_impl; - template typename List, std::size_t Idx, std::size_t N> - struct split_impl { - using first_list = List<>; - using second_list = List<>; - }; +template typename List, std::size_t Idx, std::size_t N> +struct split_impl { + using first_list = List<>; + using second_list = List<>; +}; - template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - struct split_impl : split_impl { - using base = split_impl; - using first_list = conditional::type, - typename base::first_list>; - using second_list = conditional::type>; - }; +template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> +struct split_impl : split_impl { + using base = split_impl; + using first_list = + conditional < + Idx::type, typename base::first_list>; + using second_list = + conditional < + Idx::type>; +}; - } // namespace detail +} // namespace detail - template - struct type_list_split; +template +struct type_list_split; - template typename List, std::size_t N, typename... Types> - struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; - }; +template typename List, std::size_t N, typename... Types> +struct type_list_split, N> { + static_assert(N <= sizeof...(Types), "Invalid index provided"); + using split = detail::split_impl; + using first_list = split::first_list; + using second_list = split::second_list; +}; - // split_half +// split_half - template - struct type_list_split_half; +template +struct type_list_split_half; - template typename List, typename... Types> - struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { - }; +template typename List, typename... Types> +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted +// merge_sorted - namespace detail { +namespace detail { - template typename Pred> - struct type_list_merge_sorted_impl; +template typename Pred> +struct type_list_merge_sorted_impl; - template typename List, typename... Lhs, template typename Pred> - struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; - }; +template typename List, typename... Lhs, template typename Pred> +struct type_list_merge_sorted_impl, List<>, Pred> { + using type = List; +}; - template typename List, typename... Rhs, template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = List; - }; +template typename List, typename... Rhs, template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = List; +}; - template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> - struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl, List, Pred>::type, Rhs1>::type>; - }; +template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, + template typename Pred> +struct type_list_merge_sorted_impl, List, Pred> { + using type = conditional< + Pred::value, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, + typename type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; +}; - } +} // namespace detail - template typename Pred> - using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; +template typename Pred> +using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - // sort +// sort - namespace detail { +namespace detail { - template typename Pred> - struct type_list_sort_impl; +template typename Pred> +struct type_list_sort_impl; - template typename List, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List<>; - }; +template typename List, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List<>; +}; - template typename List, typename T, template typename Pred> - struct type_list_sort_impl, Pred> { - using type = List; - }; +template typename List, typename T, template typename Pred> +struct type_list_sort_impl, Pred> { + using type = List; +}; - template typename List, typename... Types, template typename Pred> - struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; - }; +template typename List, typename... Types, template typename Pred> +struct type_list_sort_impl, Pred> { + using types = List; + using split = type_list_split_half>; + using left = type_list_sort_impl::type; + using right = type_list_sort_impl::type; + using type = type_list_merge_sorted_impl::type; +}; - } +} // namespace detail - template typename Pred> - using type_list_sort = detail::type_list_sort_impl::type; +template typename Pred> +using type_list_sort = detail::type_list_sort_impl::type; } // namespace units diff --git a/test/metabench/make_dimension/type_traits.h b/test/metabench/make_dimension/type_traits.h index 842410f3..35d7e162 100644 --- a/test/metabench/make_dimension/type_traits.h +++ b/test/metabench/make_dimension/type_traits.h @@ -26,23 +26,23 @@ namespace units { - namespace detail { +namespace detail { - template - struct conditional_impl { - template - using type = F; - }; +template +struct conditional_impl { + template + using type = F; +}; - template<> - struct conditional_impl { - template - using type = T; - }; +template<> +struct conditional_impl { + template + using type = T; +}; - } +} // namespace detail - template - using conditional = TYPENAME detail::conditional_impl::template type; +template +using conditional = TYPENAME detail::conditional_impl::template type; -} +} // namespace units diff --git a/test/metabench/ratio/ratio_type_constexpr.h b/test/metabench/ratio/ratio_type_constexpr.h index 26dc31b3..86e2c0d6 100644 --- a/test/metabench/ratio/ratio_type_constexpr.h +++ b/test/metabench/ratio/ratio_type_constexpr.h @@ -22,103 +22,107 @@ #pragma once -#include -#include -#include #include +#include +#include +#include -#define Expects(cond) if(!(cond)) ::std::terminate(); +#define Expects(cond) \ + if (!(cond)) ::std::terminate(); namespace units { - namespace detail { +namespace detail { - template - [[nodiscard]] constexpr T abs(T v) noexcept { return v < 0 ? -v : v; } +template +[[nodiscard]] constexpr T abs(T v) noexcept +{ + return v < 0 ? -v : v; +} - } +} // namespace detail - template - struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); +template +struct ratio { + static_assert(Den != 0, "zero denominator"); + static_assert(-INTMAX_MAX <= Num, "numerator too negative"); + static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); + static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); + static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - using type = ratio; - }; + using type = ratio; +}; - // ratio_multiply +// ratio_multiply - namespace detail { +namespace detail { - static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) - { - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); +static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) +{ + constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; + const std::uintmax_t a0 = detail::abs(lhs) % c; + const std::uintmax_t a1 = detail::abs(lhs) / c; + const std::uintmax_t b0 = detail::abs(rhs) % c; + const std::uintmax_t b1 = detail::abs(rhs) / c; - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication + Expects(a1 == 0 || b1 == 0); // overflow in multiplication + Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication + Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication + Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - return lhs * rhs; - } + return lhs * rhs; +} - template - struct ratio_multiply { - private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); +template +struct ratio_multiply { +private: + static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); + static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +public: + using type = ratio; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_multiply = typename detail::ratio_multiply::type; +template +using ratio_multiply = typename detail::ratio_multiply::type; - // ratio_divide +// ratio_divide - namespace detail { +namespace detail { - template - struct ratio_divide { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; - }; +template +struct ratio_divide { + static_assert(R2::num != 0, "division by 0"); + using type = ratio_multiply>; + static constexpr std::intmax_t num = type::num; + static constexpr std::intmax_t den = type::den; +}; - } +} // namespace detail - template - using ratio_divide = typename detail::ratio_divide::type; +template +using ratio_divide = typename detail::ratio_divide::type; - // common_ratio +// common_ratio - namespace detail { +namespace detail { - template - struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; - }; +template +struct common_ratio_impl { + static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); + static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); + using type = ratio; +}; - } +} // namespace detail - template - using common_ratio_t = typename detail::common_ratio_impl::type; +template +using common_ratio_t = typename detail::common_ratio_impl::type; } // namespace units diff --git a/test/metabench/ratio/std_ratio.h b/test/metabench/ratio/std_ratio.h index 6c1a13f2..459b5acd 100644 --- a/test/metabench/ratio/std_ratio.h +++ b/test/metabench/ratio/std_ratio.h @@ -27,42 +27,37 @@ namespace units { - // static_sign +// static_sign - template - struct static_sign : std::integral_constant { - }; +template +struct static_sign : std::integral_constant {}; - // static_abs +// static_abs - template - struct static_abs : std::integral_constant::value> { - }; +template +struct static_abs : std::integral_constant::value> {}; - // static_gcd +// static_gcd - template - struct static_gcd : static_gcd { - }; +template +struct static_gcd : static_gcd {}; - template - struct static_gcd : std::integral_constant::value> { - }; +template +struct static_gcd : std::integral_constant::value> {}; - template - struct static_gcd<0, Qn> : std::integral_constant::value> { - }; +template +struct static_gcd<0, Qn> : std::integral_constant::value> {}; - // common_ratio +// common_ratio - template - struct common_ratio { - using gcd_num = static_gcd; - using gcd_den = static_gcd; - using type = std::ratio; - }; +template +struct common_ratio { + using gcd_num = static_gcd; + using gcd_den = static_gcd; + using type = std::ratio; +}; - template - using common_ratio_t = typename common_ratio::type; +template +using common_ratio_t = typename common_ratio::type; } // namespace units diff --git a/test/unit_test/static/dimensions_concepts_test.cpp b/test/unit_test/static/dimensions_concepts_test.cpp index fbde0bfe..2b237250 100644 --- a/test/unit_test/static/dimensions_concepts_test.cpp +++ b/test/unit_test/static/dimensions_concepts_test.cpp @@ -67,19 +67,22 @@ static_assert(!Speed>); static_assert(Acceleration>); static_assert(!Acceleration>); #if UNITS_DOWNCAST_MODE == 0 -static_assert(Acceleration, exponent>, unknown_coherent_unit>>); +static_assert(Acceleration, exponent>, + unknown_coherent_unit>>); #endif static_assert(Force>); static_assert(!Force>); #if UNITS_DOWNCAST_MODE == 0 -// static_assert(Force, exponent, exponent>, unknown_coherent_unit>>); +// static_assert(Force, exponent, +// exponent>, unknown_coherent_unit>>); #endif static_assert(Energy>); static_assert(!Energy>); #if UNITS_DOWNCAST_MODE == 0 -// static_assert(Energy, exponent, exponent>, unknown_coherent_unit>>); +// static_assert(Energy, exponent, +// exponent>, unknown_coherent_unit>>); #endif static_assert(Power>); @@ -168,4 +171,4 @@ static_assert(!Permeability>); static_assert(MolarEnergy>); static_assert(!MolarEnergy>); -} +} // namespace diff --git a/test/unit_test/static/fixed_string_test.cpp b/test/unit_test/static/fixed_string_test.cpp index 8fadd9d7..7c4ffeb2 100644 --- a/test/unit_test/static/fixed_string_test.cpp +++ b/test/unit_test/static/fixed_string_test.cpp @@ -50,4 +50,4 @@ static_assert(basic_fixed_string('d') + txt2 == basic_fixed_string("dabc")); static_assert(txt2 + basic_fixed_string("def") == basic_fixed_string("abcdef")); static_assert(basic_fixed_string("def") + txt2 == basic_fixed_string("defabc")); -} +} // namespace diff --git a/test/unit_test/static/fps_test.cpp b/test/unit_test/static/fps_test.cpp index 74ddd60e..8f241525 100644 --- a/test/unit_test/static/fps_test.cpp +++ b/test/unit_test/static/fps_test.cpp @@ -100,6 +100,7 @@ static_assert(1_q_ft_pdl_per_s * 10_q_s == 10_q_ft_pdl); static_assert(10_q_ft_pdl / 1_q_ft_pdl_per_s == 10_q_s); static_assert(detail::unit_text() == basic_symbol_text("ft ⋅ pdl/s", "ft pdl/s")); -static_assert(detail::unit_text() == basic_symbol_text("ft ⋅ lbf/s", "ft lbf/s")); +static_assert(detail::unit_text() == + basic_symbol_text("ft ⋅ lbf/s", "ft lbf/s")); -} +} // namespace diff --git a/test/unit_test/static/quantity_kind_test.cpp b/test/unit_test/static/quantity_kind_test.cpp index d9dc2961..adbfeb8d 100644 --- a/test/unit_test/static/quantity_kind_test.cpp +++ b/test/unit_test/static/quantity_kind_test.cpp @@ -114,7 +114,7 @@ concept invalid_types = requires { requires !requires { typename quantity_kind; }; // unit of a different dimension requires !requires { typename quantity_kind>; }; // quantity used as Rep - requires !requires { // quantity point used as Rep + requires !requires { // quantity point used as Rep typename quantity_kind, metre>>; }; requires !requires { typename quantity_kind>; }; // quantity kind used as Rep diff --git a/test/unit_test/static/quantity_point_test.cpp b/test/unit_test/static/quantity_point_test.cpp index 19b6e32f..8eb42c4c 100644 --- a/test/unit_test/static/quantity_point_test.cpp +++ b/test/unit_test/static/quantity_point_test.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include #include "test_tools.h" #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -46,20 +46,22 @@ struct sea_level_origin : point_origin {}; // class invariants template -concept invalid_types = requires -{ - // unit of a different dimension: - requires !requires { typename quantity_point, second, int>; }; - // quantity used as Rep: - requires !requires { typename quantity_point, metre, quantity>; }; - // quantity point used as Rep: - requires !requires { typename quantity_point, metre, - quantity_point, metre, int>>; }; - // reordered arguments: - requires !requires { typename quantity_point, double>; }; - // dimension used as origin: - requires !requires { typename quantity_point; }; -}; +concept invalid_types = + requires { + // unit of a different dimension: + requires !requires { typename quantity_point, second, int>; }; + // quantity used as Rep: + requires !requires { typename quantity_point, metre, quantity>; }; + // quantity point used as Rep: + requires !requires { + typename quantity_point, metre, + quantity_point, metre, int>>; + }; + // reordered arguments: + requires !requires { typename quantity_point, double>; }; + // dimension used as origin: + requires !requires { typename quantity_point; }; + }; static_assert(invalid_types); @@ -71,7 +73,8 @@ static_assert(is_same_v, metre, int>:: static_assert(is_same_v, kilometre, int>::unit, kilometre>); static_assert(is_same_v, metre, int>::dimension, dim_length>); static_assert(is_same_v, metre, int>::origin, dynamic_origin>); -static_assert(is_same_v, metre, int>::quantity_type, quantity>); +static_assert( + is_same_v, metre, int>::quantity_type, quantity>); // constructors @@ -80,10 +83,14 @@ static_assert(!std::is_convertible_v static_assert(quantity_point(42s).relative() == 42 * s); static_assert(quantity_point(sys_seconds{42s}).relative() == 42 * s); -static_assert(!std::is_convertible_v, second, std::chrono::seconds::rep>>); -static_assert(!std::is_convertible_v, second, std::chrono::seconds::rep>>); +static_assert(!std::is_convertible_v, second, std::chrono::seconds::rep>>); +static_assert( + !std::is_convertible_v, second, std::chrono::seconds::rep>>); static_assert(!std::is_convertible_v, second, sys_seconds::rep>>); -static_assert(!std::is_convertible_v, second, sys_seconds::rep>>); +static_assert(!std::is_convertible_v< + sys_seconds, quantity_point, second, sys_seconds::rep>>); static_assert(quantity_point, metre, int>().relative() == 0_q_m); constexpr quantity_point, metre, int> km{1000_q_m}; @@ -91,21 +98,25 @@ static_assert(km.relative() == 1000_q_m); static_assert(quantity_point, metre, int>(km).relative() == km.relative()); static_assert(quantity_point, metre, int>(1_q_m).relative() == 1_q_m); -static_assert(!std::is_constructible_v, metre, int>, double>); // truncating conversion +static_assert( + !std::is_constructible_v, metre, int>, double>); // truncating conversion static_assert(quantity_point, metre, double>(1.0_q_m).relative() == 1.0_q_m); static_assert(quantity_point, metre, double>(1_q_m).relative() == 1_q_m); static_assert(quantity_point, metre, long double>(3.14_q_m).relative() == 3.14_q_m); static_assert(quantity_point, metre, int>(km).relative() == 1000_q_m); -static_assert(!std::is_constructible_v, metre, int>, - quantity_point, metre, double>>); // truncating conversion -static_assert(quantity_point, metre, double>(quantity_point(1000.0_q_m)).relative() == 1000.0_q_m); +static_assert( + !std::is_constructible_v, metre, int>, + quantity_point, metre, double>>); // truncating conversion +static_assert(quantity_point, metre, double>(quantity_point(1000.0_q_m)).relative() == + 1000.0_q_m); static_assert(quantity_point, metre, double>(km).relative() == 1000.0_q_m); static_assert(quantity_point, metre, int>(quantity_point(1_q_km)).relative() == 1000_q_m); static_assert(!std::is_constructible_v, metre, int>, quantity_point, second, int>>); // different dimensions -static_assert(!std::is_constructible_v, kilometre, int>, - quantity_point, metre, int>>); // truncating conversion +static_assert( + !std::is_constructible_v, kilometre, int>, + quantity_point, metre, int>>); // truncating conversion static_assert(!std::is_constructible_v, quantity_point, metre, int>>, @@ -115,12 +126,18 @@ static_assert(!std::is_constructible_v, // assignment operator -static_assert([]() { quantity_point, metre, int> l1(1_q_m), l2{}; return l2 = l1; }().relative() == 1_q_m); +static_assert(([]() { + quantity_point, metre, int> l1(1_q_m), l2{}; + return l2 = l1; + }()) + .relative() == 1_q_m); // static member functions -static_assert(quantity_point, metre, int>::min().relative().number() == std::numeric_limits::lowest()); -static_assert(quantity_point, metre, int>::max().relative().number() == std::numeric_limits::max()); +static_assert(quantity_point, metre, int>::min().relative().number() == + std::numeric_limits::lowest()); +static_assert(quantity_point, metre, int>::max().relative().number() == + std::numeric_limits::max()); static_assert(quantity_point, metre, double>::min().relative().number() == std::numeric_limits::lowest()); static_assert(quantity_point, metre, double>::max().relative().number() == @@ -131,19 +148,23 @@ static_assert(quantity_point, metre, double>::max().r static_assert([](auto v) { auto vv = v++; return std::pair(v, vv); -}(km) == std::pair(quantity_point, metre, int>(1001_q_m), quantity_point, metre, int>(1000_q_m))); +}(km) == std::pair(quantity_point, metre, int>(1001_q_m), + quantity_point, metre, int>(1000_q_m))); static_assert([](auto v) { auto vv = ++v; return std::pair(v, vv); -}(km) == std::pair(quantity_point, metre, int>(1001_q_m), quantity_point, metre, int>(1001_q_m))); +}(km) == std::pair(quantity_point, metre, int>(1001_q_m), + quantity_point, metre, int>(1001_q_m))); static_assert([](auto v) { auto vv = v--; return std::pair(v, vv); -}(km) == std::pair(quantity_point, metre, int>(999_q_m), quantity_point, metre, int>(1000_q_m))); +}(km) == std::pair(quantity_point, metre, int>(999_q_m), + quantity_point, metre, int>(1000_q_m))); static_assert([](auto v) { auto vv = --v; return std::pair(v, vv); -}(km) == std::pair(quantity_point, metre, int>(999_q_m), quantity_point, metre, int>(999_q_m))); +}(km) == std::pair(quantity_point, metre, int>(999_q_m), + quantity_point, metre, int>(999_q_m))); // compound assignment @@ -153,23 +174,23 @@ static_assert((quantity_point(2_q_m) -= 1_q_m).relative().number() == 1); // non-member arithmetic operators static_assert(compare, metre, int>() + length()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare() + quantity_point, metre, double>()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare, kilometre, int>() + length()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare() + quantity_point, metre, double>()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare, metre, double>() - length()), - quantity_point, metre, double>>); + quantity_point, metre, double>>); static_assert(compare, kilometre, double>() - length()), - quantity_point, metre, double>>); -static_assert( - compare, metre, double>() - quantity_point, metre, int>()), - length>); -static_assert( - compare, kilometre, double>() - quantity_point, metre, int>()), - length>); + quantity_point, metre, double>>); +static_assert(compare, metre, double>() - + quantity_point, metre, int>()), + length>); +static_assert(compare, kilometre, double>() - + quantity_point, metre, int>()), + length>); static_assert((1_q_m + km).relative().number() == 1001); static_assert((quantity_point(1_q_m) + 1_q_km).relative().number() == 1001); @@ -177,10 +198,9 @@ static_assert((km - 1_q_m).relative().number() == 999); static_assert((quantity_point(1_q_km) - quantity_point(1_q_m)).number() == 999); template -concept invalid_subtraction = requires(quantity_point, metre, Int> lhs, - quantity_point rhs) { - requires !requires { rhs - lhs; }; -}; +concept invalid_subtraction = + requires(quantity_point, metre, Int> lhs, + quantity_point rhs) { requires !requires { rhs - lhs; }; }; static_assert(invalid_subtraction); // comparators @@ -217,9 +237,9 @@ static_assert(quantity_point(1000_q_m) <= quantity_point(1_q_km)); template concept invalid_comparisons = requires(quantity_point, metre, Int> lhs, quantity_point rhs) { - requires !requires { lhs == rhs; }; - requires !requires { lhs < rhs; }; -}; + requires !requires { lhs == rhs; }; + requires !requires { lhs < rhs; }; + }; static_assert(invalid_comparisons); // alias units @@ -256,25 +276,35 @@ static_assert(std::equality_comparable_with, metre, int>>(quantity_point(2_q_km)).relative().number() == - 2000); -static_assert( - quantity_point_cast, kilometre, int>>(quantity_point(2000_q_m)).relative().number() == 2); -static_assert(quantity_point_cast, metre, int>>(quantity_point(1.23_q_m)).relative().number() == - 1); +static_assert(quantity_point_cast, metre, int>>(quantity_point(2_q_km)) + .relative() + .number() == 2000); +static_assert(quantity_point_cast, kilometre, int>>(quantity_point(2000_q_m)) + .relative() + .number() == 2); +static_assert(quantity_point_cast, metre, int>>(quantity_point(1.23_q_m)) + .relative() + .number() == 1); static_assert(quantity_point_cast>(quantity_point(2_q_km)).relative().number() == 2000); static_assert(quantity_point_cast>(quantity_point(2000_q_m)).relative().number() == 2); static_assert(quantity_point_cast>(quantity_point(1.23_q_m)).relative().number() == 1); static_assert(quantity_point_cast(quantity_point(2_q_km)).relative().number() == 2000); static_assert(quantity_point_cast(quantity_point(2000_q_m)).relative().number() == 2); static_assert(quantity_point_cast(quantity_point(1.23_q_m)).relative().number() == 1); -static_assert(quantity_point_cast(quantity_point(2000.0_q_m / 3600.0_q_s)).relative().number() == 2); +static_assert( + quantity_point_cast(quantity_point(2000.0_q_m / 3600.0_q_s)).relative().number() == 2); template -concept invalid_cast = requires(Int i) { - requires !requires { quantity_point_cast, second, Int>>(quantity_point(i * m)); }; - requires !requires { quantity_point_cast, metre, Int>>(quantity_point(i * m)); }; -}; +concept invalid_cast = + requires(Int i) { + requires !requires { + quantity_point_cast, second, Int>>(quantity_point(i * m)); + }; + requires !requires { + quantity_point_cast, metre, Int>>( + quantity_point(i * m)); + }; + }; static_assert(invalid_cast); // time @@ -282,10 +312,7 @@ static_assert(invalid_cast); static_assert(quantity_point{1_q_h} == quantity_point{3600_q_s}); template -concept no_crossdimensional_equality = !requires -{ - quantity_point(1_q_s) == quantity_point(length(1)); -}; +concept no_crossdimensional_equality = !requires { quantity_point(1_q_s) == quantity_point(length(1)); }; static_assert(no_crossdimensional_equality); @@ -297,10 +324,7 @@ static_assert(quantity_point(1_q_km) + 1_q_m == quantity_point(1001_q_m)); static_assert(1_q_km + quantity_point(1_q_m) == quantity_point(1001_q_m)); template -concept dimensional_analysis = requires(T t) -{ - pow<2>(t); -}; +concept dimensional_analysis = requires(T t) { pow<2>(t); }; static_assert(!dimensional_analysis, metre, int>>); diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index 9f9b87ae..0f810ccf 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -58,11 +58,11 @@ static_assert(sizeof(length) == sizeof(short)); #if UNITS_COMP_GCC != 10 || UNITS_COMP_GCC_MINOR > 2 template typename Q> concept invalid_types = requires { - requires !requires { typename Q; }; // unit of a different dimension - requires !requires { typename Q>; }; // quantity used as Rep - requires !requires { typename Q; }; // reordered arguments - requires !requires { typename Q; }; // reordered arguments -}; + requires !requires { typename Q; }; // unit of a different dimension + requires !requires { typename Q>; }; // quantity used as Rep + requires !requires { typename Q; }; // reordered arguments + requires !requires { typename Q; }; // reordered arguments + }; static_assert(invalid_types); #endif @@ -128,7 +128,8 @@ static_assert(!std::convertible_to>); static_assert(std::constructible_from, float>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, double>); // truncating implicit conversions double -> float allowed +static_assert( + std::constructible_from, double>); // truncating implicit conversions double -> float allowed static_assert(!std::convertible_to>); static_assert(std::constructible_from, int>); @@ -137,7 +138,8 @@ static_assert(!std::convertible_to>); static_assert(std::constructible_from, short>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, int>); // truncating implicit conversions int -> short allowed +static_assert( + std::constructible_from, int>); // truncating implicit conversions int -> short allowed static_assert(!std::convertible_to>); // exception, implicit construction from a value allowed for a dimensionless quantity @@ -166,7 +168,8 @@ static_assert(!std::convertible_to>); static_assert(std::constructible_from, float>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, double>); // truncating implicit conversions double -> float allowed +static_assert(std::constructible_from, + double>); // truncating implicit conversions double -> float allowed static_assert(!std::convertible_to>); static_assert(std::constructible_from, int>); @@ -175,7 +178,8 @@ static_assert(!std::convertible_to>); static_assert(std::constructible_from, short>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, int>); // truncating implicit conversions int -> short allowed +static_assert( + std::constructible_from, int>); // truncating implicit conversions int -> short allowed static_assert(!std::convertible_to>); // floating-point to integral truncating conversion not allowed @@ -185,7 +189,7 @@ static_assert(!std::convertible_to>); static_assert(!std::constructible_from, double>); static_assert(!std::convertible_to>); -static_assert(length().number() == 0); // value initialization +static_assert(length().number() == 0); // value initialization static_assert(length(1).number() == 1); static_assert(length(1.0).number() == 1.0); static_assert(length(1).number() == 1.0); @@ -212,16 +216,18 @@ static_assert(!std::convertible_to, length>); // implicit conversion from another quantity only if non-truncating static_assert(std::constructible_from, length>); // int -> double OK -static_assert(std::convertible_to, length>); // int -> double OK +static_assert(std::convertible_to, length>); // int -> double OK static_assert(!std::constructible_from, length>); // truncating double -> int not allowed -static_assert(!std::convertible_to, length>); // truncating double -> int not allowed +static_assert(!std::convertible_to, length>); // truncating double -> int not allowed static_assert(std::constructible_from, length>); // kilometre -> metre OK -static_assert(std::convertible_to, length>); // kilometre -> metre OK +static_assert(std::convertible_to, length>); // kilometre -> metre OK -static_assert(!std::constructible_from, length>); // truncating metre -> kilometre not allowed -static_assert(!std::convertible_to, length>); // truncating metre -> kilometre not allowed +static_assert(!std::constructible_from, + length>); // truncating metre -> kilometre not allowed +static_assert(!std::convertible_to, + length>); // truncating metre -> kilometre not allowed // converting to double always OK static_assert(std::constructible_from, length>); @@ -249,13 +255,21 @@ struct derived_quantity : quantity constexpr explicit(!std::is_trivial_v) derived_quantity(const R& t) : R(t) {} constexpr explicit(!std::is_trivial_v) derived_quantity(R&& t) : R(std::move(t)) {} - constexpr derived_quantity& operator=(const R& t) { R::operator=(t); return *this; } - constexpr derived_quantity& operator=(R&& t) { R::operator=(std::move(t)); return *this; } + constexpr derived_quantity& operator=(const R& t) + { + R::operator=(t); + return *this; + } + constexpr derived_quantity& operator=(R&& t) + { + R::operator=(std::move(t)); + return *this; + } constexpr operator R&() & noexcept { return *this; } - constexpr operator const R&() const & noexcept { return *this; } + constexpr operator const R&() const& noexcept { return *this; } constexpr operator R&&() && noexcept { return *this; } - constexpr operator const R&&() const && noexcept { return *this; } + constexpr operator const R&&() const&& noexcept { return *this; } }; static_assert(detail::is_quantity, "NTTP type description">>); @@ -290,8 +304,16 @@ static_assert(is_same_v>); // assignment operator //////////////////////// -static_assert([]() { length l1(1), l2(2); return l2 = l1; }().number() == 1); -static_assert([]() { length l1(1), l2(2); return l2 = std::move(l1); }().number() == 1); +static_assert([]() { + length l1(1), l2(2); + return l2 = l1; +}() + .number() == 1); +static_assert([]() { + length l1(1), l2(2); + return l2 = std::move(l1); +}() + .number() == 1); //////////////////// @@ -303,10 +325,22 @@ static_assert((-123_q_m).number() == -123); static_assert((+(-123_q_m)).number() == -123); static_assert((-(-123_q_m)).number() == 123); -static_assert([](auto v) { auto vv = v++; return std::pair(v, vv); }(123_q_m) == std::pair(124_q_m, 123_q_m)); -static_assert([](auto v) { auto vv = ++v; return std::pair(v, vv); }(123_q_m) == std::pair(124_q_m, 124_q_m)); -static_assert([](auto v) { auto vv = v--; return std::pair(v, vv); }(123_q_m) == std::pair(122_q_m, 123_q_m)); -static_assert([](auto v) { auto vv = --v; return std::pair(v, vv); }(123_q_m) == std::pair(122_q_m, 122_q_m)); +static_assert([](auto v) { + auto vv = v++; + return std::pair(v, vv); +}(123_q_m) == std::pair(124_q_m, 123_q_m)); +static_assert([](auto v) { + auto vv = ++v; + return std::pair(v, vv); +}(123_q_m) == std::pair(124_q_m, 124_q_m)); +static_assert([](auto v) { + auto vv = v--; + return std::pair(v, vv); +}(123_q_m) == std::pair(122_q_m, 123_q_m)); +static_assert([](auto v) { + auto vv = --v; + return std::pair(v, vv); +}(123_q_m) == std::pair(122_q_m, 122_q_m)); static_assert(is_same_v); @@ -337,15 +371,32 @@ static_assert((2.5_q_m *= quantity(3)).number() == 7.5); static_assert((7.5_q_m /= quantity(3)).number() == 2.5); static_assert((3500_q_m %= 1_q_km).number() == 500); -static_assert((std::uint8_t(255) * m %= 256).number() == [] { std::uint8_t ui(255); return ui %= 256; }()); -static_assert((std::uint8_t(255) * m %= quantity(256)).number() == [] { std::uint8_t ui(255); return ui %= 256; }()); -// static_assert((std::uint8_t(255) * m %= 256 * m).number() != [] { std::uint8_t ui(255); return ui %= 256; }()); // UB -static_assert((std::uint8_t(255) * m %= 257).number() == [] { std::uint8_t ui(255); return ui %= 257; }()); -static_assert((std::uint8_t(255) * m %= quantity(257)).number() == [] { std::uint8_t ui(255); return ui %= 257; }()); +static_assert((std::uint8_t(255) * m %= 256).number() == [] { + std::uint8_t ui(255); + return ui %= 256; +}()); +static_assert((std::uint8_t(255) * m %= quantity(256)).number() == [] { + std::uint8_t ui(255); + return ui %= 256; +}()); +// static_assert((std::uint8_t(255) * m %= 256 * m).number() != [] { std::uint8_t ui(255); return ui %= 256; }()); // +// UB +static_assert((std::uint8_t(255) * m %= 257).number() == [] { + std::uint8_t ui(255); + return ui %= 257; +}()); +static_assert((std::uint8_t(255) * m %= quantity(257)).number() == [] { + std::uint8_t ui(255); + return ui %= 257; +}()); // TODO: Fix -static_assert((std::uint8_t(255) * m %= 257 * m).number() != [] { std::uint8_t ui(255); return ui %= 257; }()); +static_assert((std::uint8_t(255) * m %= 257 * m).number() != [] { + std::uint8_t ui(255); + return ui %= 257; +}()); -#ifndef UNITS_COMP_MSVC // TODO ICE (https://developercommunity2.visualstudio.com/t/ICE-on-a-constexpr-operator-in-mp-unit/1302907) +#ifndef UNITS_COMP_MSVC // TODO ICE + // (https://developercommunity2.visualstudio.com/t/ICE-on-a-constexpr-operator-in-mp-unit/1302907) // next two lines trigger conversions warnings // (warning disabled in CMake for this file) static_assert((22_q_m *= 33.33).number() == 733); @@ -355,43 +406,44 @@ static_assert((22_q_m /= quantity(3.33)).number() == 6); #endif template -concept invalid_compound_assignments = requires() { - // truncating not allowed - requires !requires(length l) { l += 2.5_q_m; }; - requires !requires(length l) { l -= 2.5_q_m; }; - requires !requires(length l) { l += length(2); }; - requires !requires(length l) { l -= length(2); }; - requires !requires(length l) { l %= length(2); }; - requires !requires(length l) { l %= dimensionless(2); }; - requires !requires(length l) { l %= dimensionless(2); }; +concept invalid_compound_assignments = + requires() { + // truncating not allowed + requires !requires(length l) { l += 2.5_q_m; }; + requires !requires(length l) { l -= 2.5_q_m; }; + requires !requires(length l) { l += length(2); }; + requires !requires(length l) { l -= length(2); }; + requires !requires(length l) { l %= length(2); }; + requires !requires(length l) { l %= dimensionless(2); }; + requires !requires(length l) { l %= dimensionless(2); }; - // TODO: accept non-truncating argument - requires !requires(length l) { l *= 1 * (km / m); }; - requires !requires(length l) { l /= 1 * (km / m); }; - requires !requires(length l) { l %= 1 * (km / m); }; + // TODO: accept non-truncating argument + requires !requires(length l) { l *= 1 * (km / m); }; + requires !requires(length l) { l /= 1 * (km / m); }; + requires !requires(length l) { l %= 1 * (km / m); }; - // only quantities can be added or subtracted - requires !requires(length l) { l += 2; }; - requires !requires(length l) { l -= 2; }; + // only quantities can be added or subtracted + requires !requires(length l) { l += 2; }; + requires !requires(length l) { l -= 2; }; - // compound multiply/divide by another quantity not allowed - requires !requires(length l) { l *= 2_q_m; }; - requires !requires(length l) { l /= 2_q_m; }; + // compound multiply/divide by another quantity not allowed + requires !requires(length l) { l *= 2_q_m; }; + requires !requires(length l) { l /= 2_q_m; }; - // modulo operations on a floating point representation not allowed - requires !requires(length l) { l %= 2.; }; - requires !requires(length l) { l %= 2; }; - requires !requires(length l) { l %= 2._q_m; }; - requires !requires(length l) { l %= 2_q_m; }; - requires !requires(length l) { l %= 2._q_m; }; + // modulo operations on a floating point representation not allowed + requires !requires(length l) { l %= 2.; }; + requires !requires(length l) { l %= 2; }; + requires !requires(length l) { l %= 2._q_m; }; + requires !requires(length l) { l %= 2_q_m; }; + requires !requires(length l) { l %= 2._q_m; }; - // no unit constants - requires !requires(length l) { l += m; }; - requires !requires(length l) { l -= m; }; - requires !requires(length l) { l *= m; }; - requires !requires(length l) { l /= m; }; - requires !requires(length l) { l %= m; }; -}; + // no unit constants + requires !requires(length l) { l += m; }; + requires !requires(length l) { l -= m; }; + requires !requires(length l) { l *= m; }; + requires !requires(length l) { l /= m; }; + requires !requires(length l) { l %= m; }; + }; static_assert(invalid_compound_assignments); @@ -401,26 +453,26 @@ static_assert(invalid_compound_assignments); template concept invalid_binary_operations = requires { - // no crossdimensional addition and subtraction - requires !requires { 1_q_s + length(1); }; - requires !requires { 1_q_s - length(1); }; + // no crossdimensional addition and subtraction + requires !requires { 1_q_s + length(1); }; + requires !requires { 1_q_s - length(1); }; - // no floating-point modulo - requires !requires(length a) { a % 2_q_m; }; - requires !requires(length a) { 2_q_m % a; }; - requires !requires(length a) { a % 2; }; - requires !requires(length a, length b) { a % b; }; - requires !requires(length a, length b) { a % b; }; - requires !requires(length a, length b) { b % a; }; + // no floating-point modulo + requires !requires(length a) { a % 2_q_m; }; + requires !requires(length a) { 2_q_m % a; }; + requires !requires(length a) { a % 2; }; + requires !requires(length a, length b) { a % b; }; + requires !requires(length a, length b) { a % b; }; + requires !requires(length a, length b) { b % a; }; - // unit constants - requires !requires { length(1) + m; }; - requires !requires { length(1) - m; }; - requires !requires { length(1) % m; }; - requires !requires { m + length(1); }; - requires !requires { m - length(1); }; - requires !requires { m % length(1); }; -}; + // unit constants + requires !requires { length(1) + m; }; + requires !requires { length(1) - m; }; + requires !requires { length(1) % m; }; + requires !requires { m + length(1); }; + requires !requires { m - length(1); }; + requires !requires { m % length(1); }; + }; static_assert(invalid_binary_operations); // same representation type @@ -443,7 +495,8 @@ static_assert(compare> static_assert(compare>); static_assert(compare>); static_assert(compare>); -static_assert(compare(1) / 1_q_s), frequency, std::int64_t>>); +static_assert(compare(1) / 1_q_s), + frequency, std::int64_t>>); static_assert(is_same_v); static_assert(is_same_v); @@ -456,9 +509,13 @@ static_assert(is_same_v>); static_assert(is_same_v>); -static_assert(is_same_v>); // TODO should we address fundamental types implicit truncating conversions with concepts? +static_assert( + is_same_v>); // TODO should we address fundamental types implicit + // truncating conversions with concepts? static_assert(is_same_v>); -static_assert(is_same_v>); // TODO should we address fundamental types implicit truncating conversions with concepts? +static_assert(is_same_v>); // TODO should we address fundamental types implicit truncating + // conversions with concepts? static_assert(is_same_v>); static_assert(is_same_v>); static_assert(is_same_v>); @@ -469,7 +526,8 @@ static_assert(compare(1)), static_assert(compare>); static_assert(compare>); static_assert(compare>); -static_assert(compare(1) / 1._q_s), frequency, long double>>); +static_assert(compare(1) / 1._q_s), + frequency, long double>>); static_assert(compare>); static_assert(compare>); static_assert(compare(1)), length>); @@ -490,7 +548,8 @@ static_assert(compare> static_assert(compare>); static_assert(compare>); static_assert(compare>); -static_assert(compare(1) / 1_q_s), frequency, long double>>); +static_assert(compare(1) / 1_q_s), + frequency, long double>>); // different units static_assert(is_same_v>); @@ -519,15 +578,21 @@ static_assert(is_same_v>); static_assert(compare, std::int64_t>>); -static_assert(compare, exponent>, scaled_unit, std::int64_t>>); +static_assert( + compare, exponent>, + scaled_unit, std::int64_t>>); static_assert(compare>); static_assert(compare, std::int64_t>>); static_assert(compare>); -static_assert(compare>, scaled_unit, std::int64_t>>); +static_assert( + compare>, + scaled_unit, std::int64_t>>); static_assert(compare, std::int64_t>>); static_assert(compare>); static_assert(compare, std::int64_t>>); -static_assert(compare, exponent>, scaled_unit, std::int64_t>>); +static_assert( + compare, exponent>, + scaled_unit, std::int64_t>>); static_assert((1_q_m + 1_q_m).number() == 2); static_assert((1_q_m + 1_q_km).number() == 1001); @@ -652,9 +717,9 @@ static_assert(quantity{2} / (1 * m) == 2 / 1_q_m); template concept no_crossdimensional_equality = requires { - requires !requires { 1_q_s == length(1); }; - requires !requires { 1_q_s != length(1); }; -}; + requires !requires { 1_q_s == length(1); }; + requires !requires { 1_q_s != length(1); }; + }; static_assert(no_crossdimensional_equality); // same type @@ -688,11 +753,11 @@ static_assert(123 != quantity{321}); template concept no_crossdimensional_ordering = requires { - requires !requires { 1_q_s < length(1); }; - requires !requires { 1_q_s > length(1); }; - requires !requires { 1_q_s <= length(1); }; - requires !requires { 1_q_s >= length(1); }; -}; + requires !requires { 1_q_s < length(1); }; + requires !requires { 1_q_s > length(1); }; + requires !requires { 1_q_s <= length(1); }; + requires !requires { 1_q_s >= length(1); }; + }; static_assert(no_crossdimensional_ordering); // same type @@ -764,9 +829,9 @@ static_assert(!std::equality_comparable_with, double>); template concept invalid_dimensionless_operations = requires { - requires !requires(dimensionless d) { 1 + d; }; - requires !requires(dimensionless d) { d + 1; }; -}; + requires !requires(dimensionless d) { 1 + d; }; + requires !requires(dimensionless d) { d + 1; }; + }; static_assert(invalid_dimensionless_operations); static_assert(compare>); @@ -815,7 +880,9 @@ static_assert(!is_same_v(2_q_dm3)), volume, units::exponent>, scaled_unit, std::int64_t>>); +static_assert(is_same_v, units::exponent>, + scaled_unit, std::int64_t>>); static_assert(is_same_v, std::int64_t>>); #else @@ -846,6 +913,7 @@ static_assert(same(quotient_remainder_theorem(3'000 * m, 400), 3'000 * m)); static_assert(same(quotient_remainder_theorem(3'000 * m, quantity(400)), 3'000 * m)); static_assert(same(quotient_remainder_theorem(3 * km, quantity(400)), 3 * km)); static_assert(same(quotient_remainder_theorem(3 * km, quantity(2)), 3 * km)); -static_assert(same(quotient_remainder_theorem(3 * km, dimensionless, int>(400)), 3 * km)); +static_assert(same(quotient_remainder_theorem(3 * km, dimensionless, int>(400)), + 3 * km)); } // namespace diff --git a/test/unit_test/static/ratio_test.cpp b/test/unit_test/static/ratio_test.cpp index 32de5f10..9eac9963 100644 --- a/test/unit_test/static/ratio_test.cpp +++ b/test/unit_test/static/ratio_test.cpp @@ -45,7 +45,7 @@ static_assert(-ratio(3, 8) == ratio(-3, 8)); // ratio addition static_assert(ratio(1, 2) + ratio(1, 3) == ratio(5, 6)); -static_assert(ratio(1, 3, 2) + ratio(11, 6) == ratio(211, 6)); // 100/3 + 11/6 +static_assert(ratio(1, 3, 2) + ratio(11, 6) == ratio(211, 6)); // 100/3 + 11/6 // multiply with exponents static_assert(ratio(1, 8, 2) * ratio(2, 1, 4) == ratio(1, 4, 6)); diff --git a/test/unit_test/static/references_test.cpp b/test/unit_test/static/references_test.cpp index 670f0975..ef128436 100644 --- a/test/unit_test/static/references_test.cpp +++ b/test/unit_test/static/references_test.cpp @@ -36,24 +36,24 @@ static_assert(2 * m == 2_q_m); static_assert(2 * s == 2_q_s); template concept invalid_operations = requires { - requires !requires { 2 / s; }; - requires !requires { s / 2; }; - requires !requires { s * 2; }; - requires !requires { s + 2; }; - requires !requires { 2 + s; }; - requires !requires { s + s; }; - requires !requires { s - 2; }; - requires !requires { 2 - s; }; - requires !requires { s - s; }; - requires !requires { s + 1_q_s; }; - requires !requires { s - 1_q_s; }; - requires !requires { s * 1_q_s; }; - requires !requires { s / 1_q_s; }; - requires !requires { 1_q_s + s; }; - requires !requires { 1_q_s - s; }; - requires !requires { 1_q_s * s; }; - requires !requires { 1_q_s / s; }; -}; + requires !requires { 2 / s; }; + requires !requires { s / 2; }; + requires !requires { s * 2; }; + requires !requires { s + 2; }; + requires !requires { 2 + s; }; + requires !requires { s + s; }; + requires !requires { s - 2; }; + requires !requires { 2 - s; }; + requires !requires { s - s; }; + requires !requires { s + 1_q_s; }; + requires !requires { s - 1_q_s; }; + requires !requires { s * 1_q_s; }; + requires !requires { s / 1_q_s; }; + requires !requires { 1_q_s + s; }; + requires !requires { 1_q_s - s; }; + requires !requires { 1_q_s * s; }; + requires !requires { 1_q_s / s; }; + }; static_assert(invalid_operations); static_assert(2_q_m / (1 * s) == 2_q_m_per_s); @@ -77,7 +77,8 @@ static_assert(1. / 4 * m2 == 1._q_m2 / 4); UNITS_DIAGNOSTIC_PUSH UNITS_DIAGNOSTIC_IGNORE_SHADOW -constexpr bool test_hiding() { +constexpr bool test_hiding() +{ Speed auto v0 = 10 * (m / s); signed s = 2; // hides ^ Length auto v = 20 * m / s; diff --git a/test/unit_test/static/si_cgs_test.cpp b/test/unit_test/static/si_cgs_test.cpp index 81a67faa..42e91ad8 100644 --- a/test/unit_test/static/si_cgs_test.cpp +++ b/test/unit_test/static/si_cgs_test.cpp @@ -21,16 +21,16 @@ // SOFTWARE. #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep namespace { @@ -40,8 +40,10 @@ static_assert(units::detail::quantity_ratio> == units::rat static_assert(units::detail::quantity_ratio> == units::ratio(1, 100)); static_assert(units::detail::quantity_ratio> == units::ratio(1)); static_assert(units::detail::quantity_ratio> == units::ratio(1, 100)); -static_assert(units::detail::quantity_ratio> == units::ratio(1000)); // defined in terms of kilogram that are 1000 * gram -static_assert(units::detail::quantity_ratio> == units::ratio(1, 100)); // defined in terms of gram so only centimetre ratio counts here +static_assert(units::detail::quantity_ratio> == + units::ratio(1000)); // defined in terms of kilogram that are 1000 * gram +static_assert(units::detail::quantity_ratio> == + units::ratio(1, 100)); // defined in terms of gram so only centimetre ratio counts here static_assert(si::cgs::length(100) == si::length(1)); static_assert(si::cgs::mass(1'000) == si::mass(1)); @@ -68,7 +70,7 @@ static_assert(si::cgs::energy(10'000'000) == 1_q_J); static_assert(si::cgs::power(10'000'000) == 1_q_W); static_assert(si::cgs::pressure(10) == 1_q_Pa); -} +} // namespace si_test namespace cgs_test { @@ -84,7 +86,7 @@ static_assert(10'000'000_q_erg == si::energy(1)); static_assert(10'000'000_q_erg_per_s == si::power(1)); static_assert(10_q_Ba == si::pressure(1)); -} +} // namespace cgs_test namespace both_test { @@ -101,7 +103,7 @@ static_assert(10'000'000_q_erg == 1_q_J); static_assert(10'000'000_q_erg_per_s == 1_q_W); static_assert(10_q_Ba == quantity_cast(1_q_Pa)); -} +} // namespace both_test namespace cgs_test { @@ -125,24 +127,29 @@ static_assert(quantity_cast>(si::length(2) == si::area(4)); // TODO Add support for comparing of an unknown_dimension +// static_assert(200_q_cm * si::length(2) == si::area(4)); // TODO Add support for +// comparing of an unknown_dimension static_assert(quantity_cast(200._q_cm) * si::length(2) == si::area(4)); static_assert(200._q_cm * quantity_cast(si::length(2)) == 40'000_q_cm2); // TODO Add support for quantity_cast on an unknown_dimension? -// static_assert(quantity_cast>(200_q_cm * si::length(2)) == si::area(4)); -// static_assert(quantity_cast(200_q_cm * si::length(2)) == si::area(4)); -// static_assert(quantity_cast>(200_q_cm * si::length(2)) == 40'000_q_cm2); -// static_assert(quantity_cast(200_q_cm * si::length(2)) == 40'000_q_cm2); +// static_assert(quantity_cast>(200_q_cm * si::length(2)) == +// si::area(4)); static_assert(quantity_cast(200_q_cm * si::length(2)) == +// si::area(4)); static_assert(quantity_cast>(200_q_cm * +// si::length(2)) == 40'000_q_cm2); static_assert(quantity_cast(200_q_cm * +// si::length(2)) == 40'000_q_cm2); // division -// static_assert(si::area(4) / 200_q_cm == si::length(2)); // TODO Add support for comparing of an unknown_dimension +// static_assert(si::area(4) / 200_q_cm == si::length(2)); // TODO Add support for +// comparing of an unknown_dimension -static_assert(si::area(4) / quantity_cast>(200_q_cm) == si::length(2)); -static_assert(quantity_cast>(si::area(4)) / 200._q_cm == 200_q_cm); +static_assert(si::area(4) / quantity_cast>(200_q_cm) == + si::length(2)); +static_assert(quantity_cast>(si::area(4)) / 200._q_cm == + 200_q_cm); -} +} // namespace cgs_test -} +} // namespace diff --git a/test/unit_test/static/si_fps_test.cpp b/test/unit_test/static/si_fps_test.cpp index d9e494d1..a3b0aeb5 100644 --- a/test/unit_test/static/si_fps_test.cpp +++ b/test/unit_test/static/si_fps_test.cpp @@ -41,7 +41,8 @@ static_assert(si::fps::mass(1) == si::mass(0.45359 static_assert(si::fps::time(1) == si::time(1)); static_assert(si::fps::speed(1) == si::speed(0.3048)); static_assert(si::fps::area(1) == si::area(0.09290304)); -static_assert(si::fps::acceleration(1) == si::acceleration(0.3048)); +static_assert(si::fps::acceleration(1) == + si::acceleration(0.3048)); static_assert(si::fps::force(1) > si::force(0.138254) && si::fps::force(1) < si::force(0.138256)); static_assert(si::fps::energy(1) > si::energy(0.042140110093804) && @@ -61,15 +62,14 @@ static_assert(si::fps::time(1) == 1_q_s); static_assert(si::fps::speed(1) == 0.3048_q_m_per_s); static_assert(si::fps::area(1) == 0.09290304_q_m2); static_assert(si::fps::acceleration(1) == 0.3048_q_m_per_s2); -static_assert(si::fps::force(1) > 0.138254_q_N && - si::fps::force(1) < 0.138256_q_N); +static_assert(si::fps::force(1) > 0.138254_q_N && si::fps::force(1) < 0.138256_q_N); static_assert(si::fps::energy(1) > 0.042140110093804_q_J && si::fps::energy(1) < 0.042140110093806_q_J); static_assert(si::fps::power(1) > 0.042140110093804_q_W && si::fps::power(1) < 0.042140110093806_q_W); -static_assert(si::fps::pressure(1) > 1.4881639435_q_Pa && - si::fps::pressure(1) < 1.4881639437_q_Pa); -} +static_assert(si::fps::pressure(1) > 1.4881639435_q_Pa && + si::fps::pressure(1) < 1.4881639437_q_Pa); +} // namespace si_literals namespace fps_literals { @@ -82,15 +82,14 @@ static_assert(1_q_s == si::time(1)); static_assert(1_q_ft_per_s == si::speed(0.3048)); static_assert(1_q_ft2 == si::area(0.09290304)); static_assert(1_q_ft_per_s2 == si::acceleration(0.3048)); -static_assert(1_q_pdl > si::force(0.138254) && - 1_q_pdl < si::force(0.138256)); +static_assert(1_q_pdl > si::force(0.138254) && 1_q_pdl < si::force(0.138256)); static_assert(1_q_ft_pdl > si::energy(0.042140110093804) && 1_q_ft_pdl < si::energy(0.042140110093806)); static_assert(1_q_ft_pdl_per_s > si::power(0.042140110093804) && 1_q_ft_pdl_per_s < si::power(0.042140110093806)); -static_assert(1_q_pdl_per_ft2> si::pressure(1.4881639435) && +static_assert(1_q_pdl_per_ft2 > si::pressure(1.4881639435) && 1_q_pdl_per_ft2 < si::pressure(1.4881639437)); -} +} // namespace fps_literals namespace fps_plus_si_literals { @@ -102,20 +101,16 @@ using namespace units::isq::si::fps::references; // static_assert(1'000_q_g == 1_q_kg); // ambiguous static_assert(1 * ft == 0.3048_q_m); static_assert(1_q_lb == 0.45359237_q_kg); -static_assert(1_q_s == 1_q_s); +static_assert(1_q_s == 1_q_s); static_assert(1_q_ft_per_s == 0.3048_q_m_per_s); static_assert(1_q_ft2 == 0.09290304_q_m2); static_assert(1_q_ft_per_s2 == 0.3048_q_m_per_s2); -static_assert(1_q_pdl > 0.138254_q_N && - 1_q_pdl < 0.138256_q_N); -static_assert(1_q_ft_pdl > 0.042140110093804_q_J && - 1_q_ft_pdl < 0.042140110093806_q_J); -static_assert(1_q_ft_pdl_per_s > 0.042140110093804_q_W && - 1_q_ft_pdl_per_s < 0.042140110093806_q_W); -static_assert(1_q_pdl_per_ft2> 1.4881639435_q_Pa && - 1_q_pdl_per_ft2 <1.4881639437_q_Pa); +static_assert(1_q_pdl > 0.138254_q_N && 1_q_pdl < 0.138256_q_N); +static_assert(1_q_ft_pdl > 0.042140110093804_q_J && 1_q_ft_pdl < 0.042140110093806_q_J); +static_assert(1_q_ft_pdl_per_s > 0.042140110093804_q_W && 1_q_ft_pdl_per_s < 0.042140110093806_q_W); +static_assert(1_q_pdl_per_ft2 > 1.4881639435_q_Pa && 1_q_pdl_per_ft2 < 1.4881639437_q_Pa); -} +} // namespace fps_plus_si_literals namespace fps_test { @@ -126,34 +121,49 @@ using namespace units::isq::si::fps::references; static_assert(si::length(1) + 1 * ft == si::length(1.3048)); static_assert(1 * ft + si::length(1) == si::length(1.3048)); -static_assert(quantity_cast>(1. * ft / 0.3048) + si::length(1) == si::length(2)); // 1 m in ft + 1 m -static_assert(si::length(1) + quantity_cast>(1. * ft / 0.3048) == si::length(2)); // 1 m + 1 m in ft -static_assert(1 * ft + quantity_cast>(si::length(0.3048)) == 2 * ft); // 1 ft + 1 ft in m -static_assert(quantity_cast>(si::length(0.3048)) + 1 * ft == 2 * ft); // 1 ft in m + 1 ft +static_assert(quantity_cast>(1. * ft / 0.3048) + si::length(1) == + si::length(2)); // 1 m in ft + 1 m +static_assert(si::length(1) + quantity_cast>(1. * ft / 0.3048) == + si::length(2)); // 1 m + 1 m in ft +static_assert(1 * ft + quantity_cast>(si::length(0.3048)) == + 2 * ft); // 1 ft + 1 ft in m +static_assert(quantity_cast>(si::length(0.3048)) + 1 * ft == + 2 * ft); // 1 ft in m + 1 ft // substraction static_assert(1 * ft - si::length(1) == -si::length(0.6952)); static_assert(si::length(1) - 1 * ft == si::length(0.6952)); -static_assert(quantity_cast>(6. * ft) - si::length(1) > si::length(0.8287) && - quantity_cast>(6. * ft) - si::length(1) < si::length(0.8289)); // 6 ft in m - 1 m = ... m -static_assert(si::length(5) - quantity_cast>(6 * ft) == si::length(3.1712)); // 5 m - 6 ft in m = ... -static_assert(6. * ft - quantity_cast>(si::length(0.3048)) == 5. * ft); // 6 ft - 1 ft in m = 5 ft -static_assert(quantity_cast>(si::length(1.8288)) - 1. * ft == 5. * ft); // 6 ft in m - 1 ft = 5 ft +static_assert(quantity_cast>(6. * ft) - si::length(1) > + si::length(0.8287) && + quantity_cast>(6. * ft) - si::length(1) < + si::length(0.8289)); // 6 ft in m - 1 m = ... m +static_assert(si::length(5) - quantity_cast>(6 * ft) == + si::length(3.1712)); // 5 m - 6 ft in m = ... +static_assert(6. * ft - quantity_cast>(si::length(0.3048)) == + 5. * ft); // 6 ft - 1 ft in m = 5 ft +static_assert(quantity_cast>(si::length(1.8288)) - 1. * ft == + 5. * ft); // 6 ft in m - 1 ft = 5 ft // multiplication -// static_assert(2 * ft * si::length(2) == si::area(1.2192)); // TODO Add support for comparing of an unknown_dimension -static_assert(quantity_cast>(2. * ft) * si::length(2) == si::area(1.2192)); -static_assert(quantity_cast>(2. * ft) * si::length(0.6096) == si::area(0.371612160)); // 2 ft * 2 ft == 4 sq ft +// static_assert(2 * ft * si::length(2) == si::area(1.2192)); // TODO Add support for +// comparing of an unknown_dimension +static_assert(quantity_cast>(2. * ft) * si::length(2) == + si::area(1.2192)); +static_assert(quantity_cast>(2. * ft) * si::length(0.6096) == + si::area(0.371612160)); // 2 ft * 2 ft == 4 sq ft static_assert(2. * ft * quantity_cast>(si::length(0.6096)) == 4._q_ft2); // division -// static_assert(si::area(4) / 200_q_cm == si::length(2)); // TODO Add support for comparing of an unknown_dimension -static_assert(si::area(1.48644864) / quantity_cast>(4 * ft) == si::length(1.2192)); // 16 ft2 / 4 ft = 4 ft -static_assert(quantity_cast>(si::area(1.48644864)) / (4. * ft) == 4. * ft); // 16 ft2 / 4 ft = 4 ft +// static_assert(si::area(4) / 200_q_cm == si::length(2)); // TODO Add support for +// comparing of an unknown_dimension +static_assert(si::area(1.48644864) / quantity_cast>(4 * ft) == + si::length(1.2192)); // 16 ft2 / 4 ft = 4 ft +static_assert(quantity_cast>(si::area(1.48644864)) / (4. * ft) == + 4. * ft); // 16 ft2 / 4 ft = 4 ft -} +} // namespace fps_test -} +} // namespace diff --git a/test/unit_test/static/si_hep_test.cpp b/test/unit_test/static/si_hep_test.cpp index 4e1bfbaa..914ceddd 100644 --- a/test/unit_test/static/si_hep_test.cpp +++ b/test/unit_test/static/si_hep_test.cpp @@ -23,9 +23,9 @@ #include #include #include -#include #include #include +#include namespace { @@ -45,7 +45,8 @@ static_assert(si::momentum(1'000'000) == si::hep::momentum(1e28) == si::area(1)); -//static_assert(si::area(1) == si::area(1e-28)); // numeric rounding issues on some platforms +// static_assert(si::area(1) == si::area(1e-28)); // numeric rounding issues on some +// platforms namespace hep_literal_test { @@ -62,9 +63,10 @@ static_assert(si::hep::momentum(1'000) == 1_q_keV_per_c); static_assert(si::hep::momentum(1'000'000) == 1_q_MeV_per_c); // static_assert(si::area(1e-28L) == 1_q_b); // numeric rounding issues on some platforms -//static_assert(si::hep::area(1e-4L) == 1_q_b); // numeric rounding issues on some platforms +// static_assert(si::hep::area(1e-4L) == 1_q_b); // numeric rounding issues on some +// platforms static_assert(si::area(1e-43) == 1_q_fb); -} +} // namespace hep_literal_test -} +} // namespace diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index bc7e16fb..a69c1f1b 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -334,16 +334,18 @@ static_assert(1_q_J_per_K * 1_q_K == 1_q_s * 1_q_N * 1_q_m_per_s); static_assert(1_q_J_per_mol_K == 1_q_J_per_K / 1_q_mol); static_assert(detail::unit_text() == "J/K"); -static_assert(detail::unit_text() == basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J K^-1 kg^-1")); +static_assert(detail::unit_text() == + basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J K^-1 kg^-1")); // thermal conductivity static_assert(20_q_W_per_m_K * 10_q_m * 300_q_K == 60'000_q_W); -static_assert(detail::unit_text() == basic_symbol_text("W ⋅ m⁻¹ ⋅ K⁻¹", "W m^-1 K^-1")); +static_assert(detail::unit_text() == + basic_symbol_text("W ⋅ m⁻¹ ⋅ K⁻¹", "W m^-1 K^-1")); // electric field strength -static_assert(100_q_N/20_q_C == 5_q_V_per_m); +static_assert(100_q_N / 20_q_C == 5_q_V_per_m); static_assert(1_q_C * 10_q_V_per_m * 3_q_m == 30_q_J); static_assert(detail::unit_text() == "V/m"); @@ -358,12 +360,13 @@ static_assert(1_q_C_per_m2 == 1_q_C_per_m3 * 1_q_m); static_assert(1_q_V_per_m * 10_q_C_per_m3 * 1_q_m3 == 10_q_N); static_assert(detail::unit_text() == basic_symbol_text("C/m³", "C/m^3")); -static_assert(detail::unit_text() == basic_symbol_text("C/m²", "C/m^2")); +static_assert(detail::unit_text() == + basic_symbol_text("C/m²", "C/m^2")); // permittivity static_assert(1_q_F_per_m == 1_q_F / 1_q_m); -static_assert(1/(1_q_F_per_m) * 1_q_C * 1_q_C / 1_q_m2 == 1_q_N); +static_assert(1 / (1_q_F_per_m) * 1_q_C * 1_q_C / 1_q_m2 == 1_q_N); static_assert(1_q_C_per_m3 / 1_q_F_per_m * 1_q_m == 1_q_V_per_m); static_assert(detail::unit_text() == "F/m"); diff --git a/test/unit_test/static/symbol_text_test.cpp b/test/unit_test/static/symbol_text_test.cpp index c1e4ffd5..03173810 100644 --- a/test/unit_test/static/symbol_text_test.cpp +++ b/test/unit_test/static/symbol_text_test.cpp @@ -92,4 +92,4 @@ static_assert(sym6 + basic_fixed_string("f") == basic_symbol_text("bcf", "def")) static_assert("a" + sym6 == basic_symbol_text("abc", "ade")); static_assert(sym6 + "f" == basic_symbol_text("bcf", "def")); -} +} // namespace diff --git a/test/unit_test/static/type_list_test.cpp b/test/unit_test/static/type_list_test.cpp index d4ea9dcd..186e0ba0 100644 --- a/test/unit_test/static/type_list_test.cpp +++ b/test/unit_test/static/type_list_test.cpp @@ -50,8 +50,10 @@ static_assert(is_same_v, type_list<>, type_list<>>, t static_assert(is_same_v, type_list<>, type_list<>>, type_list>); static_assert(is_same_v, type_list, type_list<>>, type_list>); static_assert(is_same_v, type_list<>, type_list>, type_list>); -static_assert(is_same_v, type_list, type_list>, type_list>); -static_assert(is_same_v, type_list, type_list>, type_list>); +static_assert( + is_same_v, type_list, type_list>, type_list>); +static_assert(is_same_v, type_list, type_list>, + type_list>); // type_list_split @@ -87,10 +89,9 @@ static_assert(is_same_v>::second_list, static_assert(is_same_v>::first_list, type_list>); static_assert(is_same_v>::second_list, type_list>); +static_assert(is_same_v>::first_list, type_list>); static_assert( - is_same_v>::first_list, type_list>); -static_assert( - is_same_v>::second_list, type_list>); + is_same_v>::second_list, type_list>); // type_list_merge_sorted struct u0 : named_unit {}; @@ -98,10 +99,12 @@ struct d0 : base_dimension<"d0", u0> {}; struct u1 : named_unit {}; struct d1 : base_dimension<"d1", u1> {}; -static_assert(is_same_v>, type_list>, exponent_less>, - type_list, units::exponent>>); -static_assert(is_same_v>, type_list>, exponent_less>, - type_list, units::exponent>>); +static_assert( + is_same_v>, type_list>, exponent_less>, + type_list, units::exponent>>); +static_assert( + is_same_v>, type_list>, exponent_less>, + type_list, units::exponent>>); // type_list_sort @@ -109,9 +112,9 @@ template using exp_sort = type_list_sort; static_assert(is_same_v>>, exponent_list>>); -static_assert( - is_same_v, units::exponent>>, exponent_list, units::exponent>>); -static_assert( - is_same_v, units::exponent>>, exponent_list, units::exponent>>); +static_assert(is_same_v, units::exponent>>, + exponent_list, units::exponent>>); +static_assert(is_same_v, units::exponent>>, + exponent_list, units::exponent>>); } // namespace diff --git a/test/unit_test/static/unit_test.cpp b/test/unit_test/static/unit_test.cpp index ec657dad..4856b09a 100644 --- a/test/unit_test/static/unit_test.cpp +++ b/test/unit_test/static/unit_test.cpp @@ -47,11 +47,14 @@ struct dim_time : base_dimension<"time", second> {}; struct kelvin : named_unit {}; #if !UNITS_COMP_MSVC -static_assert([](P) { return !requires { typename prefixed_unit; }; }(si::kilo{})); // no prefix allowed +static_assert([](P) { + return !requires { typename prefixed_unit; }; +}(si::kilo{})); // no prefix allowed #endif struct metre_per_second : unit {}; -struct dim_speed : derived_dimension, units::exponent> {}; +struct dim_speed : + derived_dimension, units::exponent> {}; struct kilometre_per_hour : derived_unit {}; static_assert(equivalent); @@ -63,7 +66,9 @@ static_assert(compare>, f static_assert(compare>, kilometre_per_hour>); #if !UNITS_COMP_MSVC -static_assert([]() { return !requires { typename scaled_unit; }; }.template operator()()); // negative unit ratio +static_assert([]() { + return !requires { typename scaled_unit; }; +}.template operator()()); // negative unit ratio #endif static_assert(centimetre::symbol == "cm"); From d7681e188e5298c37b46d26656db0bd46a929d73 Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Mon, 21 Feb 2022 01:44:26 +0000 Subject: [PATCH 06/50] Support seamless interop between `ratio` and rational `Magnitude` We provide two new functions, `numerator(m)` and `denominator(m)`, for a Magnitude `m`. They fulfill the following conditions: 1. `numerator(m)` and `denominator(m)` are always integer Magnitudes. 2. If `m` is rational, then `m == numerator(m) / denominator(m)`. If `m` is _not_ rational, then the numerator and denominator are not especially meaningful (there is no uniquely defined "leftover irrational part"). However, we choose a convention that matches how humans would write a mixed number. For example, sqrt(27/16) would have a numerator of 3, denominator of 4, and a "leftover part" of sqrt(3), matching the "human" way of writing this as [(3 * sqrt(3)) / 4]. This has no use yet, but it may later be useful in printing the Magnitude of an anonymous Unit for end users. To further reduce friction for the upcoming migration, we provide an implicit conversion from a Magnitude to a `ratio`. We restrict this operation to rational Magnitudes, and guard this with a `static_assert`. --- src/core/include/units/magnitude.h | 52 ++++++++++++++- src/core/include/units/ratio.h | 19 ++++++ test/unit_test/runtime/magnitude_test.cpp | 78 +++++++++++++++++++++++ test/unit_test/static/ratio_test.cpp | 6 ++ 4 files changed, 154 insertions(+), 1 deletion(-) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index 94140397..eae55206 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -368,6 +368,9 @@ struct magnitude { // Whether this magnitude represents a rational number. friend constexpr bool is_rational(const magnitude&) { return (detail::is_rational(BPs) && ...); } + + // Implicit conversion to ratio. + constexpr explicit(false) operator ratio() const; }; // Implementation for Magnitude concept (below). @@ -392,7 +395,7 @@ template constexpr T get_value(const magnitude&) { // Force the expression to be evaluated in a constexpr context, to catch, e.g., overflow. - constexpr auto result = detail::checked_static_cast((detail::compute_base_power(BPs) * ...)); + constexpr auto result = detail::checked_static_cast((detail::compute_base_power(BPs) * ... * 1)); return result; } @@ -480,6 +483,53 @@ constexpr auto operator*(magnitude, magnitude) constexpr auto operator/(Magnitude auto l, Magnitude auto r) { return l * pow<-1>(r); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Magnitude numerator and denominator implementation. + +namespace detail { + +// The largest integer which can be extracted from any magnitude with only a single basis vector. +template +constexpr auto integer_part(magnitude) +{ + constexpr auto power_num = numerator(BP.power); + constexpr auto power_den = denominator(BP.power); + + if constexpr (std::is_integral_v && (power_num >= power_den)) { + constexpr auto largest_integer_power = [power_num, power_den](BasePower auto bp) { + bp.power = (power_num / power_den); // Note: integer division intended. + return bp; + }(BP); // Note: lambda is immediately invoked. + + return magnitude{}; + } else { + return magnitude<>{}; + } +} + +} // namespace detail + +template +constexpr auto numerator(magnitude) +{ + return (detail::integer_part(magnitude{}) * ... * magnitude<>{}); +} + +constexpr auto denominator(Magnitude auto m) { return numerator(pow<-1>(m)); } + +// Implementation of implicit conversion to ratio goes here, because it needs `numerator()` and `denominator()`. +template +constexpr magnitude::operator ratio() const +{ + static_assert(is_rational(magnitude{})); + + return ratio{ + get_value(numerator(*this)), + get_value(denominator(*this)), + }; +} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // `as_magnitude()` implementation. diff --git a/src/core/include/units/ratio.h b/src/core/include/units/ratio.h index 1e35b47e..d892825a 100644 --- a/src/core/include/units/ratio.h +++ b/src/core/include/units/ratio.h @@ -87,8 +87,27 @@ struct ratio { } [[nodiscard]] friend constexpr ratio operator/(const ratio& lhs, const ratio& rhs) { return lhs * inverse(rhs); } + + [[nodiscard]] friend constexpr std::intmax_t numerator(const ratio& r) + { + std::intmax_t num = r.num; + for (auto i = r.exp; i > 0; --i) { + num *= 10; + } + return num; + } + + [[nodiscard]] friend constexpr std::intmax_t denominator(const ratio& r) + { + std::intmax_t den = r.den; + for (auto i = r.exp; i < 0; ++i) { + den *= 10; + } + return den; + } }; + [[nodiscard]] constexpr ratio inverse(const ratio& r) { return ratio(r.den, r.num, -r.exp); } [[nodiscard]] constexpr bool is_integral(const ratio& r) diff --git a/test/unit_test/runtime/magnitude_test.cpp b/test/unit_test/runtime/magnitude_test.cpp index 9db7b696..b7a75b65 100644 --- a/test/unit_test/runtime/magnitude_test.cpp +++ b/test/unit_test/runtime/magnitude_test.cpp @@ -63,6 +63,18 @@ void check_same_type_and_value(T actual, U expected) CHECK(actual == expected); } +template +void check_ratio_round_trip_is_identity() +{ + constexpr Magnitude auto m = as_magnitude(); + constexpr ratio round_trip = ratio{ + get_value(numerator(m)), + get_value(denominator(m)), + }; + CHECK(round_trip == R); +} + + TEST_CASE("base_power") { SECTION("base rep deducible for integral base") @@ -156,6 +168,15 @@ TEST_CASE("make_ratio performs prime factorization correctly") as_magnitude(); } + SECTION("Can handle prime number which would exceed GCC iteration limit") + { + // GCC 10 has a constexpr loop iteration limit of 262144. A naive algorithm, which performs trial division on 2 and + // all odd numbers up to sqrt(N), will exceed this limit for the following prime. Thus, for this test to pass, we + // need to be using a more efficient algorithm. (We could increase the limit, but we don't want users to have to + // mess with compiler flags just to compile the code.) + as_magnitude<334'524'384'739>(); + } + SECTION("Can bypass computing primes by providing known_first_factor") { // Sometimes, even wheel factorization isn't enough to handle the compilers' limits on constexpr steps and/or @@ -351,6 +372,35 @@ TEST_CASE("can distinguish integral, rational, and irrational magnitudes") } } +TEST_CASE("Constructing ratio from rational magnitude") +{ + SECTION("Round trip is identity") + { + // Note that not every Magnitude can be represented as a ratio. However, if we _start_ with a + // ratio, we must guarantee to recover the same ratio in a round trip. + check_ratio_round_trip_is_identity<1>(); + check_ratio_round_trip_is_identity<9>(); + check_ratio_round_trip_is_identity(); + } + + SECTION("Rational magnitude implicitly converts to ratio") + { + constexpr ratio r = as_magnitude(); + CHECK(r == ratio{22, 7}); + } + + SECTION("Irrational magnitude does not convert to ratio") + { + // The following code should not compile. + // constexpr ratio radical = pow(as_magnitude<2>()); + // (void)radical; + + // The following code should not compile. + // constexpr ratio degrees_per_radian = as_magnitude<180>() / pi_to_the<1>(); + // (void)degrees_per_radian; + } +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Detail function tests below. @@ -374,6 +424,34 @@ TEST_CASE("int_power computes integer powers") } } +TEST_CASE("integer_part picks out integer part of single-basis magnitude") +{ + SECTION("integer_part of non-integer base is identity magnitude") + { + CHECK(integer_part(pi_to_the<1>()) == magnitude<>{}); + CHECK(integer_part(pi_to_the<-8>()) == magnitude<>{}); + CHECK(integer_part(pi_to_the()) == magnitude<>{}); + } + + SECTION("integer_part of integer base to negative power is identity magnitude") + { + CHECK(integer_part(magnitude{}) == magnitude<>{}); + CHECK(integer_part(magnitude{}) == magnitude<>{}); + } + + SECTION("integer_part of integer base to fractional power is identity magnitude") + { + CHECK(integer_part(magnitude{}) == magnitude<>{}); + } + + SECTION("integer_part of integer base to power at least one takes integer part") + { + CHECK(integer_part(magnitude{}) == magnitude{}); + CHECK(integer_part(magnitude{}) == magnitude{}); + CHECK(integer_part(magnitude{}) == magnitude{}); + } +} + TEST_CASE("Prime helper functions") { SECTION("multiplicity") diff --git a/test/unit_test/static/ratio_test.cpp b/test/unit_test/static/ratio_test.cpp index 9eac9963..4abe5094 100644 --- a/test/unit_test/static/ratio_test.cpp +++ b/test/unit_test/static/ratio_test.cpp @@ -102,4 +102,10 @@ static_assert(common_ratio(ratio(100, 1), ratio(1, 10)) == ratio(1, 10)); static_assert(common_ratio(ratio(1), ratio(1, 1, 3)) == ratio(1)); static_assert(common_ratio(ratio(10, 1, -1), ratio(1, 1, -3)) == ratio(1, 1, -3)); +// numerator and denominator +static_assert(numerator(ratio(3, 4)) == 3); +static_assert(numerator(ratio(3, 7, 2)) == 300); +static_assert(denominator(ratio(3, 4)) == 4); +static_assert(denominator(ratio(3, 7, -2)) == 700); + } // namespace From 746aa34fccb20151327979113fbc7d0926c91f5d Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Wed, 6 Apr 2022 00:18:52 +0000 Subject: [PATCH 07/50] Tweak unwise variable names --- src/core/include/units/ratio.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/include/units/ratio.h b/src/core/include/units/ratio.h index d892825a..0fb2f428 100644 --- a/src/core/include/units/ratio.h +++ b/src/core/include/units/ratio.h @@ -90,24 +90,23 @@ struct ratio { [[nodiscard]] friend constexpr std::intmax_t numerator(const ratio& r) { - std::intmax_t num = r.num; + std::intmax_t true_num = r.num; for (auto i = r.exp; i > 0; --i) { - num *= 10; + true_num *= 10; } - return num; + return true_num; } [[nodiscard]] friend constexpr std::intmax_t denominator(const ratio& r) { - std::intmax_t den = r.den; + std::intmax_t true_den = r.den; for (auto i = r.exp; i < 0; ++i) { - den *= 10; + true_den *= 10; } - return den; + return true_den; } }; - [[nodiscard]] constexpr ratio inverse(const ratio& r) { return ratio(r.den, r.num, -r.exp); } [[nodiscard]] constexpr bool is_integral(const ratio& r) From 0f776b5b5bd8b5fe2297db423b53e44ab0b469e9 Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Wed, 6 Apr 2022 00:31:18 +0000 Subject: [PATCH 08/50] Remove incorrectly included test We had removed this upstream, but apparently it snuck back in from a merge/rebase conflict. --- test/unit_test/runtime/magnitude_test.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/unit_test/runtime/magnitude_test.cpp b/test/unit_test/runtime/magnitude_test.cpp index b7a75b65..038aff8a 100644 --- a/test/unit_test/runtime/magnitude_test.cpp +++ b/test/unit_test/runtime/magnitude_test.cpp @@ -168,15 +168,6 @@ TEST_CASE("make_ratio performs prime factorization correctly") as_magnitude(); } - SECTION("Can handle prime number which would exceed GCC iteration limit") - { - // GCC 10 has a constexpr loop iteration limit of 262144. A naive algorithm, which performs trial division on 2 and - // all odd numbers up to sqrt(N), will exceed this limit for the following prime. Thus, for this test to pass, we - // need to be using a more efficient algorithm. (We could increase the limit, but we don't want users to have to - // mess with compiler flags just to compile the code.) - as_magnitude<334'524'384'739>(); - } - SECTION("Can bypass computing primes by providing known_first_factor") { // Sometimes, even wheel factorization isn't enough to handle the compilers' limits on constexpr steps and/or From f77a92ca043a0b460fc7ff910ab008ed47fc90af Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Wed, 6 Apr 2022 00:36:18 +0000 Subject: [PATCH 09/50] Reproduce requires clause clang appears to care about this. --- src/core/include/units/magnitude.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index eae55206..d65c9ad1 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -519,6 +519,7 @@ constexpr auto denominator(Magnitude auto m) { return numerator(pow<-1>(m)); } // Implementation of implicit conversion to ratio goes here, because it needs `numerator()` and `denominator()`. template + requires detail::is_base_power_pack_valid constexpr magnitude::operator ratio() const { static_assert(is_rational(magnitude{})); From b616e5821646db2d8995b0fc95c41205754a9315 Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Wed, 6 Apr 2022 01:40:17 +0000 Subject: [PATCH 10/50] Give up on implicit conversion I don't understand what MSVC is complaining about, and it may end up being easier to just make the conversion explicit. --- src/core/include/units/magnitude.h | 12 +++++------- test/unit_test/runtime/magnitude_test.cpp | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index d65c9ad1..7656a348 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -517,16 +517,14 @@ constexpr auto numerator(magnitude) constexpr auto denominator(Magnitude auto m) { return numerator(pow<-1>(m)); } -// Implementation of implicit conversion to ratio goes here, because it needs `numerator()` and `denominator()`. -template - requires detail::is_base_power_pack_valid -constexpr magnitude::operator ratio() const +// Implementation of conversion to ratio goes here, because it needs `numerator()` and `denominator()`. +constexpr ratio as_ratio(Magnitude auto m) { - static_assert(is_rational(magnitude{})); + static_assert(is_rational(m)); return ratio{ - get_value(numerator(*this)), - get_value(denominator(*this)), + get_value(numerator(m)), + get_value(denominator(m)), }; } diff --git a/test/unit_test/runtime/magnitude_test.cpp b/test/unit_test/runtime/magnitude_test.cpp index 038aff8a..22a3dd4b 100644 --- a/test/unit_test/runtime/magnitude_test.cpp +++ b/test/unit_test/runtime/magnitude_test.cpp @@ -374,9 +374,9 @@ TEST_CASE("Constructing ratio from rational magnitude") check_ratio_round_trip_is_identity(); } - SECTION("Rational magnitude implicitly converts to ratio") + SECTION("Rational magnitude converts to ratio") { - constexpr ratio r = as_magnitude(); + constexpr ratio r = as_ratio(as_magnitude()); CHECK(r == ratio{22, 7}); } From 2c31bf83ec65bfac05fc7184f1a95a259398ba32 Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Wed, 6 Apr 2022 02:01:23 +0000 Subject: [PATCH 11/50] Clean up --- src/core/include/units/magnitude.h | 5 +---- test/unit_test/runtime/magnitude_test.cpp | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index 7656a348..fe814dd2 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -368,9 +368,6 @@ struct magnitude { // Whether this magnitude represents a rational number. friend constexpr bool is_rational(const magnitude&) { return (detail::is_rational(BPs) && ...); } - - // Implicit conversion to ratio. - constexpr explicit(false) operator ratio() const; }; // Implementation for Magnitude concept (below). @@ -395,7 +392,7 @@ template constexpr T get_value(const magnitude&) { // Force the expression to be evaluated in a constexpr context, to catch, e.g., overflow. - constexpr auto result = detail::checked_static_cast((detail::compute_base_power(BPs) * ... * 1)); + constexpr auto result = detail::checked_static_cast((detail::compute_base_power(BPs) * ... * T{1})); return result; } diff --git a/test/unit_test/runtime/magnitude_test.cpp b/test/unit_test/runtime/magnitude_test.cpp index 22a3dd4b..e5d46f26 100644 --- a/test/unit_test/runtime/magnitude_test.cpp +++ b/test/unit_test/runtime/magnitude_test.cpp @@ -383,12 +383,10 @@ TEST_CASE("Constructing ratio from rational magnitude") SECTION("Irrational magnitude does not convert to ratio") { // The following code should not compile. - // constexpr ratio radical = pow(as_magnitude<2>()); - // (void)radical; + // as_ratio(pow(as_magnitude<2>())); // The following code should not compile. - // constexpr ratio degrees_per_radian = as_magnitude<180>() / pi_to_the<1>(); - // (void)degrees_per_radian; + // as_ratio(as_magnitude<180>() / pi_to_the<1>()); } } From 44cccfc743bde1810346bcd7263b9b7a96ce089c Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Sat, 9 Apr 2022 15:39:29 +0000 Subject: [PATCH 12/50] Address review comments --- src/core/include/units/magnitude.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index fe814dd2..88d003e7 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -493,7 +493,7 @@ constexpr auto integer_part(magnitude) constexpr auto power_den = denominator(BP.power); if constexpr (std::is_integral_v && (power_num >= power_den)) { - constexpr auto largest_integer_power = [power_num, power_den](BasePower auto bp) { + constexpr auto largest_integer_power = [=](BasePower auto bp) { bp.power = (power_num / power_den); // Note: integer division intended. return bp; }(BP); // Note: lambda is immediately invoked. @@ -516,9 +516,8 @@ constexpr auto denominator(Magnitude auto m) { return numerator(pow<-1>(m)); } // Implementation of conversion to ratio goes here, because it needs `numerator()` and `denominator()`. constexpr ratio as_ratio(Magnitude auto m) + requires(is_rational(decltype(m){})) { - static_assert(is_rational(m)); - return ratio{ get_value(numerator(m)), get_value(denominator(m)), From 061b7652d36b58abafc623644aab821268424763 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 15 Apr 2022 16:56:48 +0200 Subject: [PATCH 13/50] style: conanfile.py reformatted --- conanfile.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/conanfile.py b/conanfile.py index 924700cb..0d7c2dd3 100644 --- a/conanfile.py +++ b/conanfile.py @@ -28,11 +28,24 @@ import os, re required_conan_version = ">=1.44.0" + class MPUnitsConan(ConanFile): name = "mp-units" homepage = "https://github.com/mpusz/units" description = "Physical Units library for C++" - topics = ("units", "dimensions", "quantities", "dimensional-analysis", "physical-quantities", "physical-units", "system-of-units", "cpp23", "cpp20", "library", "quantity-manipulation") + topics = ( + "units", + "dimensions", + "quantities", + "dimensional-analysis", + "physical-quantities", + "physical-units", + "system-of-units", + "cpp23", + "cpp20", + "library", + "quantity-manipulation", + ) license = "MIT" url = "https://github.com/mpusz/units" settings = "os", "compiler", "build_type", "arch" @@ -48,7 +61,7 @@ class MPUnitsConan(ConanFile): "build_docs": True } exports = ["LICENSE.md"] - exports_sources = ["docs/*", "src/*", "test/*", "cmake/*", "example/*","CMakeLists.txt"] + exports_sources = ["docs/*", "src/*", "test/*", "cmake/*", "example/*", "CMakeLists.txt"] generators = "cmake_paths" @property @@ -68,12 +81,12 @@ class MPUnitsConan(ConanFile): def _use_range_v3(self): compiler = self.settings.compiler version = Version(self.settings.compiler.version) - return ("clang" in compiler and compiler.libcxx == "libc++" and version < 14) + return "clang" in compiler and compiler.libcxx == "libc++" and version < 14 @property def _msvc_version(self): compiler = self.settings.compiler - if (compiler.update): + if compiler.update: return int(f"{compiler.version}{compiler.update}") else: return int(f"{compiler.version}0") From 9abd63c2d56504ebd4af00e3ea41e8baf17b19d8 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 15 Apr 2022 16:57:38 +0200 Subject: [PATCH 14/50] fix: `validate()` replaced with `configure()` to raise errors during `conan install` in Conan 1.X --- conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 0d7c2dd3..2cfa1810 100644 --- a/conanfile.py +++ b/conanfile.py @@ -110,7 +110,8 @@ class MPUnitsConan(ConanFile): if self.options.build_docs: self.tool_requires("doxygen/1.9.2") - def validate(self): + # TODO Replace with `valdate()` for Conan 2.0 (https://github.com/conan-io/conan/issues/10723) + def configure(self): compiler = self.settings.compiler version = Version(self.settings.compiler.version) if compiler == "gcc": From 05fecca12cc48e2dc2b53d06592625823839ecd8 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 15 Apr 2022 17:00:02 +0200 Subject: [PATCH 15/50] refactor: `self.copy` replaced by the explicit tool `copy` (for Conan 2.0) --- conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 2cfa1810..01b90f62 100644 --- a/conanfile.py +++ b/conanfile.py @@ -23,6 +23,7 @@ from conans import ConanFile, tools from conans.tools import Version, check_min_cppstd from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake +from conan.tools.files import copy from conans.errors import ConanInvalidConfiguration import os, re @@ -160,7 +161,7 @@ class MPUnitsConan(ConanFile): self.info.header_only() def package(self): - self.copy("LICENSE.md", dst="licenses") + copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = CMake(self) cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) From 10a1c06dfa1d36c4a300436eaafd8c3df9cbf5b5 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 15 Apr 2022 17:01:47 +0200 Subject: [PATCH 16/50] fix: `includedirs` added for components as there will be no defaults in Conan 2.0 --- conanfile.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 01b90f62..98add025 100644 --- a/conanfile.py +++ b/conanfile.py @@ -171,6 +171,7 @@ class MPUnitsConan(ConanFile): # core self.cpp_info.components["core"].requires = ["gsl-lite::gsl-lite"] + self.cpp_info.components["core"].includedirs = ["include"] if compiler == "Visual Studio": self.cpp_info.components["core"].cxxflags = ["/utf-8"] if self._use_range_v3: @@ -178,19 +179,60 @@ class MPUnitsConan(ConanFile): # rest self.cpp_info.components["core-io"].requires = ["core"] + self.cpp_info.components["core-io"].includedirs = ["include"] + self.cpp_info.components["core-fmt"].requires = ["core"] + self.cpp_info.components["core-fmt"].includedirs = ["include"] if self._use_libfmt: self.cpp_info.components["core-fmt"].requires.append("fmt::fmt") + self.cpp_info.components["isq"].requires = ["core"] + self.cpp_info.components["isq"].includedirs = ["include"] + self.cpp_info.components["isq-natural"].requires = ["isq"] + self.cpp_info.components["isq-natural"].includedirs = ["include"] + self.cpp_info.components["si"].requires = ["isq"] + self.cpp_info.components["si"].includedirs = ["include"] + self.cpp_info.components["si-cgs"].requires = ["si"] + self.cpp_info.components["si-cgs"].includedirs = ["include"] + self.cpp_info.components["si-fps"].requires = ["si"] + self.cpp_info.components["si-fps"].includedirs = ["include"] + self.cpp_info.components["si-hep"].requires = ["si"] + self.cpp_info.components["si-hep"].includedirs = ["include"] + self.cpp_info.components["si-iau"].requires = ["si"] + self.cpp_info.components["si-iau"].includedirs = ["include"] + self.cpp_info.components["si-imperial"].requires = ["si"] + self.cpp_info.components["si-imperial"].includedirs = ["include"] + self.cpp_info.components["si-international"].requires = ["si"] + self.cpp_info.components["si-international"].includedirs = ["include"] + self.cpp_info.components["si-typographic"].requires = ["si"] + self.cpp_info.components["si-typographic"].includedirs = ["include"] + self.cpp_info.components["si-uscs"].requires = ["si"] + self.cpp_info.components["si-uscs"].includedirs = ["include"] + self.cpp_info.components["isq-iec80000"].requires = ["si"] - self.cpp_info.components["systems"].requires = ["isq", "isq-natural", "si", "si-cgs", "si-fps", "si-hep", "si-iau", "si-imperial", "si-international", "si-typographic", "si-uscs", "isq-iec80000"] + self.cpp_info.components["isq-iec80000"].includedirs = ["include"] + + self.cpp_info.components["systems"].requires = [ + "isq", + "isq-natural", + "si", + "si-cgs", + "si-fps", + "si-hep", + "si-iau", + "si-imperial", + "si-international", + "si-typographic", + "si-uscs", + "isq-iec80000", + ] From ac8e32fcdae5685277f0e3d0e574b7c0188f6cf7 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 15 Apr 2022 17:07:55 +0200 Subject: [PATCH 17/50] feat: Conan 2.0 requires the explicit declaration of the requirement being tested --- test_package/conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index babc60b1..9a98ad73 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -23,9 +23,14 @@ from conans import ConanFile, tools from conan.tools.cmake import CMake + class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "CMakeToolchain", "CMakeDeps" + test_type = "explicit" # TODO Remove for Conan 2.0 + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) From 291314fbb743b2025475732480efb8251d534a95 Mon Sep 17 00:00:00 2001 From: Aleksei Latyshev Date: Sun, 17 Apr 2022 23:49:19 +0300 Subject: [PATCH 18/50] docs: fix typo in units.rst --- docs/framework/units.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/framework/units.rst b/docs/framework/units.rst index 86dd0e1b..9e00b7ee 100644 --- a/docs/framework/units.rst +++ b/docs/framework/units.rst @@ -193,7 +193,7 @@ namely second. Those can be defined easily in the library using struct minute : named_scaled_unit {}; struct hour : named_scaled_unit {}; - struct day : named_scaled_unit {}; + struct day : named_scaled_unit {}; where `no_prefix` is a special tag type describing that the library should not allow to define a new prefixed unit that would use this unit as a From a0c625256719ec04b1be948bccb57c776774c7ef Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 19 Apr 2022 18:45:13 +0200 Subject: [PATCH 19/50] refactor: `mi(naut)` renamed to `nmi` Relates to #357 --- src/systems/si-fps/include/units/isq/si/fps/length.h | 2 +- .../include/units/isq/si/international/length.h | 2 +- test/unit_test/runtime/fmt_units_test.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/systems/si-fps/include/units/isq/si/fps/length.h b/src/systems/si-fps/include/units/isq/si/fps/length.h index c037afe1..a4307180 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/length.h +++ b/src/systems/si-fps/include/units/isq/si/fps/length.h @@ -52,7 +52,7 @@ struct kiloyard : prefixed_unit {}; struct mile : named_scaled_unit {}; -struct nautical_mile : named_scaled_unit {}; +struct nautical_mile : named_scaled_unit {}; struct dim_length : isq::dim_length {}; diff --git a/src/systems/si-international/include/units/isq/si/international/length.h b/src/systems/si-international/include/units/isq/si/international/length.h index 38b7eac3..e37944a0 100644 --- a/src/systems/si-international/include/units/isq/si/international/length.h +++ b/src/systems/si-international/include/units/isq/si/international/length.h @@ -56,7 +56,7 @@ struct mile : named_scaled_unit {}; +struct nautical_mile : named_scaled_unit {}; // thou // https://en.wikipedia.org/wiki/Thousandth_of_an_inch diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index c94c3734..8414e5a0 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -65,7 +65,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") CHECK(STD_FMT::format("{}", 1_q_fathom_us) == "1 fathom(us)"); CHECK(STD_FMT::format("{}", 1_q_mi) == "1 mi"); CHECK(STD_FMT::format("{}", 1_q_mi_us) == "1 mi(us)"); - CHECK(STD_FMT::format("{}", 1_q_naut_mi) == "1 mi(naut)"); + CHECK(STD_FMT::format("{}", 1_q_naut_mi) == "1 nmi"); CHECK(STD_FMT::format("{}", 1_q_ch) == "1 ch"); CHECK(STD_FMT::format("{}", 1_q_rd) == "1 rd"); CHECK(STD_FMT::format("{}", 1_q_thou) == "1 thou"); From 999ff52d701dda9c8d118e688612e5026209e552 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 19 Apr 2022 18:48:46 +0200 Subject: [PATCH 20/50] refactor: `knot` unit helper renamed to `kn` in FPS Relates to #357 --- example/aliases/foot_pound_second.cpp | 6 +++--- example/literals/foot_pound_second.cpp | 4 ++-- example/references/foot_pound_second.cpp | 4 ++-- src/systems/si-fps/include/units/isq/si/fps/speed.h | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/example/aliases/foot_pound_second.cpp b/example/aliases/foot_pound_second.cpp index 588e328d..12b1082d 100644 --- a/example/aliases/foot_pound_second.cpp +++ b/example/aliases/foot_pound_second.cpp @@ -68,7 +68,7 @@ void print_details(std::string_view description, const Ship& ship) << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) << STD_FMT::format("{:20} : {}\n", "speed", - fmt_line, si::speed::km_per_h<>>(ship.speed)) + fmt_line, si::speed::km_per_h<>>(ship.speed)) << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) << STD_FMT::format("{:20} : {}\n", "main guns", fmt_line, si::length::mm<>>(ship.mainGuns)) @@ -101,7 +101,7 @@ int main() auto iowa = Ship{.length{ft<>(860.)}, .draft{ft<>(37.) + in<>(2.)}, .beam{ft<>(108.) + in<>(2.)}, - .speed{knot<>(33)}, + .speed{kn<>(33)}, .mass{lton<>(57'540)}, .mainGuns{in<>(16)}, .shellMass{lb<>(2700)}, @@ -112,7 +112,7 @@ int main() auto kgv = Ship{.length{ft<>(745.1)}, .draft{ft<>(33.) + in<>(7.5)}, .beam{ft<>(103.2) + in<>(2.5)}, - .speed{knot<>(28.3)}, + .speed{kn<>(28.3)}, .mass{lton<>(42'245)}, .mainGuns{in<>(14)}, .shellMass{lb<>(1'590)}, diff --git a/example/literals/foot_pound_second.cpp b/example/literals/foot_pound_second.cpp index 69df4f51..67d1d296 100644 --- a/example/literals/foot_pound_second.cpp +++ b/example/literals/foot_pound_second.cpp @@ -108,7 +108,7 @@ int main() auto iowa = Ship{.length{860._q_ft}, .draft{37._q_ft + 2._q_in}, .beam{108._q_ft + 2._q_in}, - .speed{33_q_knot}, + .speed{33_q_kn}, .mass{57'540_q_lton}, .mainGuns{16_q_in}, .shellMass{2700_q_lb}, @@ -119,7 +119,7 @@ int main() auto kgv = Ship{.length{745.1_q_ft}, .draft{33._q_ft + 7.5_q_in}, .beam{103.2_q_ft + 2.5_q_in}, - .speed{28.3_q_knot}, + .speed{28.3_q_kn}, .mass{42'245_q_lton}, .mainGuns{14_q_in}, .shellMass{1'590_q_lb}, diff --git a/example/references/foot_pound_second.cpp b/example/references/foot_pound_second.cpp index f947ed4c..ca1f5447 100644 --- a/example/references/foot_pound_second.cpp +++ b/example/references/foot_pound_second.cpp @@ -112,7 +112,7 @@ int main() auto iowa = Ship{.length{860. * ft}, .draft{37. * ft + 2. * in}, .beam{108. * ft + 2. * in}, - .speed{33 * knot}, + .speed{33 * kn}, .mass{57'540 * lton}, .mainGuns{16 * in}, .shellMass{2700 * lb}, @@ -123,7 +123,7 @@ int main() auto kgv = Ship{.length{745.1 * ft}, .draft{33. * ft + 7.5 * in}, .beam{103.2 * ft + 2.5 * in}, - .speed{28.3 * knot}, + .speed{28.3 * kn}, .mass{42'245 * lton}, .mainGuns{14 * in}, .shellMass{1'590 * lb}, diff --git a/src/systems/si-fps/include/units/isq/si/fps/speed.h b/src/systems/si-fps/include/units/isq/si/fps/speed.h index 04302b86..cc78443f 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/speed.h +++ b/src/systems/si-fps/include/units/isq/si/fps/speed.h @@ -66,12 +66,12 @@ constexpr auto operator"" _q_mph(unsigned long long l) constexpr auto operator"" _q_mph(long double l) { return speed(l); } // kn -constexpr auto operator"" _q_knot(unsigned long long l) +constexpr auto operator"" _q_kn(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } -constexpr auto operator"" _q_knot(long double l) { return speed(l); } +constexpr auto operator"" _q_kn(long double l) { return speed(l); } } // namespace literals @@ -82,7 +82,7 @@ constexpr auto operator"" _q_knot(long double l) { return speed{}; -inline constexpr auto knot = reference{}; +inline constexpr auto kn = reference{}; } // namespace speed_references @@ -105,7 +105,7 @@ using ft_per_s = units::isq::si::fps::speed using mph = units::isq::si::fps::speed; template -using knot = units::isq::si::fps::speed; +using kn = units::isq::si::fps::speed; } // namespace units::aliases::isq::si::fps::inline speed From e660278fa893132cc0782e3fccc369896c00dabd Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 19 Apr 2022 18:49:48 +0200 Subject: [PATCH 21/50] feat: `nautical_mile_per_hour` and `knot` added to `si::international` system Relates to #357 --- .../units/isq/si/international/speed.h | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/systems/si-international/include/units/isq/si/international/speed.h b/src/systems/si-international/include/units/isq/si/international/speed.h index 3ce51418..df074b84 100644 --- a/src/systems/si-international/include/units/isq/si/international/speed.h +++ b/src/systems/si-international/include/units/isq/si/international/speed.h @@ -35,6 +35,9 @@ namespace units::isq::si::international { struct mile_per_hour : derived_unit {}; +struct nautical_mile_per_hour : + derived_unit {}; +struct knot : alias_unit {}; #ifndef UNITS_NO_LITERALS @@ -48,10 +51,42 @@ constexpr auto operator"" _q_mi_per_h(unsigned long long l) } constexpr auto operator"" _q_mi_per_h(long double l) { return si::speed(l); } +// nmi/h +constexpr auto operator"" _q_nmi_per_h(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::speed(static_cast(l)); +} +constexpr auto operator"" _q_nmi_per_h(long double l) { return si::speed(l); } + +// kn +constexpr auto operator"" _q_kn(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::speed(static_cast(l)); +} +constexpr auto operator"" _q_kn(long double l) { return si::speed(l); } + } // namespace literals #endif // UNITS_NO_LITERALS +#ifndef UNITS_NO_REFERENCES + +namespace speed_references { + +inline constexpr auto kn = reference{}; + +} // namespace speed_references + +namespace references { + +using namespace speed_references; + +} // namespace references + +#endif // UNITS_NO_REFERENCES + } // namespace units::isq::si::international #ifndef UNITS_NO_ALIASES @@ -61,6 +96,12 @@ namespace units::aliases::isq::si::international::inline speed { template using mi_per_h = units::isq::si::speed; +template +using nmi_per_h = units::isq::si::speed; + +template +using kn = units::isq::si::speed; + } // namespace units::aliases::isq::si::international::inline speed #endif // UNITS_NO_ALIASES From e525c0c8928fa235cad8ae2b1a84c3270d40096c Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 19 Apr 2022 18:57:06 +0200 Subject: [PATCH 22/50] refactor: `knot` text symbol changed from `"knot"` to `"kn`" Relates to #357 --- src/systems/si-fps/include/units/isq/si/fps/speed.h | 2 +- .../si-international/include/units/isq/si/international/speed.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/systems/si-fps/include/units/isq/si/fps/speed.h b/src/systems/si-fps/include/units/isq/si/fps/speed.h index cc78443f..816aff3a 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/speed.h +++ b/src/systems/si-fps/include/units/isq/si/fps/speed.h @@ -43,7 +43,7 @@ using speed = quantity; struct mile_per_hour : derived_unit {}; struct nautical_mile_per_hour : derived_unit {}; -struct knot : alias_unit {}; +struct knot : alias_unit {}; #ifndef UNITS_NO_LITERALS diff --git a/src/systems/si-international/include/units/isq/si/international/speed.h b/src/systems/si-international/include/units/isq/si/international/speed.h index df074b84..1f81a592 100644 --- a/src/systems/si-international/include/units/isq/si/international/speed.h +++ b/src/systems/si-international/include/units/isq/si/international/speed.h @@ -37,7 +37,7 @@ namespace units::isq::si::international { struct mile_per_hour : derived_unit {}; struct nautical_mile_per_hour : derived_unit {}; -struct knot : alias_unit {}; +struct knot : alias_unit {}; #ifndef UNITS_NO_LITERALS From 11521a5a96358188965ea25673051480910f8625 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 21 Apr 2022 21:23:45 +0200 Subject: [PATCH 23/50] feat(example): `validated_type` and `ranged_representation` example types added --- example/CMakeLists.txt | 3 + example/include/ranged_representation.h | 52 ++++++++++++++++ example/include/validated_type.h | 81 +++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 example/include/ranged_representation.h create mode 100644 example/include/validated_type.h diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 0e7a71b0..76117aa4 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -22,6 +22,9 @@ cmake_minimum_required(VERSION 3.2) +add_library(example_utils INTERFACE) +target_include_directories(example_utils INTERFACE include) + # # add_example(target ...) # diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h new file mode 100644 index 00000000..8d5ec234 --- /dev/null +++ b/example/include/ranged_representation.h @@ -0,0 +1,52 @@ +// 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 "validated_type.h" +#include +#include + +template +inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, Min, Max) == v; }; + +template +class ranged_representation : public validated_type)> { +public: + using base = validated_type)>; + using base::validated_type; + constexpr ranged_representation() : base(T{}) {} + + [[nodiscard]] constexpr ranged_representation operator-() const { return ranged_representation(-this->value()); } +}; + +template +struct std::common_type> : + std::type_identity< + ranged_representation, std::common_type_t{Min}, + std::common_type_t{Max}>> {}; + +template +struct std::common_type, std::intmax_t> : + std::type_identity< + ranged_representation, std::common_type_t{Min}, + std::common_type_t{Max}>> {}; diff --git a/example/include/validated_type.h b/example/include/validated_type.h new file mode 100644 index 00000000..bf44bbbc --- /dev/null +++ b/example/include/validated_type.h @@ -0,0 +1,81 @@ +// 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 + +inline constexpr struct validated_tag { +} validated; + +template Validator> +class validated_type { + T value_; +public: + using value_type = T; + + static constexpr bool validate(const T& value) { return Validator()(value); } + + constexpr explicit validated_type(const T& value) noexcept(std::is_nothrow_copy_constructible_v) + requires std::copyable + : value_(value) + { + gsl_Expects(validate(value_)); + } + + constexpr explicit validated_type(T&& value) noexcept(std::is_nothrow_move_constructible_v) : + value_(std::move(value)) + { + gsl_Expects(validate(value_)); + } + + constexpr validated_type(const T& value, validated_tag) noexcept(std::is_nothrow_copy_constructible_v) + requires std::copyable + : value_(value) + { + } + + constexpr validated_type(T&& value, validated_tag) noexcept(std::is_nothrow_move_constructible_v) : + value_(std::move(value)) + { + } + + constexpr explicit(false) operator T() const noexcept(std::is_nothrow_copy_constructible_v) + requires std::copyable + { + return value_; + } + + constexpr T& value() & noexcept = delete; + constexpr const T& value() const& noexcept { return value_; } + constexpr T&& value() && noexcept { return std::move(value_); } + constexpr const T&& value() const&& noexcept { return std::move(value_); } + + bool operator==(const validated_type&) const + requires std::equality_comparable + = default; + auto operator<=>(const validated_type&) const + requires std::three_way_comparable + = default; +}; From bded48987d075b94a58b50c126843a9e6cc853e1 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 21 Apr 2022 21:25:54 +0200 Subject: [PATCH 24/50] refactor(example): `glide_computer` now use dimensionless quantities with `ranged_representation` as `rep` --- example/glide_computer/CMakeLists.txt | 4 +- example/glide_computer/geographic.cpp | 64 -------- example/glide_computer/include/geographic.h | 153 +++++++++++------- .../glide_computer/include/glide_computer.h | 2 +- 4 files changed, 99 insertions(+), 124 deletions(-) delete mode 100644 example/glide_computer/geographic.cpp diff --git a/example/glide_computer/CMakeLists.txt b/example/glide_computer/CMakeLists.txt index d98b3636..7c19f4db 100644 --- a/example/glide_computer/CMakeLists.txt +++ b/example/glide_computer/CMakeLists.txt @@ -22,6 +22,6 @@ cmake_minimum_required(VERSION 3.2) -add_library(glide_computer STATIC geographic.cpp include/geographic.h glide_computer.cpp include/glide_computer.h) -target_link_libraries(glide_computer PRIVATE mp-units::core-fmt PUBLIC mp-units::si) +add_library(glide_computer STATIC include/geographic.h glide_computer.cpp include/glide_computer.h) +target_link_libraries(glide_computer PRIVATE mp-units::core-fmt PUBLIC mp-units::si example_utils) target_include_directories(glide_computer PUBLIC include) diff --git a/example/glide_computer/geographic.cpp b/example/glide_computer/geographic.cpp deleted file mode 100644 index 4150c792..00000000 --- a/example/glide_computer/geographic.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// 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. - -#include "geographic.h" -#include -#include -#include - -namespace { - -using namespace units::isq::si; -inline constexpr length earth_radius(6371); - -} // namespace - -namespace geographic { - -distance spherical_distance(position from, position to) -{ - using rep = std::common_type_t; - constexpr auto p = std::numbers::pi_v / 180; - const auto lat1 = from.lat.value() * p; - const auto lon1 = from.lon.value() * p; - const auto lat2 = to.lat.value() * p; - const auto lon2 = to.lon.value() * p; - - using std::sin, std::cos, std::asin, std::sqrt; - - // https://en.wikipedia.org/wiki/Great-circle_distance#Formulae - if constexpr (sizeof(rep) >= 8) { - // spherical law of cosines - const auto central_angle = acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)); - // const auto central_angle = 2 * asin(sqrt(0.5 - cos(lat2 - lat1) / 2 + cos(lat1) * cos(lat2) * (1 - cos(lon2 - - // lon1)) / 2)); - return distance(earth_radius * central_angle); - } else { - // the haversine formula - const auto sin_lat = sin((lat2 - lat1) / 2); - const auto sin_lon = sin((lon2 - lon1) / 2); - const auto central_angle = 2 * asin(sqrt(sin_lat * sin_lat + cos(lat1) * cos(lat2) * sin_lon * sin_lon)); - return distance(earth_radius * central_angle); - } -} - -} // namespace geographic diff --git a/example/glide_computer/include/geographic.h b/example/glide_computer/include/geographic.h index 44290080..e8a56714 100644 --- a/example/glide_computer/include/geographic.h +++ b/example/glide_computer/include/geographic.h @@ -22,7 +22,9 @@ #pragma once +#include "ranged_representation.h" #include +#include #include #include #include @@ -34,88 +36,95 @@ namespace geographic { -template -struct coordinate { - using value_type = Rep; - constexpr explicit coordinate(value_type v) : value_(v) {} - constexpr value_type value() const { return value_; } - auto operator<=>(const coordinate&) const = default; -private: - value_type value_; -}; +// TODO Change to `angle` dimension in degree unit when the work on magnitudes is done +template +using latitude = units::dimensionless>; -struct latitude : coordinate { - using coordinate::coordinate; -}; +template +using longitude = units::dimensionless>; -struct longitude : coordinate { - using coordinate::coordinate; -}; - -template -std::basic_ostream& operator<<(std::basic_ostream& os, const latitude& lat) +template +std::basic_ostream& operator<<(std::basic_ostream& os, const latitude& lat) { - if (lat.value() > 0) - return os << "N" << lat.value(); + if (lat.number() > 0) + return os << "N" << lat.number(); else - return os << "S" << -lat.value(); + return os << "S" << -lat.number(); } -template -std::basic_ostream& operator<<(std::basic_ostream& os, const longitude& lon) +template +std::basic_ostream& operator<<(std::basic_ostream& os, const longitude& lon) { - if (lon.value() > 0) - return os << "E" << lon.value(); + if (lon.number() > 0) + return os << "E" << lon.number(); else - return os << "W" << -lon.value(); + return os << "W" << -lon.number(); } inline namespace literals { -constexpr auto operator"" _N(unsigned long long v) { return latitude(static_cast(v)); } -constexpr auto operator"" _N(long double v) { return latitude(static_cast(v)); } -constexpr auto operator"" _S(unsigned long long v) { return latitude(-static_cast(v)); } -constexpr auto operator"" _S(long double v) { return latitude(-static_cast(v)); } -constexpr auto operator"" _E(unsigned long long v) { return longitude(static_cast(v)); } -constexpr auto operator"" _E(long double v) { return longitude(static_cast(v)); } -constexpr auto operator"" _W(unsigned long long v) { return longitude(-static_cast(v)); } -constexpr auto operator"" _W(long double v) { return longitude(-static_cast(v)); } +constexpr auto operator"" _N(long double v) { return latitude(latitude::rep(v)); } +constexpr auto operator"" _S(long double v) { return latitude(latitude::rep(v)); } +constexpr auto operator"" _E(long double v) { return longitude(longitude::rep(v)); } +constexpr auto operator"" _W(long double v) { return longitude(longitude::rep(v)); } +constexpr auto operator"" _N(unsigned long long v) +{ + gsl_ExpectsAudit(std::in_range(v)); + return latitude(latitude::rep(static_cast(v))); +} +constexpr auto operator"" _S(unsigned long long v) +{ + gsl_ExpectsAudit(std::in_range(v)); + return latitude(-latitude::rep(static_cast(v))); +} +constexpr auto operator"" _E(unsigned long long v) +{ + gsl_ExpectsAudit(std::in_range(v)); + return longitude(longitude::rep(static_cast(v))); +} +constexpr auto operator"" _W(unsigned long long v) +{ + gsl_ExpectsAudit(std::in_range(v)); + return longitude(-longitude::rep(static_cast(v))); +} } // namespace literals } // namespace geographic -template<> -class std::numeric_limits : public numeric_limits { - static constexpr auto min() noexcept { return geographic::latitude(-90); } - static constexpr auto lowest() noexcept { return geographic::latitude(-90); } - static constexpr auto max() noexcept { return geographic::latitude(90); } +template +class std::numeric_limits> : public numeric_limits { + static constexpr auto min() noexcept { return geographic::latitude(-90); } + static constexpr auto lowest() noexcept { return geographic::latitude(-90); } + static constexpr auto max() noexcept { return geographic::latitude(90); } }; -template<> -class std::numeric_limits : public numeric_limits { - static constexpr auto min() noexcept { return geographic::longitude(-180); } - static constexpr auto lowest() noexcept { return geographic::longitude(-180); } - static constexpr auto max() noexcept { return geographic::longitude(180); } +template +class std::numeric_limits> : public numeric_limits { + static constexpr auto min() noexcept { return geographic::longitude(-180); } + static constexpr auto lowest() noexcept { return geographic::longitude(-180); } + static constexpr auto max() noexcept { return geographic::longitude(180); } }; -template<> -struct STD_FMT::formatter : formatter { +template +struct STD_FMT::formatter> : formatter { template - auto format(geographic::latitude lat, FormatContext& ctx) + auto format(geographic::latitude lat, FormatContext& ctx) { - STD_FMT::format_to(ctx.out(), "{}", lat.value() > 0 ? 'N' : 'S'); - return formatter::format(lat.value() > 0 ? lat.value() : -lat.value(), ctx); + using rep = geographic::latitude::rep; + STD_FMT::format_to(ctx.out(), "{}", lat > rep{0} ? 'N' : 'S'); + return formatter::format(lat > rep{0} ? lat.number() : -lat.number(), ctx); } }; -template<> -struct STD_FMT::formatter : formatter { +template +struct STD_FMT::formatter> : formatter { template - auto format(geographic::longitude lon, FormatContext& ctx) + auto format(geographic::longitude lon, FormatContext& ctx) { - STD_FMT::format_to(ctx.out(), "{}", lon.value() > 0 ? 'E' : 'W'); - return formatter::format(lon.value() > 0 ? lon.value() : -lon.value(), ctx); + using rep = geographic::longitude::rep; + STD_FMT::format_to(ctx.out(), "{}", lon > rep{0} ? 'E' : 'W'); + return formatter::format(lon > rep{0} ? lon.number() : -lon.number(), ctx); } }; @@ -124,11 +133,41 @@ namespace geographic { struct horizontal_kind : units::kind {}; using distance = units::quantity_kind; +template struct position { - latitude lat; - longitude lon; + latitude lat; + longitude lon; }; -distance spherical_distance(position from, position to); +template +distance spherical_distance(position from, position to) +{ + using namespace units::isq::si; + constexpr length earth_radius(6371); + + constexpr auto p = std::numbers::pi_v / 180; + const auto lat1_rad = from.lat.number() * p; + const auto lon1_rad = from.lon.number() * p; + const auto lat2_rad = to.lat.number() * p; + const auto lon2_rad = to.lon.number() * p; + + using std::sin, std::cos, std::asin, std::acos, std::sqrt; + + // https://en.wikipedia.org/wiki/Great-circle_distance#Formulae + if constexpr (sizeof(T) >= 8) { + // spherical law of cosines + const auto central_angle = + acos(sin(lat1_rad) * sin(lat2_rad) + cos(lat1_rad) * cos(lat2_rad) * cos(lon2_rad - lon1_rad)); + // const auto central_angle = 2 * asin(sqrt(0.5 - cos(lat2_rad - lat1_rad) / 2 + cos(lat1_rad) * cos(lat2_rad) * (1 + // - cos(lon2_rad - lon1_rad)) / 2)); + return distance(earth_radius * central_angle); + } else { + // the haversine formula + const auto sin_lat = sin((lat2_rad - lat1_rad) / 2); + const auto sin_lon = sin((lon2_rad - lon1_rad) / 2); + const auto central_angle = 2 * asin(sqrt(sin_lat * sin_lat + cos(lat1_rad) * cos(lat2_rad) * sin_lon * sin_lon)); + return distance(earth_radius * central_angle); + } +} } // namespace geographic diff --git a/example/glide_computer/include/glide_computer.h b/example/glide_computer/include/glide_computer.h index d545ea7a..c515868c 100644 --- a/example/glide_computer/include/glide_computer.h +++ b/example/glide_computer/include/glide_computer.h @@ -136,7 +136,7 @@ struct weather { struct waypoint { std::string name; - geographic::position pos; + geographic::position pos; altitude alt; }; From c598201d113fb3ae7ca133980fa1701e8157dc2d Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 22 Apr 2022 13:07:01 +0200 Subject: [PATCH 25/50] fix: `ranged_representation` refactored to work with older compilers --- example/glide_computer/include/geographic.h | 5 +++-- example/include/ranged_representation.h | 22 +++++++++------------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/example/glide_computer/include/geographic.h b/example/glide_computer/include/geographic.h index e8a56714..9c72b1e0 100644 --- a/example/glide_computer/include/geographic.h +++ b/example/glide_computer/include/geographic.h @@ -28,6 +28,7 @@ #include #include #include +#include #include // IWYU pragma: begin_exports @@ -38,10 +39,10 @@ namespace geographic { // TODO Change to `angle` dimension in degree unit when the work on magnitudes is done template -using latitude = units::dimensionless>; +using latitude = units::dimensionless>; template -using longitude = units::dimensionless>; +using longitude = units::dimensionless>; template std::basic_ostream& operator<<(std::basic_ostream& os, const latitude& lat) diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h index 8d5ec234..b620729e 100644 --- a/example/include/ranged_representation.h +++ b/example/include/ranged_representation.h @@ -26,27 +26,23 @@ #include #include -template -inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, Min, Max) == v; }; +template +inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; }; -template -class ranged_representation : public validated_type)> { +template +class ranged_representation : public validated_type)> { public: - using base = validated_type)>; + using base = validated_type)>; using base::validated_type; constexpr ranged_representation() : base(T{}) {} [[nodiscard]] constexpr ranged_representation operator-() const { return ranged_representation(-this->value()); } }; -template +template struct std::common_type> : - std::type_identity< - ranged_representation, std::common_type_t{Min}, - std::common_type_t{Max}>> {}; + std::type_identity, Min, Max>> {}; -template +template struct std::common_type, std::intmax_t> : - std::type_identity< - ranged_representation, std::common_type_t{Min}, - std::common_type_t{Max}>> {}; + std::type_identity, Min, Max>> {}; From 967c1c9ca997c2b1c596d462ba7934f4d92d7d33 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 22 Apr 2022 13:26:31 +0200 Subject: [PATCH 26/50] fix: `ranged_representation` fixed for clang-12 --- example/include/ranged_representation.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h index b620729e..3d7b2a88 100644 --- a/example/include/ranged_representation.h +++ b/example/include/ranged_representation.h @@ -23,6 +23,7 @@ #pragma once #include "validated_type.h" +#include #include #include @@ -30,11 +31,13 @@ template inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; }; template -class ranged_representation : public validated_type)> { +using is_in_range_t = decltype(is_in_range); + +template +class ranged_representation : public validated_type> { public: - using base = validated_type)>; - using base::validated_type; - constexpr ranged_representation() : base(T{}) {} + using validated_type>::validated_type; + constexpr ranged_representation() : validated_type>(T{}) {} [[nodiscard]] constexpr ranged_representation operator-() const { return ranged_representation(-this->value()); } }; From 954dc5d53e3735d550c949ae0471122e894b6d74 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 22 Apr 2022 13:27:11 +0200 Subject: [PATCH 27/50] fix: missing `typename` added for clang-12 --- example/glide_computer/include/geographic.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/example/glide_computer/include/geographic.h b/example/glide_computer/include/geographic.h index 9c72b1e0..851f79c6 100644 --- a/example/glide_computer/include/geographic.h +++ b/example/glide_computer/include/geographic.h @@ -23,6 +23,7 @@ #pragma once #include "ranged_representation.h" +#include #include #include #include @@ -112,7 +113,7 @@ struct STD_FMT::formatter> : formatter { template auto format(geographic::latitude lat, FormatContext& ctx) { - using rep = geographic::latitude::rep; + using rep = TYPENAME geographic::latitude::rep; STD_FMT::format_to(ctx.out(), "{}", lat > rep{0} ? 'N' : 'S'); return formatter::format(lat > rep{0} ? lat.number() : -lat.number(), ctx); } @@ -123,7 +124,7 @@ struct STD_FMT::formatter> : formatter { template auto format(geographic::longitude lon, FormatContext& ctx) { - using rep = geographic::longitude::rep; + using rep = TYPENAME geographic::longitude::rep; STD_FMT::format_to(ctx.out(), "{}", lon > rep{0} ? 'E' : 'W'); return formatter::format(lon > rep{0} ? lon.number() : -lon.number(), ctx); } From e62c162610202748fdf2cf0d04d0e38270c07fa6 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 23 Apr 2022 16:52:06 +0200 Subject: [PATCH 28/50] fix: `radioactivity` header compilation fixed --- .../si/include/units/isq/si/radioactivity.h | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/systems/si/include/units/isq/si/radioactivity.h b/src/systems/si/include/units/isq/si/radioactivity.h index 017d8fcf..7db478d1 100644 --- a/src/systems/si/include/units/isq/si/radioactivity.h +++ b/src/systems/si/include/units/isq/si/radioactivity.h @@ -280,47 +280,47 @@ using namespace radioactivity_references; namespace units::aliases::isq::si::inline radioactivity { template -using Bq = units::isq::radioactivity; +using Bq = units::isq::si::radioactivity; template -using yBq = units::isq::radioactivity; +using yBq = units::isq::si::radioactivity; template -using zBq = units::isq::radioactivity; +using zBq = units::isq::si::radioactivity; template -using aBq = units::isq::radioactivity; +using aBq = units::isq::si::radioactivity; template -using fBq = units::isq::radioactivity; +using fBq = units::isq::si::radioactivity; template -using pBq = units::isq::radioactivity; +using pBq = units::isq::si::radioactivity; template -using nBq = units::isq::radioactivity; +using nBq = units::isq::si::radioactivity; template -using uBq = units::isq::radioactivity; +using uBq = units::isq::si::radioactivity; template -using mBq = units::isq::radioactivity; +using mBq = units::isq::si::radioactivity; template -using cBq = units::isq::radioactivity; +using cBq = units::isq::si::radioactivity; template -using dBq = units::isq::radioactivity; +using dBq = units::isq::si::radioactivity; template -using daBq = units::isq::radioactivity; +using daBq = units::isq::si::radioactivity; template -using hBq = units::isq::radioactivity; +using hBq = units::isq::si::radioactivity; template -using kBq = units::isq::radioactivity; +using kBq = units::isq::si::radioactivity; template -using MBq = units::isq::radioactivity; +using MBq = units::isq::si::radioactivity; template -using GBq = units::isq::radioactivity; +using GBq = units::isq::si::radioactivity; template -using TBq = units::isq::radioactivity; +using TBq = units::isq::si::radioactivity; template -using PBq = units::isq::radioactivity; +using PBq = units::isq::si::radioactivity; template -using EBq = units::isq::radioactivity; +using EBq = units::isq::si::radioactivity; template -using ZBq = units::isq::radioactivity; +using ZBq = units::isq::si::radioactivity; template -using YBq = units::isq::radioactivity; +using YBq = units::isq::si::radioactivity; } // namespace units::aliases::isq::si::inline radioactivity From 56cee31a675fe731103421da0570198ed1015a1f Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 24 Apr 2022 19:52:07 +0200 Subject: [PATCH 29/50] fix: `si::hep::dim_momentum` duplicated definition fixed --- src/systems/si-hep/include/units/isq/si/hep/momentum.h | 5 +++-- test/unit_test/static/si_hep_test.cpp | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/systems/si-hep/include/units/isq/si/hep/momentum.h b/src/systems/si-hep/include/units/isq/si/hep/momentum.h index 285f9d21..74a85390 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/momentum.h +++ b/src/systems/si-hep/include/units/isq/si/hep/momentum.h @@ -24,7 +24,6 @@ // IWYU pragma: begin_exports #include -#include #include #include // IWYU pragma: end_exports @@ -35,9 +34,11 @@ namespace units::isq::si::hep { +struct kilogram_metre_per_second : unit {}; + struct eV_per_c : named_scaled_unit {}; + kilogram_metre_per_second> {}; struct feV_per_c : prefixed_unit {}; struct peV_per_c : prefixed_unit {}; struct neV_per_c : prefixed_unit {}; diff --git a/test/unit_test/static/si_hep_test.cpp b/test/unit_test/static/si_hep_test.cpp index 914ceddd..87045e63 100644 --- a/test/unit_test/static/si_hep_test.cpp +++ b/test/unit_test/static/si_hep_test.cpp @@ -40,8 +40,6 @@ static_assert(si::mass(1'000) == si::hep::mass(1'000'000) == si::hep::momentum(1)); -static_assert(si::hep::momentum(1'000'000) == si::momentum(1)); -static_assert(si::momentum(1'000'000) == si::hep::momentum(1)); // area static_assert(si::area(1e28) == si::area(1)); From 464b4467ee5d291ff72e21721d0a48133ae9883b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 24 Apr 2022 19:52:58 +0200 Subject: [PATCH 30/50] fix: public headers fixed to be standalone --- src/systems/isq/include/units/isq/dimensions/momentum.h | 1 + src/systems/si-hep/include/units/isq/si/hep/area.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/systems/isq/include/units/isq/dimensions/momentum.h b/src/systems/isq/include/units/isq/dimensions/momentum.h index f7240259..8508fb0a 100644 --- a/src/systems/isq/include/units/isq/dimensions/momentum.h +++ b/src/systems/isq/include/units/isq/dimensions/momentum.h @@ -23,6 +23,7 @@ #pragma once #include +#include #include namespace units::isq { diff --git a/src/systems/si-hep/include/units/isq/si/hep/area.h b/src/systems/si-hep/include/units/isq/si/hep/area.h index 9718fb2d..da988438 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/area.h +++ b/src/systems/si-hep/include/units/isq/si/hep/area.h @@ -29,7 +29,7 @@ #include // IWYU pragma: end_exports -#include +#include #include namespace units::isq::si::hep { From d18bf2229a5afd86b018e296c4c6878e9b8f3c8e Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 24 Apr 2022 19:59:46 +0200 Subject: [PATCH 31/50] test: standalone public headers tests added --- CMakeLists.txt | 42 ++++++- cmake/TestHeaders.cmake | 128 ++++++++++++++++++++ src/CMakeLists.txt | 2 +- src/cmake/AddUnitsModule.cmake | 42 ++++++- src/core-fmt/CMakeLists.txt | 9 +- src/core-io/CMakeLists.txt | 9 +- src/core/CMakeLists.txt | 28 ++++- src/systems/CMakeLists.txt | 2 +- src/systems/isq-iec80000/CMakeLists.txt | 14 ++- src/systems/isq-natural/CMakeLists.txt | 19 ++- src/systems/isq/CMakeLists.txt | 53 +++++++- src/systems/si-cgs/CMakeLists.txt | 19 ++- src/systems/si-fps/CMakeLists.txt | 22 +++- src/systems/si-hep/CMakeLists.txt | 13 +- src/systems/si-iau/CMakeLists.txt | 10 +- src/systems/si-imperial/CMakeLists.txt | 10 +- src/systems/si-international/CMakeLists.txt | 14 ++- src/systems/si-typographic/CMakeLists.txt | 11 +- src/systems/si-uscs/CMakeLists.txt | 11 +- src/systems/si/CMakeLists.txt | 55 ++++++++- 20 files changed, 476 insertions(+), 37 deletions(-) create mode 100644 cmake/TestHeaders.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e3626289..00112c6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) project(mp-units-dev LANGUAGES CXX) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -71,3 +71,43 @@ add_subdirectory(docs) # add unit tests enable_testing() add_subdirectory(test) + +function(get_target_linked_targets target targets_out) + get_target_property(linked_libs ${target} INTERFACE_LINK_LIBRARIES) + foreach(linked_lib ${linked_libs}) + if(NOT linked_lib IN_LIST targets) + if(TARGET ${linked_lib}) + get_target_linked_targets(${linked_lib} child_targets) + list(APPEND targets ${linked_lib} ${child_targets}) + endif() + endif() + endforeach() + + list(REMOVE_DUPLICATES targets) + list(REMOVE_DUPLICATES link_libs) + set(${targets_out} ${targets} PARENT_SCOPE) +endfunction() + +function(get_target_sources target paths_out) + get_target_linked_targets(${target} targets) + list(APPEND targets ${target}) + + foreach(t ${targets}) + get_target_property(sources ${t} SOURCES) + if(sources) + get_target_property(source_dir ${t} SOURCE_DIR) + foreach(f ${sources}) + file(REAL_PATH "${f}" path BASE_DIRECTORY "${source_dir}") + list(APPEND paths "${path}") + endforeach() + endif() + endforeach() + + set(${paths_out} ${paths} PARENT_SCOPE) +endfunction() + +# tests for standalone headers +include(TestHeaders) +get_target_sources(mp-units::mp-units sources) +add_header_test(test_headers HEADERS ${sources}) +target_link_libraries(test_headers PRIVATE mp-units::mp-units) diff --git a/cmake/TestHeaders.cmake b/cmake/TestHeaders.cmake new file mode 100644 index 00000000..663c9f4e --- /dev/null +++ b/cmake/TestHeaders.cmake @@ -0,0 +1,128 @@ +# Copyright Louis Dionne 2013-2017 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +# +# +# This CMake module provides a function generating a unit test to make sure +# that every public header can be included on its own. +# +# When a C++ library or application has many header files, it can happen that +# a header does not include all the other headers it depends on. When this is +# the case, it can happen that including that header file on its own will +# break the compilation. This CMake module generates a dummy executable +# comprised of many .cpp files, each of which includes a header file that +# is part of the public API. In other words, the executable is comprised +# of .cpp files of the form: +# +# #include +# +# and then exactly one `main` function. If this succeeds to compile, it means +# that the header can be included on its own, which is what clients expect. +# Otherwise, you have a problem. Since writing these dumb unit tests by hand +# is tedious and repetitive, you can use this CMake module to automate this +# task. + +# add_header_test( [EXCLUDE_FROM_ALL] [EXCLUDE excludes...] HEADERS headers...) +# +# Generates header-inclusion unit tests for all the specified headers. +# +# This function creates a target which builds a dummy executable including +# each specified header file individually. If this target builds successfully, +# it means that all the specified header files can be included individually. +# +# Parameters +# ---------- +# : +# The name of the target to generate. +# +# HEADERS headers: +# A list of header files to generate the inclusion tests for. All headers +# in this list must be represented as relative paths from the root of the +# include directory added to the compiler's header search path. In other +# words, it should be possible to include all headers in this list as +# +# #include <${header}> +# +# For example, for a library with the following structure: +# +# project/ +# doc/ +# test/ +# ... +# include/ +# boost/ +# hana.hpp +# hana/ +# transform.hpp +# tuple.hpp +# pair.hpp +# ... +# +# When building the unit tests for that library, we'll add `-I project/include' +# to the compiler's arguments. The list of public headers should therefore contain +# +# boost/hana.hpp +# boost/hana/transform.hpp +# boost/hana/tuple.hpp +# boost/hana/pair.hpp +# ... +# +# Usually, all the 'public' header files of a library should be tested for +# standalone inclusion. A header is considered 'public' if a client should +# be able to include that header on its own. +# +# [EXCLUDE excludes]: +# An optional list of headers or regexes for which no unit test should be +# generated. Basically, any header in the list specified by the `HEADERS` +# argument that matches anything in `EXCLUDE` will be skipped. +# +# [EXCLUDE_FROM_ALL]: +# If provided, the generated target is excluded from the 'all' target. +# +function(add_header_test target) + cmake_parse_arguments(ARGS "EXCLUDE_FROM_ALL" # options + "" # 1 value args + "HEADERS;EXCLUDE" # multivalued args + ${ARGN}) + if (NOT ARGS_HEADERS) + message(FATAL_ERROR "The `HEADERS` argument must be provided.") + endif() + + if (ARGS_EXCLUDE_FROM_ALL) + set(ARGS_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL") + else() + set(ARGS_EXCLUDE_FROM_ALL "") + endif() + + foreach(header ${ARGS_HEADERS}) + set(skip FALSE) + foreach(exclude ${ARGS_EXCLUDE}) + if (${header} MATCHES ${exclude}) + set(skip TRUE) + break() + endif() + endforeach() + if (skip) + continue() + endif() + + get_filename_component(filename "${header}" NAME_WE) + get_filename_component(directory "${header}" DIRECTORY) + + set(source "${CMAKE_CURRENT_BINARY_DIR}/headers/${directory}/${filename}.cpp") + if (NOT EXISTS "${source}") + file(WRITE "${source}" "#include <${header}>") + endif() + list(APPEND sources "${source}") + endforeach() + + set(standalone_main "${CMAKE_CURRENT_BINARY_DIR}/headers/_standalone_main.cpp") + if (NOT EXISTS "${standalone_main}") + file(WRITE "${standalone_main}" "int main() { }") + endif() + add_executable(${target} + ${ARGS_EXCLUDE_FROM_ALL} + ${sources} + "${CMAKE_CURRENT_BINARY_DIR}/headers/_standalone_main.cpp" + ) +endfunction() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ed41451..32a5e555 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) project(mp-units VERSION 0.8.0 LANGUAGES CXX) set(projectPrefix UNITS_) diff --git a/src/cmake/AddUnitsModule.cmake b/src/cmake/AddUnitsModule.cmake index bac9a57d..2f92d92b 100644 --- a/src/cmake/AddUnitsModule.cmake +++ b/src/cmake/AddUnitsModule.cmake @@ -20,14 +20,48 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) + +function(validate_unparsed module prefix) + if(${prefix}_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Invalid arguments '${${prefix}_UNPARSED_ARGUMENTS}' " + "for module '${module}'") + endif() +endfunction() + +function(validate_argument_exists module prefix arg) + if(NOT ${prefix}_${arg}) + message(FATAL_ERROR "'${arg}' not provided for module '${module}'") + endif() +endfunction() + +function(validate_arguments_exists module prefix) + foreach(arg ${ARGN}) + validate_argument_exists(${module} ${prefix} ${arg}) + endforeach() +endfunction() # -# add_units_module(ModuleName ...) +# add_units_module(ModuleName +# DEPENDENCIES ... +# HEADERS ...) # function(add_units_module name) - add_library(mp-units-${name} INTERFACE) - target_link_libraries(mp-units-${name} INTERFACE ${ARGN}) + # parse arguments + set(multiValues DEPENDENCIES HEADERS) + cmake_parse_arguments( + PARSE_ARGV 1 + ARG + "" "" "${multiValues}" + ) + + # validate and process arguments + validate_unparsed(${name} ARG) + validate_arguments_exists(${name} ARG DEPENDENCIES HEADERS) + + # define the target for a module + add_library(mp-units-${name} INTERFACE ${ARG_HEADERS}) + target_link_libraries(mp-units-${name} INTERFACE ${ARG_DEPENDENCIES}) target_include_directories( mp-units-${name} ${unitsAsSystem} INTERFACE $ $ diff --git a/src/core-fmt/CMakeLists.txt b/src/core-fmt/CMakeLists.txt index 1ee5e6f7..57212995 100644 --- a/src/core-fmt/CMakeLists.txt +++ b/src/core-fmt/CMakeLists.txt @@ -20,12 +20,17 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) option(${projectPrefix}USE_LIBFMT "Enables usage of libfmt instead of the one from 'std'" ON) message(STATUS "${projectPrefix}USE_LIBFMT: ${${projectPrefix}USE_LIBFMT}") -add_units_module(core-fmt mp-units::core) +add_units_module(core-fmt + DEPENDENCIES + mp-units::core + HEADERS + include/units/format.h +) target_compile_definitions(mp-units-core-fmt INTERFACE ${projectPrefix}USE_LIBFMT=$) if(${projectPrefix}USE_LIBFMT) diff --git a/src/core-io/CMakeLists.txt b/src/core-io/CMakeLists.txt index dc34d127..6faab9ff 100644 --- a/src/core-io/CMakeLists.txt +++ b/src/core-io/CMakeLists.txt @@ -20,6 +20,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(core-io mp-units::core) +add_units_module(core-io + DEPENDENCIES + mp-units::core + HEADERS + include/units/quantity_io.h +) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4a4682be..cdc1eb36 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) # core library options set(${projectPrefix}DOWNCAST_MODE ON CACHE STRING "Select downcasting mode") @@ -34,7 +34,31 @@ include(CheckLibcxxInUse) check_libcxx_in_use(${projectPrefix}LIBCXX) # core library definition -add_library(mp-units-core INTERFACE) +add_library(mp-units-core INTERFACE + include/units/base_dimension.h + include/units/chrono.h + include/units/concepts.h + include/units/customization_points.h + include/units/derived_dimension.h + include/units/exponent.h + include/units/generic/angle.h + include/units/generic/dimensionless.h + include/units/kind.h + include/units/magnitude.h + include/units/math.h + include/units/point_origin.h + include/units/prefix.h + include/units/quantity.h + include/units/quantity_cast.h + include/units/quantity_kind.h + include/units/quantity_point.h + include/units/quantity_point_kind.h + include/units/random.h + include/units/ratio.h + include/units/reference.h + include/units/symbol_text.h + include/units/unit.h +) target_compile_features(mp-units-core INTERFACE cxx_std_20) target_link_libraries(mp-units-core INTERFACE gsl::gsl-lite) target_include_directories( diff --git a/src/systems/CMakeLists.txt b/src/systems/CMakeLists.txt index 41adc78e..06a3169d 100644 --- a/src/systems/CMakeLists.txt +++ b/src/systems/CMakeLists.txt @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) # systems add_subdirectory(isq) diff --git a/src/systems/isq-iec80000/CMakeLists.txt b/src/systems/isq-iec80000/CMakeLists.txt index 9f37c6f6..84e8f8d7 100644 --- a/src/systems/isq-iec80000/CMakeLists.txt +++ b/src/systems/isq-iec80000/CMakeLists.txt @@ -20,6 +20,16 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(isq-iec80000 mp-units::si) +add_units_module(isq-iec80000 + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/iec80000/binary_prefixes.h + include/units/isq/iec80000/iec80000.h + include/units/isq/iec80000/modulation_rate.h + include/units/isq/iec80000/storage_capacity.h + include/units/isq/iec80000/traffic_intensity.h + include/units/isq/iec80000/transfer_rate.h +) diff --git a/src/systems/isq-natural/CMakeLists.txt b/src/systems/isq-natural/CMakeLists.txt index 7f9353b4..b88038ce 100644 --- a/src/systems/isq-natural/CMakeLists.txt +++ b/src/systems/isq-natural/CMakeLists.txt @@ -20,6 +20,21 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(isq-natural mp-units::isq) +add_units_module(isq-natural + DEPENDENCIES + mp-units::isq + HEADERS + include/units/isq/natural/acceleration.h + include/units/isq/natural/constants.h + include/units/isq/natural/energy.h + include/units/isq/natural/force.h + include/units/isq/natural/length.h + include/units/isq/natural/mass.h + include/units/isq/natural/momentum.h + include/units/isq/natural/natural.h + include/units/isq/natural/speed.h + include/units/isq/natural/time.h + include/units/isq/natural/units.h +) diff --git a/src/systems/isq/CMakeLists.txt b/src/systems/isq/CMakeLists.txt index 1c8e49b5..960a0114 100644 --- a/src/systems/isq/CMakeLists.txt +++ b/src/systems/isq/CMakeLists.txt @@ -20,6 +20,55 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(isq mp-units::core) +add_units_module(isq + DEPENDENCIES + mp-units::core + HEADERS + include/units/isq/dimensions/absorbed_dose.h + include/units/isq/dimensions/acceleration.h + include/units/isq/dimensions/amount_of_substance.h + include/units/isq/dimensions/angular_velocity.h + include/units/isq/dimensions/area.h + include/units/isq/dimensions/capacitance.h + include/units/isq/dimensions/catalytic_activity.h + include/units/isq/dimensions/charge_density.h + include/units/isq/dimensions/concentration.h + include/units/isq/dimensions/conductance.h + include/units/isq/dimensions/current_density.h + include/units/isq/dimensions/density.h + include/units/isq/dimensions/dynamic_viscosity.h + include/units/isq/dimensions/electric_charge.h + include/units/isq/dimensions/electric_current.h + include/units/isq/dimensions/electric_field_strength.h + include/units/isq/dimensions/energy.h + include/units/isq/dimensions/energy_density.h + include/units/isq/dimensions/force.h + include/units/isq/dimensions/frequency.h + include/units/isq/dimensions/heat_capacity.h + include/units/isq/dimensions/inductance.h + include/units/isq/dimensions/length.h + include/units/isq/dimensions/luminance.h + include/units/isq/dimensions/luminous_intensity.h + include/units/isq/dimensions/magnetic_flux.h + include/units/isq/dimensions/magnetic_induction.h + include/units/isq/dimensions/mass.h + include/units/isq/dimensions/molar_energy.h + include/units/isq/dimensions/momentum.h + include/units/isq/dimensions/permeability.h + include/units/isq/dimensions/permittivity.h + include/units/isq/dimensions/power.h + include/units/isq/dimensions/pressure.h + include/units/isq/dimensions/radioactivity.h + include/units/isq/dimensions/resistance.h + include/units/isq/dimensions/speed.h + include/units/isq/dimensions/surface_tension.h + include/units/isq/dimensions/thermal_conductivity.h + include/units/isq/dimensions/thermodynamic_temperature.h + include/units/isq/dimensions/time.h + include/units/isq/dimensions/torque.h + include/units/isq/dimensions/voltage.h + include/units/isq/dimensions/volume.h + include/units/isq/dimensions.h +) diff --git a/src/systems/si-cgs/CMakeLists.txt b/src/systems/si-cgs/CMakeLists.txt index 10b16ae9..5a1cb20a 100644 --- a/src/systems/si-cgs/CMakeLists.txt +++ b/src/systems/si-cgs/CMakeLists.txt @@ -20,6 +20,21 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(si-cgs mp-units::si) +add_units_module(si-cgs + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/si/cgs/acceleration.h + include/units/isq/si/cgs/area.h + include/units/isq/si/cgs/cgs.h + include/units/isq/si/cgs/energy.h + include/units/isq/si/cgs/force.h + include/units/isq/si/cgs/length.h + include/units/isq/si/cgs/mass.h + include/units/isq/si/cgs/power.h + include/units/isq/si/cgs/pressure.h + include/units/isq/si/cgs/speed.h + include/units/isq/si/cgs/time.h +) diff --git a/src/systems/si-fps/CMakeLists.txt b/src/systems/si-fps/CMakeLists.txt index c311fb5e..12f9bd9e 100644 --- a/src/systems/si-fps/CMakeLists.txt +++ b/src/systems/si-fps/CMakeLists.txt @@ -20,6 +20,24 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) + +add_units_module(si-fps + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/si/fps/acceleration.h + include/units/isq/si/fps/area.h + include/units/isq/si/fps/density.h + include/units/isq/si/fps/energy.h + include/units/isq/si/fps/force.h + include/units/isq/si/fps/fps.h + include/units/isq/si/fps/length.h + include/units/isq/si/fps/mass.h + include/units/isq/si/fps/power.h + include/units/isq/si/fps/pressure.h + include/units/isq/si/fps/speed.h + include/units/isq/si/fps/time.h + include/units/isq/si/fps/volume.h +) -add_units_module(si-fps mp-units::si) diff --git a/src/systems/si-hep/CMakeLists.txt b/src/systems/si-hep/CMakeLists.txt index 0403a82b..66747172 100644 --- a/src/systems/si-hep/CMakeLists.txt +++ b/src/systems/si-hep/CMakeLists.txt @@ -20,6 +20,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(si-hep mp-units::si) +add_units_module(si-hep + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/si/hep/area.h + include/units/isq/si/hep/energy.h + include/units/isq/si/hep/hep.h + include/units/isq/si/hep/mass.h + include/units/isq/si/hep/momentum.h +) diff --git a/src/systems/si-iau/CMakeLists.txt b/src/systems/si-iau/CMakeLists.txt index ce9984a8..2677a344 100644 --- a/src/systems/si-iau/CMakeLists.txt +++ b/src/systems/si-iau/CMakeLists.txt @@ -20,6 +20,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(si-iau mp-units::si) +add_units_module(si-iau + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/si/iau/iau.h + include/units/isq/si/iau/length.h +) diff --git a/src/systems/si-imperial/CMakeLists.txt b/src/systems/si-imperial/CMakeLists.txt index f99f274b..ac903b82 100644 --- a/src/systems/si-imperial/CMakeLists.txt +++ b/src/systems/si-imperial/CMakeLists.txt @@ -20,6 +20,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(si-imperial mp-units::si) +add_units_module(si-imperial + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/si/imperial/imperial.h + include/units/isq/si/imperial/length.h +) diff --git a/src/systems/si-international/CMakeLists.txt b/src/systems/si-international/CMakeLists.txt index e8b2716a..b62cd360 100644 --- a/src/systems/si-international/CMakeLists.txt +++ b/src/systems/si-international/CMakeLists.txt @@ -20,6 +20,16 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) + +add_units_module(si-international + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/si/international/area.h + include/units/isq/si/international/international.h + include/units/isq/si/international/length.h + include/units/isq/si/international/speed.h + include/units/isq/si/international/volume.h +) -add_units_module(si-international mp-units::si) diff --git a/src/systems/si-typographic/CMakeLists.txt b/src/systems/si-typographic/CMakeLists.txt index 10d0e4d7..e8d17a84 100644 --- a/src/systems/si-typographic/CMakeLists.txt +++ b/src/systems/si-typographic/CMakeLists.txt @@ -20,6 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) + +add_units_module(si-typographic + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/si/typographic/length.h + include/units/isq/si/typographic/typographic.h +) -add_units_module(si-typographic mp-units::si) diff --git a/src/systems/si-uscs/CMakeLists.txt b/src/systems/si-uscs/CMakeLists.txt index d5abf74c..4bce00eb 100644 --- a/src/systems/si-uscs/CMakeLists.txt +++ b/src/systems/si-uscs/CMakeLists.txt @@ -20,6 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) + +add_units_module(si-uscs + DEPENDENCIES + mp-units::si + HEADERS + include/units/isq/si/uscs/length.h + include/units/isq/si/uscs/uscs.h +) -add_units_module(si-uscs mp-units::si) diff --git a/src/systems/si/CMakeLists.txt b/src/systems/si/CMakeLists.txt index bb5098b5..5fd34835 100644 --- a/src/systems/si/CMakeLists.txt +++ b/src/systems/si/CMakeLists.txt @@ -20,6 +20,57 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) -add_units_module(si mp-units::isq) +add_units_module(si + DEPENDENCIES + mp-units::isq + HEADERS + include/units/isq/si/absorbed_dose.h + include/units/isq/si/acceleration.h + include/units/isq/si/amount_of_substance.h + include/units/isq/si/angular_velocity.h + include/units/isq/si/area.h + include/units/isq/si/capacitance.h + include/units/isq/si/catalytic_activity.h + include/units/isq/si/charge_density.h + include/units/isq/si/concentration.h + include/units/isq/si/conductance.h + include/units/isq/si/constants.h + include/units/isq/si/current_density.h + include/units/isq/si/density.h + include/units/isq/si/dynamic_viscosity.h + include/units/isq/si/electric_charge.h + include/units/isq/si/electric_current.h + include/units/isq/si/electric_field_strength.h + include/units/isq/si/energy.h + include/units/isq/si/energy_density.h + include/units/isq/si/force.h + include/units/isq/si/frequency.h + include/units/isq/si/heat_capacity.h + include/units/isq/si/inductance.h + include/units/isq/si/length.h + include/units/isq/si/luminance.h + include/units/isq/si/luminous_intensity.h + include/units/isq/si/magnetic_flux.h + include/units/isq/si/magnetic_induction.h + include/units/isq/si/mass.h + include/units/isq/si/molar_energy.h + include/units/isq/si/momentum.h + include/units/isq/si/permeability.h + include/units/isq/si/permittivity.h + include/units/isq/si/power.h + include/units/isq/si/prefixes.h + include/units/isq/si/pressure.h + include/units/isq/si/radioactivity.h + include/units/isq/si/resistance.h + include/units/isq/si/si.h + include/units/isq/si/speed.h + include/units/isq/si/surface_tension.h + include/units/isq/si/thermal_conductivity.h + include/units/isq/si/thermodynamic_temperature.h + include/units/isq/si/time.h + include/units/isq/si/torque.h + include/units/isq/si/voltage.h + include/units/isq/si/volume.h +) From be678e8ffa4aea9400399432c6d601e3b06926ec Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 24 Apr 2022 22:23:16 +0200 Subject: [PATCH 32/50] build: `add_public_header_test()` added and fixed Windows absolute header path issue --- CMakeLists.txt | 47 +++++------------------- cmake/TestPublicHeaders.cmake | 68 +++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 38 deletions(-) create mode 100644 cmake/TestPublicHeaders.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 00112c6f..cbee492f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,13 @@ if(${projectPrefix}IWYU) endif() endif() +option(${projectPrefix}CLANG_TIDY "Enables clang-tidy" OFF) +if(${projectPrefix}CLANG_TIDY) + message(STATUS "Enabling clang-tidy") + set(CMAKE_CXX_CLANG_TIDY clang-tidy) + message(STATUS "Enabling clang-tidy - done") +endif() + #enable_clang_tidy() # add project code @@ -72,42 +79,6 @@ add_subdirectory(docs) enable_testing() add_subdirectory(test) -function(get_target_linked_targets target targets_out) - get_target_property(linked_libs ${target} INTERFACE_LINK_LIBRARIES) - foreach(linked_lib ${linked_libs}) - if(NOT linked_lib IN_LIST targets) - if(TARGET ${linked_lib}) - get_target_linked_targets(${linked_lib} child_targets) - list(APPEND targets ${linked_lib} ${child_targets}) - endif() - endif() - endforeach() - - list(REMOVE_DUPLICATES targets) - list(REMOVE_DUPLICATES link_libs) - set(${targets_out} ${targets} PARENT_SCOPE) -endfunction() - -function(get_target_sources target paths_out) - get_target_linked_targets(${target} targets) - list(APPEND targets ${target}) - - foreach(t ${targets}) - get_target_property(sources ${t} SOURCES) - if(sources) - get_target_property(source_dir ${t} SOURCE_DIR) - foreach(f ${sources}) - file(REAL_PATH "${f}" path BASE_DIRECTORY "${source_dir}") - list(APPEND paths "${path}") - endforeach() - endif() - endforeach() - - set(${paths_out} ${paths} PARENT_SCOPE) -endfunction() - # tests for standalone headers -include(TestHeaders) -get_target_sources(mp-units::mp-units sources) -add_header_test(test_headers HEADERS ${sources}) -target_link_libraries(test_headers PRIVATE mp-units::mp-units) +include(TestPublicHeaders) +add_public_header_test(test_headers mp-units::mp-units) diff --git a/cmake/TestPublicHeaders.cmake b/cmake/TestPublicHeaders.cmake new file mode 100644 index 00000000..a1d3d4a8 --- /dev/null +++ b/cmake/TestPublicHeaders.cmake @@ -0,0 +1,68 @@ +# 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. + +cmake_minimum_required(VERSION 3.19) + +function(get_target_linked_targets target targets_out) + get_target_property(linked_libs ${target} INTERFACE_LINK_LIBRARIES) + foreach(linked_lib ${linked_libs}) + if(NOT linked_lib IN_LIST targets) + if(TARGET ${linked_lib}) + get_target_linked_targets(${linked_lib} child_targets) + list(APPEND targets ${linked_lib} ${child_targets}) + endif() + endif() + endforeach() + + list(REMOVE_DUPLICATES targets) + list(REMOVE_DUPLICATES link_libs) + set(${targets_out} ${targets} PARENT_SCOPE) +endfunction() + +function(get_target_sources target paths_out) + get_target_linked_targets(${target} targets) + list(APPEND targets ${target}) + + foreach(t ${targets}) + get_target_property(sources ${t} SOURCES) + if(sources) + get_target_property(source_dir ${t} SOURCE_DIR) + foreach(f ${sources}) + file(REAL_PATH "${f}" path BASE_DIRECTORY "${source_dir}") + file(RELATIVE_PATH path ${CMAKE_CURRENT_LIST_DIR} "${path}") + list(APPEND paths "${path}") + endforeach() + endif() + endforeach() + + set(${paths_out} ${paths} PARENT_SCOPE) +endfunction() + +include(TestHeaders) + +function(add_public_header_test target test_target) + get_target_sources(${test_target} sources) + add_header_test(${target} HEADERS ${sources}) + target_link_libraries(${target} PRIVATE ${test_target}) + target_include_directories(${target} PRIVATE .) +endfunction() + From 98da140fae4d266cb5e329f8d7d4d7dcfd8cf89f Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 24 Apr 2022 22:55:30 +0200 Subject: [PATCH 33/50] ci: `pre-commit` cmake-format checks fixed --- .cmake-format.yaml | 14 ++- cmake/TestHeaders.cmake | 29 +++--- cmake/TestPublicHeaders.cmake | 1 - src/cmake/AddUnitsModule.cmake | 9 +- src/core-fmt/CMakeLists.txt | 7 +- src/core-io/CMakeLists.txt | 7 +- src/core/CMakeLists.txt | 4 +- src/systems/isq-iec80000/CMakeLists.txt | 16 ++-- src/systems/isq-natural/CMakeLists.txt | 29 +++--- src/systems/isq/CMakeLists.txt | 97 ++++++++++--------- src/systems/si-cgs/CMakeLists.txt | 29 +++--- src/systems/si-fps/CMakeLists.txt | 34 ++++--- src/systems/si-hep/CMakeLists.txt | 13 +-- src/systems/si-iau/CMakeLists.txt | 8 +- src/systems/si-imperial/CMakeLists.txt | 9 +- src/systems/si-international/CMakeLists.txt | 16 ++-- src/systems/si-typographic/CMakeLists.txt | 10 +- src/systems/si-uscs/CMakeLists.txt | 9 +- src/systems/si/CMakeLists.txt | 101 ++++++++++---------- 19 files changed, 200 insertions(+), 242 deletions(-) diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 45da65a4..2956b76e 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -4,19 +4,25 @@ parse: pargs: nargs: 1 flags: - - ALL + - ALL kwargs: BREATHE_PROJECT: 1 CODE_SOURCE_DIR: 1 INSTALL_DIR: 1 CODE_DEPENDS: 1 DOCS_DEPENDS: 1 + add_units_module: + pargs: + nargs: 1 + kwargs: + DEPENDENCIES: + + HEADERS: + enable_iwyu: pargs: flags: - - NO_FORWARD_DECLARATIONS - - QUOTED_INCLUDES_FIRST - - NO_COMMENTS + - NO_FORWARD_DECLARATIONS + - QUOTED_INCLUDES_FIRST + - NO_COMMENTS kwargs: MAPPING_FILE: 1 MAX_LINE_LENGTH: 1 diff --git a/cmake/TestHeaders.cmake b/cmake/TestHeaders.cmake index 663c9f4e..6ec30990 100644 --- a/cmake/TestHeaders.cmake +++ b/cmake/TestHeaders.cmake @@ -80,15 +80,18 @@ # If provided, the generated target is excluded from the 'all' target. # function(add_header_test target) - cmake_parse_arguments(ARGS "EXCLUDE_FROM_ALL" # options - "" # 1 value args - "HEADERS;EXCLUDE" # multivalued args - ${ARGN}) - if (NOT ARGS_HEADERS) + cmake_parse_arguments( + ARGS + "EXCLUDE_FROM_ALL" # options + "" # 1 value args + "HEADERS;EXCLUDE" # multivalued args + ${ARGN} + ) + if(NOT ARGS_HEADERS) message(FATAL_ERROR "The `HEADERS` argument must be provided.") endif() - if (ARGS_EXCLUDE_FROM_ALL) + if(ARGS_EXCLUDE_FROM_ALL) set(ARGS_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL") else() set(ARGS_EXCLUDE_FROM_ALL "") @@ -97,12 +100,12 @@ function(add_header_test target) foreach(header ${ARGS_HEADERS}) set(skip FALSE) foreach(exclude ${ARGS_EXCLUDE}) - if (${header} MATCHES ${exclude}) + if(${header} MATCHES ${exclude}) set(skip TRUE) break() endif() endforeach() - if (skip) + if(skip) continue() endif() @@ -110,19 +113,17 @@ function(add_header_test target) get_filename_component(directory "${header}" DIRECTORY) set(source "${CMAKE_CURRENT_BINARY_DIR}/headers/${directory}/${filename}.cpp") - if (NOT EXISTS "${source}") + if(NOT EXISTS "${source}") file(WRITE "${source}" "#include <${header}>") endif() list(APPEND sources "${source}") endforeach() set(standalone_main "${CMAKE_CURRENT_BINARY_DIR}/headers/_standalone_main.cpp") - if (NOT EXISTS "${standalone_main}") + if(NOT EXISTS "${standalone_main}") file(WRITE "${standalone_main}" "int main() { }") endif() - add_executable(${target} - ${ARGS_EXCLUDE_FROM_ALL} - ${sources} - "${CMAKE_CURRENT_BINARY_DIR}/headers/_standalone_main.cpp" + add_executable( + ${target} ${ARGS_EXCLUDE_FROM_ALL} ${sources} "${CMAKE_CURRENT_BINARY_DIR}/headers/_standalone_main.cpp" ) endfunction() diff --git a/cmake/TestPublicHeaders.cmake b/cmake/TestPublicHeaders.cmake index a1d3d4a8..e1756af5 100644 --- a/cmake/TestPublicHeaders.cmake +++ b/cmake/TestPublicHeaders.cmake @@ -65,4 +65,3 @@ function(add_public_header_test target test_target) target_link_libraries(${target} PRIVATE ${test_target}) target_include_directories(${target} PRIVATE .) endfunction() - diff --git a/src/cmake/AddUnitsModule.cmake b/src/cmake/AddUnitsModule.cmake index 2f92d92b..7e52697b 100644 --- a/src/cmake/AddUnitsModule.cmake +++ b/src/cmake/AddUnitsModule.cmake @@ -24,8 +24,7 @@ cmake_minimum_required(VERSION 3.19) function(validate_unparsed module prefix) if(${prefix}_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Invalid arguments '${${prefix}_UNPARSED_ARGUMENTS}' " - "for module '${module}'") + message(FATAL_ERROR "Invalid arguments '${${prefix}_UNPARSED_ARGUMENTS}' " "for module '${module}'") endif() endfunction() @@ -49,11 +48,7 @@ endfunction() function(add_units_module name) # parse arguments set(multiValues DEPENDENCIES HEADERS) - cmake_parse_arguments( - PARSE_ARGV 1 - ARG - "" "" "${multiValues}" - ) + cmake_parse_arguments(PARSE_ARGV 1 ARG "" "" "${multiValues}") # validate and process arguments validate_unparsed(${name} ARG) diff --git a/src/core-fmt/CMakeLists.txt b/src/core-fmt/CMakeLists.txt index 57212995..d88d23f4 100644 --- a/src/core-fmt/CMakeLists.txt +++ b/src/core-fmt/CMakeLists.txt @@ -25,12 +25,7 @@ cmake_minimum_required(VERSION 3.19) option(${projectPrefix}USE_LIBFMT "Enables usage of libfmt instead of the one from 'std'" ON) message(STATUS "${projectPrefix}USE_LIBFMT: ${${projectPrefix}USE_LIBFMT}") -add_units_module(core-fmt - DEPENDENCIES - mp-units::core - HEADERS - include/units/format.h -) +add_units_module(core-fmt DEPENDENCIES mp-units::core HEADERS include/units/format.h) target_compile_definitions(mp-units-core-fmt INTERFACE ${projectPrefix}USE_LIBFMT=$) if(${projectPrefix}USE_LIBFMT) diff --git a/src/core-io/CMakeLists.txt b/src/core-io/CMakeLists.txt index 6faab9ff..de797acf 100644 --- a/src/core-io/CMakeLists.txt +++ b/src/core-io/CMakeLists.txt @@ -22,9 +22,4 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(core-io - DEPENDENCIES - mp-units::core - HEADERS - include/units/quantity_io.h -) +add_units_module(core-io DEPENDENCIES mp-units::core HEADERS include/units/quantity_io.h) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cdc1eb36..431f258a 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -34,7 +34,9 @@ include(CheckLibcxxInUse) check_libcxx_in_use(${projectPrefix}LIBCXX) # core library definition -add_library(mp-units-core INTERFACE +add_library( + mp-units-core + INTERFACE include/units/base_dimension.h include/units/chrono.h include/units/concepts.h diff --git a/src/systems/isq-iec80000/CMakeLists.txt b/src/systems/isq-iec80000/CMakeLists.txt index 84e8f8d7..b2caa696 100644 --- a/src/systems/isq-iec80000/CMakeLists.txt +++ b/src/systems/isq-iec80000/CMakeLists.txt @@ -22,14 +22,10 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(isq-iec80000 - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/iec80000/binary_prefixes.h - include/units/isq/iec80000/iec80000.h - include/units/isq/iec80000/modulation_rate.h - include/units/isq/iec80000/storage_capacity.h - include/units/isq/iec80000/traffic_intensity.h - include/units/isq/iec80000/transfer_rate.h +add_units_module( + isq-iec80000 + DEPENDENCIES mp-units::si + HEADERS include/units/isq/iec80000/binary_prefixes.h include/units/isq/iec80000/iec80000.h + include/units/isq/iec80000/modulation_rate.h include/units/isq/iec80000/storage_capacity.h + include/units/isq/iec80000/traffic_intensity.h include/units/isq/iec80000/transfer_rate.h ) diff --git a/src/systems/isq-natural/CMakeLists.txt b/src/systems/isq-natural/CMakeLists.txt index b88038ce..e968bdff 100644 --- a/src/systems/isq-natural/CMakeLists.txt +++ b/src/systems/isq-natural/CMakeLists.txt @@ -22,19 +22,18 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(isq-natural - DEPENDENCIES - mp-units::isq - HEADERS - include/units/isq/natural/acceleration.h - include/units/isq/natural/constants.h - include/units/isq/natural/energy.h - include/units/isq/natural/force.h - include/units/isq/natural/length.h - include/units/isq/natural/mass.h - include/units/isq/natural/momentum.h - include/units/isq/natural/natural.h - include/units/isq/natural/speed.h - include/units/isq/natural/time.h - include/units/isq/natural/units.h +add_units_module( + isq-natural + DEPENDENCIES mp-units::isq + HEADERS include/units/isq/natural/acceleration.h + include/units/isq/natural/constants.h + include/units/isq/natural/energy.h + include/units/isq/natural/force.h + include/units/isq/natural/length.h + include/units/isq/natural/mass.h + include/units/isq/natural/momentum.h + include/units/isq/natural/natural.h + include/units/isq/natural/speed.h + include/units/isq/natural/time.h + include/units/isq/natural/units.h ) diff --git a/src/systems/isq/CMakeLists.txt b/src/systems/isq/CMakeLists.txt index 960a0114..c7dffcfc 100644 --- a/src/systems/isq/CMakeLists.txt +++ b/src/systems/isq/CMakeLists.txt @@ -22,53 +22,52 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(isq - DEPENDENCIES - mp-units::core - HEADERS - include/units/isq/dimensions/absorbed_dose.h - include/units/isq/dimensions/acceleration.h - include/units/isq/dimensions/amount_of_substance.h - include/units/isq/dimensions/angular_velocity.h - include/units/isq/dimensions/area.h - include/units/isq/dimensions/capacitance.h - include/units/isq/dimensions/catalytic_activity.h - include/units/isq/dimensions/charge_density.h - include/units/isq/dimensions/concentration.h - include/units/isq/dimensions/conductance.h - include/units/isq/dimensions/current_density.h - include/units/isq/dimensions/density.h - include/units/isq/dimensions/dynamic_viscosity.h - include/units/isq/dimensions/electric_charge.h - include/units/isq/dimensions/electric_current.h - include/units/isq/dimensions/electric_field_strength.h - include/units/isq/dimensions/energy.h - include/units/isq/dimensions/energy_density.h - include/units/isq/dimensions/force.h - include/units/isq/dimensions/frequency.h - include/units/isq/dimensions/heat_capacity.h - include/units/isq/dimensions/inductance.h - include/units/isq/dimensions/length.h - include/units/isq/dimensions/luminance.h - include/units/isq/dimensions/luminous_intensity.h - include/units/isq/dimensions/magnetic_flux.h - include/units/isq/dimensions/magnetic_induction.h - include/units/isq/dimensions/mass.h - include/units/isq/dimensions/molar_energy.h - include/units/isq/dimensions/momentum.h - include/units/isq/dimensions/permeability.h - include/units/isq/dimensions/permittivity.h - include/units/isq/dimensions/power.h - include/units/isq/dimensions/pressure.h - include/units/isq/dimensions/radioactivity.h - include/units/isq/dimensions/resistance.h - include/units/isq/dimensions/speed.h - include/units/isq/dimensions/surface_tension.h - include/units/isq/dimensions/thermal_conductivity.h - include/units/isq/dimensions/thermodynamic_temperature.h - include/units/isq/dimensions/time.h - include/units/isq/dimensions/torque.h - include/units/isq/dimensions/voltage.h - include/units/isq/dimensions/volume.h - include/units/isq/dimensions.h +add_units_module( + isq + DEPENDENCIES mp-units::core + HEADERS include/units/isq/dimensions/absorbed_dose.h + include/units/isq/dimensions/acceleration.h + include/units/isq/dimensions/amount_of_substance.h + include/units/isq/dimensions/angular_velocity.h + include/units/isq/dimensions/area.h + include/units/isq/dimensions/capacitance.h + include/units/isq/dimensions/catalytic_activity.h + include/units/isq/dimensions/charge_density.h + include/units/isq/dimensions/concentration.h + include/units/isq/dimensions/conductance.h + include/units/isq/dimensions/current_density.h + include/units/isq/dimensions/density.h + include/units/isq/dimensions/dynamic_viscosity.h + include/units/isq/dimensions/electric_charge.h + include/units/isq/dimensions/electric_current.h + include/units/isq/dimensions/electric_field_strength.h + include/units/isq/dimensions/energy.h + include/units/isq/dimensions/energy_density.h + include/units/isq/dimensions/force.h + include/units/isq/dimensions/frequency.h + include/units/isq/dimensions/heat_capacity.h + include/units/isq/dimensions/inductance.h + include/units/isq/dimensions/length.h + include/units/isq/dimensions/luminance.h + include/units/isq/dimensions/luminous_intensity.h + include/units/isq/dimensions/magnetic_flux.h + include/units/isq/dimensions/magnetic_induction.h + include/units/isq/dimensions/mass.h + include/units/isq/dimensions/molar_energy.h + include/units/isq/dimensions/momentum.h + include/units/isq/dimensions/permeability.h + include/units/isq/dimensions/permittivity.h + include/units/isq/dimensions/power.h + include/units/isq/dimensions/pressure.h + include/units/isq/dimensions/radioactivity.h + include/units/isq/dimensions/resistance.h + include/units/isq/dimensions/speed.h + include/units/isq/dimensions/surface_tension.h + include/units/isq/dimensions/thermal_conductivity.h + include/units/isq/dimensions/thermodynamic_temperature.h + include/units/isq/dimensions/time.h + include/units/isq/dimensions/torque.h + include/units/isq/dimensions/voltage.h + include/units/isq/dimensions/volume.h + include/units/isq/dimensions.h ) diff --git a/src/systems/si-cgs/CMakeLists.txt b/src/systems/si-cgs/CMakeLists.txt index 5a1cb20a..08316c20 100644 --- a/src/systems/si-cgs/CMakeLists.txt +++ b/src/systems/si-cgs/CMakeLists.txt @@ -22,19 +22,18 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si-cgs - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/si/cgs/acceleration.h - include/units/isq/si/cgs/area.h - include/units/isq/si/cgs/cgs.h - include/units/isq/si/cgs/energy.h - include/units/isq/si/cgs/force.h - include/units/isq/si/cgs/length.h - include/units/isq/si/cgs/mass.h - include/units/isq/si/cgs/power.h - include/units/isq/si/cgs/pressure.h - include/units/isq/si/cgs/speed.h - include/units/isq/si/cgs/time.h +add_units_module( + si-cgs + DEPENDENCIES mp-units::si + HEADERS include/units/isq/si/cgs/acceleration.h + include/units/isq/si/cgs/area.h + include/units/isq/si/cgs/cgs.h + include/units/isq/si/cgs/energy.h + include/units/isq/si/cgs/force.h + include/units/isq/si/cgs/length.h + include/units/isq/si/cgs/mass.h + include/units/isq/si/cgs/power.h + include/units/isq/si/cgs/pressure.h + include/units/isq/si/cgs/speed.h + include/units/isq/si/cgs/time.h ) diff --git a/src/systems/si-fps/CMakeLists.txt b/src/systems/si-fps/CMakeLists.txt index 12f9bd9e..983a54db 100644 --- a/src/systems/si-fps/CMakeLists.txt +++ b/src/systems/si-fps/CMakeLists.txt @@ -22,22 +22,20 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si-fps - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/si/fps/acceleration.h - include/units/isq/si/fps/area.h - include/units/isq/si/fps/density.h - include/units/isq/si/fps/energy.h - include/units/isq/si/fps/force.h - include/units/isq/si/fps/fps.h - include/units/isq/si/fps/length.h - include/units/isq/si/fps/mass.h - include/units/isq/si/fps/power.h - include/units/isq/si/fps/pressure.h - include/units/isq/si/fps/speed.h - include/units/isq/si/fps/time.h - include/units/isq/si/fps/volume.h +add_units_module( + si-fps + DEPENDENCIES mp-units::si + HEADERS include/units/isq/si/fps/acceleration.h + include/units/isq/si/fps/area.h + include/units/isq/si/fps/density.h + include/units/isq/si/fps/energy.h + include/units/isq/si/fps/force.h + include/units/isq/si/fps/fps.h + include/units/isq/si/fps/length.h + include/units/isq/si/fps/mass.h + include/units/isq/si/fps/power.h + include/units/isq/si/fps/pressure.h + include/units/isq/si/fps/speed.h + include/units/isq/si/fps/time.h + include/units/isq/si/fps/volume.h ) - diff --git a/src/systems/si-hep/CMakeLists.txt b/src/systems/si-hep/CMakeLists.txt index 66747172..635d2981 100644 --- a/src/systems/si-hep/CMakeLists.txt +++ b/src/systems/si-hep/CMakeLists.txt @@ -22,13 +22,8 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si-hep - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/si/hep/area.h - include/units/isq/si/hep/energy.h - include/units/isq/si/hep/hep.h - include/units/isq/si/hep/mass.h - include/units/isq/si/hep/momentum.h +add_units_module( + si-hep DEPENDENCIES mp-units::si + HEADERS include/units/isq/si/hep/area.h include/units/isq/si/hep/energy.h include/units/isq/si/hep/hep.h + include/units/isq/si/hep/mass.h include/units/isq/si/hep/momentum.h ) diff --git a/src/systems/si-iau/CMakeLists.txt b/src/systems/si-iau/CMakeLists.txt index 2677a344..7e86c0d2 100644 --- a/src/systems/si-iau/CMakeLists.txt +++ b/src/systems/si-iau/CMakeLists.txt @@ -22,10 +22,6 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si-iau - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/si/iau/iau.h - include/units/isq/si/iau/length.h +add_units_module( + si-iau DEPENDENCIES mp-units::si HEADERS include/units/isq/si/iau/iau.h include/units/isq/si/iau/length.h ) diff --git a/src/systems/si-imperial/CMakeLists.txt b/src/systems/si-imperial/CMakeLists.txt index ac903b82..3a441611 100644 --- a/src/systems/si-imperial/CMakeLists.txt +++ b/src/systems/si-imperial/CMakeLists.txt @@ -22,10 +22,7 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si-imperial - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/si/imperial/imperial.h - include/units/isq/si/imperial/length.h +add_units_module( + si-imperial DEPENDENCIES mp-units::si HEADERS include/units/isq/si/imperial/imperial.h + include/units/isq/si/imperial/length.h ) diff --git a/src/systems/si-international/CMakeLists.txt b/src/systems/si-international/CMakeLists.txt index b62cd360..82c940fd 100644 --- a/src/systems/si-international/CMakeLists.txt +++ b/src/systems/si-international/CMakeLists.txt @@ -22,14 +22,10 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si-international - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/si/international/area.h - include/units/isq/si/international/international.h - include/units/isq/si/international/length.h - include/units/isq/si/international/speed.h - include/units/isq/si/international/volume.h +add_units_module( + si-international + DEPENDENCIES mp-units::si + HEADERS include/units/isq/si/international/area.h include/units/isq/si/international/international.h + include/units/isq/si/international/length.h include/units/isq/si/international/speed.h + include/units/isq/si/international/volume.h ) - diff --git a/src/systems/si-typographic/CMakeLists.txt b/src/systems/si-typographic/CMakeLists.txt index e8d17a84..7e359ea2 100644 --- a/src/systems/si-typographic/CMakeLists.txt +++ b/src/systems/si-typographic/CMakeLists.txt @@ -22,11 +22,7 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si-typographic - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/si/typographic/length.h - include/units/isq/si/typographic/typographic.h +add_units_module( + si-typographic DEPENDENCIES mp-units::si HEADERS include/units/isq/si/typographic/length.h + include/units/isq/si/typographic/typographic.h ) - diff --git a/src/systems/si-uscs/CMakeLists.txt b/src/systems/si-uscs/CMakeLists.txt index 4bce00eb..1a10f79e 100644 --- a/src/systems/si-uscs/CMakeLists.txt +++ b/src/systems/si-uscs/CMakeLists.txt @@ -22,11 +22,6 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si-uscs - DEPENDENCIES - mp-units::si - HEADERS - include/units/isq/si/uscs/length.h - include/units/isq/si/uscs/uscs.h +add_units_module( + si-uscs DEPENDENCIES mp-units::si HEADERS include/units/isq/si/uscs/length.h include/units/isq/si/uscs/uscs.h ) - diff --git a/src/systems/si/CMakeLists.txt b/src/systems/si/CMakeLists.txt index 5fd34835..f591c780 100644 --- a/src/systems/si/CMakeLists.txt +++ b/src/systems/si/CMakeLists.txt @@ -22,55 +22,54 @@ cmake_minimum_required(VERSION 3.19) -add_units_module(si - DEPENDENCIES - mp-units::isq - HEADERS - include/units/isq/si/absorbed_dose.h - include/units/isq/si/acceleration.h - include/units/isq/si/amount_of_substance.h - include/units/isq/si/angular_velocity.h - include/units/isq/si/area.h - include/units/isq/si/capacitance.h - include/units/isq/si/catalytic_activity.h - include/units/isq/si/charge_density.h - include/units/isq/si/concentration.h - include/units/isq/si/conductance.h - include/units/isq/si/constants.h - include/units/isq/si/current_density.h - include/units/isq/si/density.h - include/units/isq/si/dynamic_viscosity.h - include/units/isq/si/electric_charge.h - include/units/isq/si/electric_current.h - include/units/isq/si/electric_field_strength.h - include/units/isq/si/energy.h - include/units/isq/si/energy_density.h - include/units/isq/si/force.h - include/units/isq/si/frequency.h - include/units/isq/si/heat_capacity.h - include/units/isq/si/inductance.h - include/units/isq/si/length.h - include/units/isq/si/luminance.h - include/units/isq/si/luminous_intensity.h - include/units/isq/si/magnetic_flux.h - include/units/isq/si/magnetic_induction.h - include/units/isq/si/mass.h - include/units/isq/si/molar_energy.h - include/units/isq/si/momentum.h - include/units/isq/si/permeability.h - include/units/isq/si/permittivity.h - include/units/isq/si/power.h - include/units/isq/si/prefixes.h - include/units/isq/si/pressure.h - include/units/isq/si/radioactivity.h - include/units/isq/si/resistance.h - include/units/isq/si/si.h - include/units/isq/si/speed.h - include/units/isq/si/surface_tension.h - include/units/isq/si/thermal_conductivity.h - include/units/isq/si/thermodynamic_temperature.h - include/units/isq/si/time.h - include/units/isq/si/torque.h - include/units/isq/si/voltage.h - include/units/isq/si/volume.h +add_units_module( + si + DEPENDENCIES mp-units::isq + HEADERS include/units/isq/si/absorbed_dose.h + include/units/isq/si/acceleration.h + include/units/isq/si/amount_of_substance.h + include/units/isq/si/angular_velocity.h + include/units/isq/si/area.h + include/units/isq/si/capacitance.h + include/units/isq/si/catalytic_activity.h + include/units/isq/si/charge_density.h + include/units/isq/si/concentration.h + include/units/isq/si/conductance.h + include/units/isq/si/constants.h + include/units/isq/si/current_density.h + include/units/isq/si/density.h + include/units/isq/si/dynamic_viscosity.h + include/units/isq/si/electric_charge.h + include/units/isq/si/electric_current.h + include/units/isq/si/electric_field_strength.h + include/units/isq/si/energy.h + include/units/isq/si/energy_density.h + include/units/isq/si/force.h + include/units/isq/si/frequency.h + include/units/isq/si/heat_capacity.h + include/units/isq/si/inductance.h + include/units/isq/si/length.h + include/units/isq/si/luminance.h + include/units/isq/si/luminous_intensity.h + include/units/isq/si/magnetic_flux.h + include/units/isq/si/magnetic_induction.h + include/units/isq/si/mass.h + include/units/isq/si/molar_energy.h + include/units/isq/si/momentum.h + include/units/isq/si/permeability.h + include/units/isq/si/permittivity.h + include/units/isq/si/power.h + include/units/isq/si/prefixes.h + include/units/isq/si/pressure.h + include/units/isq/si/radioactivity.h + include/units/isq/si/resistance.h + include/units/isq/si/si.h + include/units/isq/si/speed.h + include/units/isq/si/surface_tension.h + include/units/isq/si/thermal_conductivity.h + include/units/isq/si/thermodynamic_temperature.h + include/units/isq/si/time.h + include/units/isq/si/torque.h + include/units/isq/si/voltage.h + include/units/isq/si/volume.h ) From 74056fd6daa90a35959c54534c14554188f14148 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 24 Apr 2022 22:57:34 +0200 Subject: [PATCH 34/50] build: `clang-tidy` is not ready yet to be officially enabled in the project --- CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbee492f..f0ca1045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,13 +57,6 @@ if(${projectPrefix}IWYU) endif() endif() -option(${projectPrefix}CLANG_TIDY "Enables clang-tidy" OFF) -if(${projectPrefix}CLANG_TIDY) - message(STATUS "Enabling clang-tidy") - set(CMAKE_CXX_CLANG_TIDY clang-tidy) - message(STATUS "Enabling clang-tidy - done") -endif() - #enable_clang_tidy() # add project code From 5d82969e0a2c7cd9faf0de7e4482839c40291494 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 26 Apr 2022 16:00:20 +0200 Subject: [PATCH 35/50] fix: enable SI prefixes for `Kelvin` Resolves #359 --- .../si/include/units/isq/si/thermodynamic_temperature.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/systems/si/include/units/isq/si/thermodynamic_temperature.h b/src/systems/si/include/units/isq/si/thermodynamic_temperature.h index 8989ca8d..04e81c35 100644 --- a/src/systems/si/include/units/isq/si/thermodynamic_temperature.h +++ b/src/systems/si/include/units/isq/si/thermodynamic_temperature.h @@ -29,11 +29,12 @@ #include // IWYU pragma: end_exports +#include #include namespace units::isq::si { -struct kelvin : named_unit {}; +struct kelvin : named_unit {}; struct dim_thermodynamic_temperature : isq::dim_thermodynamic_temperature {}; From 4361cb874e89776785be0149a2e17de1f0ef60aa Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 27 Apr 2022 19:32:21 +0200 Subject: [PATCH 36/50] fix: `hectare` definition fixed to be a prefixed version of `are` + other units Relates to #359 --- src/systems/si/include/units/isq/si/area.h | 42 +++++++++++++++++++++- test/unit_test/static/si_test.cpp | 9 +++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/systems/si/include/units/isq/si/area.h b/src/systems/si/include/units/isq/si/area.h index 98bcb87c..a321fdda 100644 --- a/src/systems/si/include/units/isq/si/area.h +++ b/src/systems/si/include/units/isq/si/area.h @@ -58,7 +58,11 @@ struct square_exametre : derived_unit {}; struct square_zettametre : derived_unit {}; struct square_yottametre : derived_unit {}; -struct hectare : alias_unit {}; +struct are : alias_unit {}; +struct centiare : prefixed_alias_unit {}; +struct deciare : prefixed_unit {}; +struct decare : prefixed_unit {}; +struct hectare : prefixed_alias_unit {}; template U, Representation Rep = double> using area = quantity; @@ -235,6 +239,38 @@ constexpr auto operator"" _q_Ym2(unsigned long long l) } constexpr auto operator"" _q_Ym2(long double l) { return area(l); } +// a +constexpr auto operator"" _q_a(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} +constexpr auto operator"" _q_a(long double l) { return area(l); } + +// ca +constexpr auto operator"" _q_ca(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} +constexpr auto operator"" _q_ca(long double l) { return area(l); } + +// da +constexpr auto operator"" _q_da(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} +constexpr auto operator"" _q_da(long double l) { return area(l); } + +// daa +constexpr auto operator"" _q_daa(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} +constexpr auto operator"" _q_daa(long double l) { return area(l); } + // ha constexpr auto operator"" _q_ha(unsigned long long l) { @@ -273,6 +309,10 @@ inline constexpr auto Em2 = reference{}; inline constexpr auto Zm2 = reference{}; inline constexpr auto Ym2 = reference{}; +inline constexpr auto a = reference{}; +inline constexpr auto ca = reference{}; +inline constexpr auto da = reference{}; +inline constexpr auto daa = reference{}; inline constexpr auto ha = reference{}; } // namespace area_references diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index a69c1f1b..5155f916 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -276,8 +276,17 @@ static_assert(10_q_m * 10_q_m == 100_q_m2); static_assert(100_q_m2 / 10_q_m == 10_q_m); static_assert(10_q_km * 10_q_km == 100_q_km2); static_assert(1_q_m2 == 10'000_q_cm2); + +static_assert(1_q_ca == 1_q_m2); +static_assert(1_q_da == 10_q_m2); +static_assert(1_q_a == 100_q_m2); +static_assert(1_q_daa == 1'000_q_m2); static_assert(1_q_ha == 10'000_q_m2); +static_assert(centiare::symbol == "ca"); +static_assert(deciare::symbol == "da"); +static_assert(are::symbol == "a"); +static_assert(decare::symbol == "daa"); static_assert(hectare::symbol == "ha"); static_assert(detail::unit_text() == basic_symbol_text("m²", "m^2")); From fbc6744bdbabb8e32e4d115474f9c7a6a499f579 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 27 Apr 2022 19:33:44 +0200 Subject: [PATCH 37/50] =?UTF-8?q?fix:=20`=CF=89`,=20`au`,=20and=20`Da`=20a?= =?UTF-8?q?llowed=20to=20have=20SI=20prefixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relates to #359 --- src/systems/si/include/units/isq/si/angular_velocity.h | 3 ++- src/systems/si/include/units/isq/si/length.h | 2 +- src/systems/si/include/units/isq/si/mass.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/systems/si/include/units/isq/si/angular_velocity.h b/src/systems/si/include/units/isq/si/angular_velocity.h index fbb6e5c6..0cbcf686 100644 --- a/src/systems/si/include/units/isq/si/angular_velocity.h +++ b/src/systems/si/include/units/isq/si/angular_velocity.h @@ -29,12 +29,13 @@ // IWYU pragma: end_exports #include +#include #include #include namespace units::isq::si { -struct radian_per_second : named_unit {}; +struct radian_per_second : named_unit {}; struct dim_angular_velocity : isq::dim_angular_velocity, dim_time> {}; diff --git a/src/systems/si/include/units/isq/si/length.h b/src/systems/si/include/units/isq/si/length.h index eee2c9d2..36022dbd 100644 --- a/src/systems/si/include/units/isq/si/length.h +++ b/src/systems/si/include/units/isq/si/length.h @@ -56,7 +56,7 @@ struct exametre : prefixed_unit {}; struct zettametre : prefixed_unit {}; struct yottametre : prefixed_unit {}; -struct astronomical_unit : named_scaled_unit {}; +struct astronomical_unit : named_scaled_unit {}; struct dim_length : isq::dim_length {}; diff --git a/src/systems/si/include/units/isq/si/mass.h b/src/systems/si/include/units/isq/si/mass.h index 620381b3..89776694 100644 --- a/src/systems/si/include/units/isq/si/mass.h +++ b/src/systems/si/include/units/isq/si/mass.h @@ -79,7 +79,7 @@ struct zettatonne : prefixed_unit {}; struct yottatonne : prefixed_unit {}; struct dalton : - named_scaled_unit {}; + named_scaled_unit {}; struct dim_mass : isq::dim_mass {}; From 6d6bf81003ef707e1c7b56bff27aebc921f395a8 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 5 May 2022 09:46:35 +0200 Subject: [PATCH 38/50] build(conan): Upgrading the recipe to Conan 2.0 --- conanfile.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/conanfile.py b/conanfile.py index 98add025..7a5b57f4 100644 --- a/conanfile.py +++ b/conanfile.py @@ -20,14 +20,14 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from conans import ConanFile, tools -from conans.tools import Version, check_min_cppstd +from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake -from conan.tools.files import copy -from conans.errors import ConanInvalidConfiguration +from conan.tools.files import copy, load, rmdir +from conan.tools.scm import Version +from conans.tools import get_env, check_min_cppstd # TODO replace with new tools for Conan 2.0 import os, re -required_conan_version = ">=1.44.0" +required_conan_version = ">=1.48.0" class MPUnitsConan(ConanFile): @@ -67,7 +67,7 @@ class MPUnitsConan(ConanFile): @property def _run_tests(self): - return tools.get_env("CONAN_RUN_TESTS", False) + return get_env("CONAN_RUN_TESTS", False) @property def _use_libfmt(self): @@ -93,7 +93,7 @@ class MPUnitsConan(ConanFile): return int(f"{compiler.version}0") def set_version(self): - content = tools.load(os.path.join(self.recipe_folder, "src/CMakeLists.txt")) + content = load(self, os.path.join(self.recipe_folder, "src/CMakeLists.txt")) version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) self.version = version.strip() @@ -164,7 +164,7 @@ class MPUnitsConan(ConanFile): copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): compiler = self.settings.compiler From 4adc71db56ed557996fe473f981ee6a7845451aa Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 5 May 2022 11:53:37 +0200 Subject: [PATCH 39/50] build(conan): `exports_sources` replaced with the `scm.Git` --- conanfile.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index 7a5b57f4..874852b9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -22,8 +22,8 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake -from conan.tools.files import copy, load, rmdir -from conan.tools.scm import Version +from conan.tools.files import copy, load, rmdir, update_conandata +from conan.tools.scm import Git, Version from conans.tools import get_env, check_min_cppstd # TODO replace with new tools for Conan 2.0 import os, re @@ -62,7 +62,6 @@ class MPUnitsConan(ConanFile): "build_docs": True } exports = ["LICENSE.md"] - exports_sources = ["docs/*", "src/*", "test/*", "cmake/*", "example/*", "CMakeLists.txt"] generators = "cmake_paths" @property @@ -140,6 +139,22 @@ class MPUnitsConan(ConanFile): # # build_docs has sense only in a development or CI build # del self.options.build_docs + def export(self): + git = Git(self, self.recipe_folder) + scm_url, scm_commit = git.get_url_and_commit() + # stores the current url and commit in conandata.yml + update_conandata(self, {"sources": {"commit": scm_commit, "url": scm_url}}) + + def layout(self): + self.folders.source = "." + + def source(self): + # recovers the saved url and commit from conandata.yml and use them to get sources + git = Git(self) + sources = self.conan_data["sources"] + git.clone(url=sources["url"], target=".") + git.checkout(commit=sources["commit"]) + def generate(self): tc = CMakeToolchain(self) tc.variables["UNITS_DOWNCAST_MODE"] = str(self.options.downcast_mode).upper() From 640fa670f874fb8077423b535e29af2762675794 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 5 May 2022 11:54:23 +0200 Subject: [PATCH 40/50] build(conan): `no_copy_source` attribute added --- conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/conanfile.py b/conanfile.py index 874852b9..c88ec456 100644 --- a/conanfile.py +++ b/conanfile.py @@ -62,6 +62,7 @@ class MPUnitsConan(ConanFile): "build_docs": True } exports = ["LICENSE.md"] + no_copy_source = True generators = "cmake_paths" @property From 0033319451f0dc812364ef96b288f2c99f45c770 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 5 May 2022 16:12:54 +0200 Subject: [PATCH 41/50] fix: shadowing compilation errors on MSVC fixed --- src/core/include/units/symbol_text.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/include/units/symbol_text.h b/src/core/include/units/symbol_text.h index 3af267a0..adf138e5 100644 --- a/src/core/include/units/symbol_text.h +++ b/src/core/include/units/symbol_text.h @@ -78,16 +78,16 @@ struct basic_symbol_text { { detail::validate_ascii_string(std.data_); } - constexpr basic_symbol_text(const StandardCharT (&std)[N + 1], const char (&a)[M + 1]) noexcept : - standard_(std), ascii_(a) + constexpr basic_symbol_text(const StandardCharT (&std)[N + 1], const char (&ascii)[M + 1]) noexcept : + standard_(std), ascii_(ascii) { - detail::validate_ascii_string(a); + detail::validate_ascii_string(ascii); } constexpr basic_symbol_text(const basic_fixed_string& std, - const basic_fixed_string& a) noexcept : - standard_(std), ascii_(a) + const basic_fixed_string& ascii) noexcept : + standard_(std), ascii_(ascii) { - detail::validate_ascii_string(a.data_); + detail::validate_ascii_string(ascii.data_); } [[nodiscard]] constexpr auto& standard() { return standard_; } From fde503202591a1cc03704b5ad73e926514269772 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 5 May 2022 19:18:19 +0200 Subject: [PATCH 42/50] Revert "build(conan): `exports_sources` replaced with the `scm.Git`" This reverts commit 4adc71db56ed557996fe473f981ee6a7845451aa. --- conanfile.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/conanfile.py b/conanfile.py index c88ec456..6eeb8e75 100644 --- a/conanfile.py +++ b/conanfile.py @@ -22,8 +22,8 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake -from conan.tools.files import copy, load, rmdir, update_conandata -from conan.tools.scm import Git, Version +from conan.tools.files import copy, load, rmdir +from conan.tools.scm import Version from conans.tools import get_env, check_min_cppstd # TODO replace with new tools for Conan 2.0 import os, re @@ -62,6 +62,7 @@ class MPUnitsConan(ConanFile): "build_docs": True } exports = ["LICENSE.md"] + exports_sources = ["docs/*", "src/*", "test/*", "cmake/*", "example/*", "CMakeLists.txt"] no_copy_source = True generators = "cmake_paths" @@ -140,22 +141,6 @@ class MPUnitsConan(ConanFile): # # build_docs has sense only in a development or CI build # del self.options.build_docs - def export(self): - git = Git(self, self.recipe_folder) - scm_url, scm_commit = git.get_url_and_commit() - # stores the current url and commit in conandata.yml - update_conandata(self, {"sources": {"commit": scm_commit, "url": scm_url}}) - - def layout(self): - self.folders.source = "." - - def source(self): - # recovers the saved url and commit from conandata.yml and use them to get sources - git = Git(self) - sources = self.conan_data["sources"] - git.clone(url=sources["url"], target=".") - git.checkout(commit=sources["commit"]) - def generate(self): tc = CMakeToolchain(self) tc.variables["UNITS_DOWNCAST_MODE"] = str(self.options.downcast_mode).upper() From ffa0f321f957f79f4bd7d3b237abd1f40e9b4ec0 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 6 May 2022 10:00:39 +0200 Subject: [PATCH 43/50] fix: shadowing compilation errors on MSVC fixed --- test/unit_test/static/quantity_test.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index 0f810ccf..fff7d9e4 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -275,11 +275,11 @@ struct derived_quantity : quantity static_assert(detail::is_quantity, "NTTP type description">>); constexpr isq::Length auto get_length_derived_quantity() noexcept { - derived_quantity, "NTTP type description"> a{}; - a += 1_q_m; - a = a + 1_q_m; - a *= 0.5; - return a; + derived_quantity, "NTTP type description"> dist{}; + dist += 1_q_m; + dist = dist + 1_q_m; + dist *= 0.5; + return dist; } static_assert(get_length_derived_quantity() == 1_q_m); From ba0e1c52b5d0d011461ec495259dd6cca847e5d2 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 6 May 2022 18:30:20 +0200 Subject: [PATCH 44/50] style: `ci-test-package-cmake.yml` reformatted --- .github/workflows/ci-test-package-cmake.yml | 105 +++++++++++--------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci-test-package-cmake.yml b/.github/workflows/ci-test-package-cmake.yml index 568083a7..68f02bd1 100644 --- a/.github/workflows/ci-test-package-cmake.yml +++ b/.github/workflows/ci-test-package-cmake.yml @@ -25,14 +25,14 @@ name: CMake Test Package CI on: push: paths-ignore: - - 'docs/**' - - 'example/**' - - 'test/**' + - "docs/**" + - "example/**" + - "test/**" pull_request: paths-ignore: - - 'docs/**' - - 'example/**' - - 'test/**' + - "docs/**" + - "example/**" + - "test/**" jobs: test_package: @@ -42,46 +42,55 @@ jobs: fail-fast: false matrix: config: - - { - name: "Windows MSVC 2019", - os: windows-latest, - compiler: { type: VISUAL, version: 16, cc: "", cxx: "" } - } - - { - name: "Ubuntu GCC 10.3.0", - os: ubuntu-20.04, - compiler: { type: GCC, version: 10, cc: "gcc-10", cxx: "g++-10" }, - lib: "libstdc++11" - } - - { - name: "Ubuntu GCC 11.1.0", - os: ubuntu-20.04, - compiler: { type: GCC, version: 11, cc: "gcc-11", cxx: "g++-11" }, - lib: "libstdc++11" - } - - { - name: "Ubuntu Clang 12.0.0 + libstdc++11", - os: ubuntu-20.04, - compiler: { type: CLANG, version: 12, cc: "clang-12", cxx: "clang++-12" }, - lib: "libstdc++11" - } - - { - name: "Ubuntu Clang 12.0.0 + libc++", - os: ubuntu-20.04, - compiler: { type: CLANG, version: 12, cc: "clang-12", cxx: "clang++-12" }, - lib: "libc++" - } - - { - name: "Ubuntu Clang 13.0.0 + libc++", - os: ubuntu-20.04, - compiler: { type: CLANG, version: 13, cc: "clang-13", cxx: "clang++-13" }, - lib: "libc++" - } - - { - name: "MacOS Apple Clang 13", - os: macos-11, - compiler: { type: APPLE_CLANG, version: "13.0", cc: "clang", cxx: "clang++" } - } + - { + name: "Windows MSVC 2019", + os: windows-latest, + compiler: { type: VISUAL, version: 16, cc: "", cxx: "" }, + } + - { + name: "Ubuntu GCC 10.3.0", + os: ubuntu-20.04, + compiler: { type: GCC, version: 10, cc: "gcc-10", cxx: "g++-10" }, + lib: "libstdc++11", + } + - { + name: "Ubuntu GCC 11.1.0", + os: ubuntu-20.04, + compiler: { type: GCC, version: 11, cc: "gcc-11", cxx: "g++-11" }, + lib: "libstdc++11", + } + - { + name: "Ubuntu Clang 12.0.0 + libstdc++11", + os: ubuntu-20.04, + compiler: + { type: CLANG, version: 12, cc: "clang-12", cxx: "clang++-12" }, + lib: "libstdc++11", + } + - { + name: "Ubuntu Clang 12.0.0 + libc++", + os: ubuntu-20.04, + compiler: + { type: CLANG, version: 12, cc: "clang-12", cxx: "clang++-12" }, + lib: "libc++", + } + - { + name: "Ubuntu Clang 13.0.0 + libc++", + os: ubuntu-20.04, + compiler: + { type: CLANG, version: 13, cc: "clang-13", cxx: "clang++-13" }, + lib: "libc++", + } + - { + name: "MacOS Apple Clang 13", + os: macos-11, + compiler: + { + type: APPLE_CLANG, + version: "13.0", + cc: "clang", + cxx: "clang++", + }, + } # In case a Conan docker image will be needed to provide a specific configuration we can use a Docker image as follows # - { # name: "Ubuntu GCC 10.2.0", @@ -89,7 +98,7 @@ jobs: # compiler: { type: GCC, version: 10, cc: "gcc-10", cxx: "g++-10" }, # docker_image: conanio/gcc10 # } - build_type: [ "Release", "Debug" ] + build_type: ["Release", "Debug"] env: CC: ${{ matrix.config.compiler.cc }} @@ -151,7 +160,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.8' + python-version: "3.8" - name: Install Conan shell: bash run: | From f8837de0cb2a200fa13e09b2177f52891fe5bf5a Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 6 May 2022 18:36:27 +0200 Subject: [PATCH 45/50] ci: Conan 1.48 does not set `CMAKE_BUILD_TYPE` in the `conan_toolchain.cmake` anymore --- .github/workflows/ci-test-package-cmake.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-test-package-cmake.yml b/.github/workflows/ci-test-package-cmake.yml index 68f02bd1..2337af7e 100644 --- a/.github/workflows/ci-test-package-cmake.yml +++ b/.github/workflows/ci-test-package-cmake.yml @@ -194,13 +194,13 @@ jobs: working-directory: build/${{ matrix.build_type }} run: | call conanvcvars.bat - cmake ../../src -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + cmake ../../src -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - name: Configure mp-units CMake if: matrix.config.compiler.type != 'VISUAL' shell: bash working-directory: build/${{ matrix.build_type }} run: | - cmake ../../src -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + cmake ../../src -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - name: Install mp-units shell: bash working-directory: build/${{ matrix.build_type }} @@ -217,14 +217,14 @@ jobs: working-directory: test_package/build/${{ matrix.build_type }} run: | call conanvcvars.bat - cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -Dmp-units_DIR=${{ github.workspace }}/build/${{ matrix.build_type }} + cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -Dmp-units_DIR=${{ github.workspace }}/build/${{ matrix.build_type }} cmake --build . - name: Build test_package CMake (local build) if: matrix.config.compiler.type != 'VISUAL' shell: bash working-directory: test_package/build/${{ matrix.build_type }} run: | - cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -Dmp-units_DIR=${{ github.workspace }}/build/${{ matrix.build_type }} + cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -Dmp-units_DIR=${{ github.workspace }}/build/${{ matrix.build_type }} cmake --build . - name: Build test_package CMake (installation) if: matrix.config.compiler.type == 'VISUAL' @@ -232,14 +232,14 @@ jobs: working-directory: test_package/build/${{ matrix.build_type }} run: | call conanvcvars.bat - cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_INSTALL_PREFIX=../../../build/${{ matrix.build_type }}/test_package + cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=../../../build/${{ matrix.build_type }}/test_package cmake --build . - name: Build test_package CMake (installation) if: matrix.config.compiler.type != 'VISUAL' shell: bash working-directory: test_package/build/${{ matrix.build_type }} run: | - cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_INSTALL_PREFIX=../../../build/${{ matrix.build_type }}/test_package + cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=../../../build/${{ matrix.build_type }}/test_package cmake --build . - name: Run test_package shell: bash From 75ca6f1aefc8c9be6e5f51dd1851e01500345daf Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 6 May 2022 18:40:03 +0200 Subject: [PATCH 46/50] docs: Conan 1.48 does not set `CMAKE_BUILD_TYPE` in the `conan_toolchain.cmake` anymore --- docs/usage.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index bc289de5..bde4ea77 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -294,7 +294,7 @@ library release the following steps may be performed: mkdir my_project/build && cd my_project/build conan install .. -pr -s compiler.cppstd=20 -b=missing - cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --build . @@ -345,7 +345,7 @@ differences: mkdir my_project/build && cd my_project/build conan install .. -pr -s compiler.cppstd=20 -b=outdated -u - cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --build . @@ -360,7 +360,7 @@ to find it, it is enough to perform the following steps: mkdir units/build && cd units/build conan install .. -pr -s compiler.cppstd=20 -b=missing - cmake ../src -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + cmake ../src -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --install . --prefix @@ -392,7 +392,7 @@ step with the CMake build: .. code-block:: shell # ... - cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --build . ctest From 8507ed1ae94ffd457c5973ad7d7baeb03cdad54e Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 9 May 2022 12:24:50 +0200 Subject: [PATCH 47/50] chore: `CMakeUserPresets.json` file should not be added to the repo --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 751b2745..a4547914 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,9 @@ /out/ _build/ +# CMake +CMakeUserPresets.json + # Conan *.pyc /test_package/build/ From a7f1817c9bbb12c6e6c6401c77ad9d07f0684b0d Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 9 May 2022 13:59:56 +0200 Subject: [PATCH 48/50] feat: SI prefixes allowed for a `yard` unit as at least `kiloyard` is used in some domains --- .../include/units/isq/si/international/length.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systems/si-international/include/units/isq/si/international/length.h b/src/systems/si-international/include/units/isq/si/international/length.h index e37944a0..ead14a46 100644 --- a/src/systems/si-international/include/units/isq/si/international/length.h +++ b/src/systems/si-international/include/units/isq/si/international/length.h @@ -37,7 +37,7 @@ namespace units::isq::si::international { // si::international yard // https://en.wikipedia.org/wiki/International_yard_and_pound -struct yard : named_scaled_unit {}; +struct yard : named_scaled_unit {}; // si::international foot // https://en.wikipedia.org/wiki/Foot_(unit)#International_foot From 8b52f46bed969abf8de3980f849b61e4a0d9d66d Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 9 May 2022 14:01:08 +0200 Subject: [PATCH 49/50] fix: `fps` can now coexist with `international` system Resolves #347 --- src/systems/si-fps/CMakeLists.txt | 2 +- .../si-fps/include/units/isq/si/fps/length.h | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/systems/si-fps/CMakeLists.txt b/src/systems/si-fps/CMakeLists.txt index 983a54db..ffd302de 100644 --- a/src/systems/si-fps/CMakeLists.txt +++ b/src/systems/si-fps/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.19) add_units_module( si-fps - DEPENDENCIES mp-units::si + DEPENDENCIES mp-units::si-international HEADERS include/units/isq/si/fps/acceleration.h include/units/isq/si/fps/area.h include/units/isq/si/fps/density.h diff --git a/src/systems/si-fps/include/units/isq/si/fps/length.h b/src/systems/si-fps/include/units/isq/si/fps/length.h index a4307180..c33819cd 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/length.h +++ b/src/systems/si-fps/include/units/isq/si/fps/length.h @@ -29,24 +29,21 @@ #include // IWYU pragma: end_exports -#include +#include #include namespace units::isq::si::fps { // https://en.wikipedia.org/wiki/Foot_(unit) -struct foot : named_scaled_unit {}; - -struct inch : named_scaled_unit {}; +using si::international::fathom; +using si::international::foot; +using si::international::inch; +using si::international::mil; +using si::international::thou; +using si::international::yard; // thousandth of an inch -struct thousandth : named_scaled_unit {}; -struct thou : alias_unit {}; -struct mil : alias_unit {}; - -struct yard : named_scaled_unit {}; - -struct fathom : named_scaled_unit {}; +struct thousandth : alias_unit {}; struct kiloyard : prefixed_unit {}; From 0b8e5c0dfe5b792fa94acd0cce69c965c961ad5a Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 9 May 2022 14:03:14 +0200 Subject: [PATCH 50/50] fix(example): `foot_pound_second` example now correctly uses `international::knot` which is typical for Marine industry Resolves #357 --- example/aliases/foot_pound_second.cpp | 7 ++++--- example/literals/foot_pound_second.cpp | 10 ++++++---- example/references/foot_pound_second.cpp | 10 ++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/example/aliases/foot_pound_second.cpp b/example/aliases/foot_pound_second.cpp index 12b1082d..8890a92f 100644 --- a/example/aliases/foot_pound_second.cpp +++ b/example/aliases/foot_pound_second.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +69,7 @@ void print_details(std::string_view description, const Ship& ship) << STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) << STD_FMT::format("{:20} : {}\n", "speed", - fmt_line, si::speed::km_per_h<>>(ship.speed)) + fmt_line, si::speed::km_per_h<>>(ship.speed)) << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) << STD_FMT::format("{:20} : {}\n", "main guns", fmt_line, si::length::mm<>>(ship.mainGuns)) @@ -101,7 +102,7 @@ int main() auto iowa = Ship{.length{ft<>(860.)}, .draft{ft<>(37.) + in<>(2.)}, .beam{ft<>(108.) + in<>(2.)}, - .speed{kn<>(33)}, + .speed{international::kn<>(33)}, .mass{lton<>(57'540)}, .mainGuns{in<>(16)}, .shellMass{lb<>(2700)}, @@ -112,7 +113,7 @@ int main() auto kgv = Ship{.length{ft<>(745.1)}, .draft{ft<>(33.) + in<>(7.5)}, .beam{ft<>(103.2) + in<>(2.5)}, - .speed{kn<>(28.3)}, + .speed{international::kn<>(28.3)}, .mass{lton<>(42'245)}, .mainGuns{in<>(14)}, .shellMass{lb<>(1'590)}, diff --git a/example/literals/foot_pound_second.cpp b/example/literals/foot_pound_second.cpp index 67d1d296..01f8d285 100644 --- a/example/literals/foot_pound_second.cpp +++ b/example/literals/foot_pound_second.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -73,8 +74,9 @@ void print_details(std::string_view description, const Ship& ship) fmt_line, si::length>(ship.beam)) << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass>(ship.mass)) - << STD_FMT::format("{:20} : {}\n", "speed", - fmt_line, si::speed>(ship.speed)) + << STD_FMT::format( + "{:20} : {}\n", "speed", + fmt_line, si::speed>(ship.speed)) << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power>(ship.power)) << STD_FMT::format("{:20} : {}\n", "main guns", @@ -108,7 +110,7 @@ int main() auto iowa = Ship{.length{860._q_ft}, .draft{37._q_ft + 2._q_in}, .beam{108._q_ft + 2._q_in}, - .speed{33_q_kn}, + .speed{si::speed{33}}, .mass{57'540_q_lton}, .mainGuns{16_q_in}, .shellMass{2700_q_lb}, @@ -119,7 +121,7 @@ int main() auto kgv = Ship{.length{745.1_q_ft}, .draft{33._q_ft + 7.5_q_in}, .beam{103.2_q_ft + 2.5_q_in}, - .speed{28.3_q_kn}, + .speed{si::speed{28.3}}, .mass{42'245_q_lton}, .mainGuns{14_q_in}, .shellMass{1'590_q_lb}, diff --git a/example/references/foot_pound_second.cpp b/example/references/foot_pound_second.cpp index ca1f5447..0833fa6b 100644 --- a/example/references/foot_pound_second.cpp +++ b/example/references/foot_pound_second.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -76,8 +77,9 @@ void print_details(std::string_view description, const Ship& ship) fmt_line, si::length>(ship.beam)) << STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass>(ship.mass)) - << STD_FMT::format("{:20} : {}\n", "speed", - fmt_line, si::speed>(ship.speed)) + << STD_FMT::format( + "{:20} : {}\n", "speed", + fmt_line, si::speed>(ship.speed)) << STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power>(ship.power)) << STD_FMT::format("{:20} : {}\n", "main guns", @@ -112,7 +114,7 @@ int main() auto iowa = Ship{.length{860. * ft}, .draft{37. * ft + 2. * in}, .beam{108. * ft + 2. * in}, - .speed{33 * kn}, + .speed{33 * units::isq::si::international::references::kn}, .mass{57'540 * lton}, .mainGuns{16 * in}, .shellMass{2700 * lb}, @@ -123,7 +125,7 @@ int main() auto kgv = Ship{.length{745.1 * ft}, .draft{33. * ft + 7.5 * in}, .beam{103.2 * ft + 2.5 * in}, - .speed{28.3 * kn}, + .speed{28.3 * units::isq::si::international::references::kn}, .mass{42'245 * lton}, .mainGuns{14 * in}, .shellMass{1'590 * lb},