diff --git a/.cppcheck.suppress b/.cppcheck.suppress index 935ac34..e0e3a7f 100644 --- a/.cppcheck.suppress +++ b/.cppcheck.suppress @@ -1,2 +1 @@ -unusedFunction -unusedStructMember \ No newline at end of file +unusedFunction \ No newline at end of file diff --git a/.devops.toml b/.devops.toml new file mode 100644 index 0000000..de78e83 --- /dev/null +++ b/.devops.toml @@ -0,0 +1,24 @@ +# DevOps Configuration File + +[exclude] +buggy_cpp_macros = ["MSTD_WARN_BUGGY_HEADER", "MSTD_WARN_BUGGY_LIBRARY"] + +[logging] +#global_level = "INFO" +#utils_level = "INFO" +#config_level = "INFO" +#cpp_level = "INFO" + +[git] +#tag_prefix = "" +#empty_tag_list_allowed = true + +[cpp] +#style_checks = true +#license_header_check = true +#check_only_staged_files = false +license_header = "config/licenseHeader.txt" +header_guards_according_to_filepath = true + +[file] +#encoding = "utf-8" diff --git a/.github/workflows/check-pr-for-release-version.yml b/.github/workflows/check-pr-for-release-version.yml index f233790..2030833 100644 --- a/.github/workflows/check-pr-for-release-version.yml +++ b/.github/workflows/check-pr-for-release-version.yml @@ -11,20 +11,31 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check PR Title or Description + - name: Check PR Title, Description, or Hotfix Branch run: | title="${{ github.event.pull_request.title }}" body="${{ github.event.pull_request.body }}" - echo "Checking PR title: $title" - echo "Checking PR body: $body" + head_ref="${{ github.head_ref }}" - # Regex: Release-x.y.z (case-insensitive, numeric x, y, z of variable length) + echo "PR title: $title" + echo "PR body: $body" + echo "PR source branch: $head_ref" + + # Allow hotfix branches unconditionally + if [[ "$head_ref" == hotfix/* ]]; then + echo "✅ Hotfix branch detected ($head_ref). Skipping release pattern check." + exit 0 + fi + + # Regex: Release-x.y.z (case-insensitive) regex='[Rr][Ee][Ll][Ee][Aa][Ss][Ee]-[0-9]+\.[0-9]+\.[0-9]+' if [[ "$title" =~ $regex ]] || [[ "$body" =~ $regex ]]; then echo "✅ Found valid Release pattern in title or description." exit 0 else - echo "❌ Invalid PR. Title or description must contain: Release-x.y.z (e.g., Release-1.2.3)" + echo "❌ Invalid PR." + echo " Title or description must contain: Release-x.y.z (e.g., Release-1.2.3)" + echo " OR the branch must start with: hotfix/" exit 1 fi diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 3df9dff..46bdd52 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -22,12 +22,44 @@ jobs: fetch-depth: 0 submodules: recursive - - name: Extract release version from PR + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.13 + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e external/devops + + - name: Extract release version (Release-x.y.z OR hotfix bump) id: extract_version + shell: bash run: | + set -euo pipefail + title="${{ github.event.pull_request.title }}" body="${{ github.event.pull_request.body }}" + head_ref="${{ github.head_ref }}" # PR source branch name, e.g. hotfix/... + + echo "PR source branch: $head_ref" + echo "PR title: $title" + + # Hotfix: version = latest tag + 1 in patch + if [[ "$head_ref" == hotfix/* ]]; then + echo "✅ Hotfix PR detected. Deducing version from latest tag + patch bump..." + git fetch --tags --force + + version="$(increase_latest_tag --patch)" + + echo "✅ Hotfix release version: $version" + echo "version=$version" >> "$GITHUB_OUTPUT" + exit 0 + fi + + # Non-hotfix: expect Release-x.y.z in title/body regex='[Rr][Ee][Ll][Ee][Aa][Ss][Ee]-([0-9]+\.[0-9]+\.[0-9]+)' if [[ "$title" =~ $regex ]]; then @@ -36,16 +68,18 @@ jobs: version="${BASH_REMATCH[1]}" else echo "❌ No valid release version found in PR title or description." + echo " Expected: Release-x.y.z (e.g., Release-1.2.3)" + echo " Or use a hotfix/* branch to auto-bump patch." exit 1 fi echo "✅ Found release version: $version" - echo "version=$version" >> $GITHUB_OUTPUT + echo "version=$version" >> "$GITHUB_OUTPUT" - name: Update CHANGELOG.md run: | version="${{ steps.extract_version.outputs.version }}" - python3 scripts/update_changelog.py "$version" + update_changelog "$version" - name: Commit and push changelog update run: | @@ -54,16 +88,21 @@ jobs: git config user.email "github-actions[bot]@users.noreply.github.com" git add CHANGELOG.md - git commit -m "docs: update changelog for $version" + git commit -m "docs: update changelog for $version" || echo "No changes to commit" git push origin HEAD:main - name: Create Git tag - id: create_tag run: | version="${{ steps.extract_version.outputs.version }}" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + # Safety: don't fail if tag already exists (e.g., re-runs) + if git rev-parse -q --verify "refs/tags/$version" >/dev/null; then + echo "Tag $version already exists. Skipping tag creation." + exit 0 + fi + git tag "$version" git push origin "$version" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..e04fb32 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,35 @@ +name: DOCS + +on: + pull_request: + branches: + - '*' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive # ✅ ensure Catch2 is pulled in + + - name: Install gcc14 + run: | + sudo apt update + sudo apt install -y gcc-14 g++-14 + shell: bash + + - name: Install Doxygen + run: | + sudo apt update + sudo apt install -y doxygen + + - name: Build and Test Project + run: | + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMSTD_BUILD_DOCS=ON + make docs # at the moment only building docs to verify no doc-related build issues + env: + CC: gcc-14 + CXX: g++-14 \ No newline at end of file diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..20707ca --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,60 @@ +name: Static Analysis + +on: + pull_request: + branches: + - '*' + workflow_dispatch: + +permissions: + contents: read + +jobs: + cppcheck: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install cppcheck + run: | + sudo apt update + sudo apt install -y cppcheck + + - name: Run cppcheck + run: | + cppcheck --enable=all \ + --enable=performance \ + --enable=style \ + --enable=information \ + --enable=portability \ + --error-exitcode=1 \ + --suppressions-list=.cppcheck.suppress \ + --suppress=missingIncludeSystem \ + --inline-suppr \ + --inconclusive \ + -I include \ + include test + + clang-tidy: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.13 + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e external/devops + + - name: Install clang-tidy and dependencies + run: | + cpp_checks --dirs include --dirs test \ No newline at end of file diff --git a/.gitignore b/.gitignore index ce61daa..32cd6fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ .build build .cache +checks.egg-info/ +__pycache__/ +.venv +docs/output/ +compile_commands.json diff --git a/.gitmodules b/.gitmodules index d8dc293..b4143bd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "external/Catch2"] path = external/Catch2 url = https://github.com/catchorg/Catch2 +[submodule "external/devops"] + path = external/devops + url = https://github.com/97gamjak/devops diff --git a/.vscode/settings.json b/.vscode/settings.json index b376aa1..3aabd6d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -108,6 +108,12 @@ "__nullptr": "cpp", "csignal": "cpp", "list": "cpp", - "text_encoding": "cpp" + "text_encoding": "cpp", + "__locale": "cpp", + "__hash_table": "cpp", + "__split_buffer": "cpp", + "__tree": "cpp", + "queue": "cpp", + "stack": "cpp" }, } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ca54ad6..9f8dd22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,32 @@ All notable changes to this project will be documented in this file. ## Next Release +### CI + +- Add devops python library first version for all kind of custom static code analysis +- Add `update_changelog` from devops package to create_tag CI +- Add hotfix branch release handling to auto increment version patch aka `major.minor.patch` + +### Error Handling + +- Add compile time warning macros for buggy libraries and buggy headers (used atm in quantity lib as long as it is not fixed) + +### Compilation + +- Add Compile flag `MSTD_IGNORE_BUGGY_CODE` to ignore any kind of warnings for buggy libraries or headers +- Add exhaustive error flags for compilation +- Add checking of doxygen comments via building docs (no docs is building for gh pages - yet) + +### Cleanup + +- Cleanup header guards to follow common rule with folder and file structure + +### Enums + +- Introduce type traits for mstd enums: `using EnumMeta = typename enum_meta::type` +- Make `EnumMeta::index` return std::optional instead of -1 in case of error +- Add a `values_view` to `EnumMeta` returning a `std::span` for having a nicer API in special cases + ## [0.0.2](https://github.com/97gamjak/mstd/releases/tag/0.0.2) - 2025-11-20 diff --git a/CMakeLists.txt b/CMakeLists.txt index c263e94..59ab53c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ project(mstd ) option(MSTD_BUILD_TESTS "Build mstd test" ON) +option(MSTD_BUILD_DOCS "Build mstd documentation" OFF) add_library(mstd INTERFACE) target_include_directories(mstd @@ -21,6 +22,40 @@ target_compile_features(mstd cxx_std_20 ) +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(mstd INTERFACE + -Wall + -Wextra + -Wpedantic + -Werror + + # correctness + -Wshadow + -Wconversion + -Wsign-conversion + -Wcast-align + -Wformat=2 + -Wnull-dereference + -Wdouble-promotion + -Wimplicit-fallthrough + -Woverloaded-virtual + -Wnon-virtual-dtor + -Wold-style-cast + -Wuseless-cast + -Wduplicated-cond + -Wduplicated-branches + -Wlogical-op + -Wmisleading-indentation + + # lifetime / safety + -Wuninitialized + -Wmaybe-uninitialized + -Winit-self + + -Wno-error=deprecated-declarations + ) +endif() + if(MSTD_BUILD_TESTS) include(CTest) enable_testing() @@ -28,3 +63,17 @@ if(MSTD_BUILD_TESTS) else() message(STATUS "Tests are disabled. Set MSTD_BUILD_TESTS to ON to enable them.") endif() + +if(MSTD_BUILD_DOCS) + find_package(Doxygen REQUIRED) + set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile) + add_custom_target(docs + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_IN} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating API documentation with Doxygen" + VERBATIM + ) + message(STATUS "Doxygen found. Use 'make docs' to build documentation.") +else() + message(STATUS "Documentation is disabled. Set MSTD_BUILD_DOCS to ON to enable it.") +endif() diff --git a/compile_commands.json b/compile_commands.json deleted file mode 120000 index 4503a4b..0000000 --- a/compile_commands.json +++ /dev/null @@ -1 +0,0 @@ -.build/compile_commands.json \ No newline at end of file diff --git a/docs/Doxyfile b/docs/Doxyfile new file mode 100644 index 0000000..51633db --- /dev/null +++ b/docs/Doxyfile @@ -0,0 +1,243 @@ +# Doxyfile for mstd library +# Doxygen configuration file for generating API documentation + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +PROJECT_NAME = "mstd" +PROJECT_NUMBER = "0.1.0" +PROJECT_BRIEF = "mstd - header-only C++ library" +PROJECT_LOGO = +OUTPUT_DIRECTORY = docs/output +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = include +STRIP_FROM_INC_PATH = include + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_ANON_NSPACES = NO +RESOLVE_UNNAMED_PARAMS = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +HIDE_COMPOUND_REFERENCE= NO +SHOW_HEADERFILE = YES +SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_IF_INCOMPLETE_DOC = YES +WARN_NO_PARAMDOC = YES +WARN_AS_ERROR = YES +WARN_FORMAT = "$file:$line: $text" + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +INPUT = include +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.hpp \ + *.h \ + *.cpp \ + *.c \ + *.md +RECURSIVE = YES +EXCLUDE = external +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = */test/* \ + */external/* +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +ALPHABETICAL_INDEX = YES +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = NO +HTML_DYNAMIC_SECTIONS = YES +HTML_INDEX_NUM_ENTRIES = 100 +GENERATE_DOCSET = NO +GENERATE_HTMLHELP = NO +GENERATE_QHP = NO +GENERATE_ECLIPSEHELP = NO +DISABLE_INDEX = NO +GENERATE_TREEVIEW = YES +FULL_SIDEBAR = NO +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +OBFUSCATE_EMAILS = YES +SEARCHENGINE = YES +SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +GENERATE_LATEX = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the RTF output +#--------------------------------------------------------------------------- + +GENERATE_RTF = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the man page output +#--------------------------------------------------------------------------- + +GENERATE_MAN = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the XML output +#--------------------------------------------------------------------------- + +GENERATE_XML = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- + +GENERATE_DOCBOOK = NO + +#--------------------------------------------------------------------------- +# Configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = include +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to external references +#--------------------------------------------------------------------------- + +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +EXTERNAL_PAGES = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +CLASS_DIAGRAMS = YES +DIA_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +DOT_NUM_THREADS = 0 +DOT_FONTNAME = Helvetica +DOT_FONTSIZE = 10 +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 +DOT_UML_DETAILS = NO +DOT_WRAP_THRESHOLD = 17 +TEMPLATE_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = YES +DOT_PATH = +DOTFILE_DIRS = +MSCFILE_DIRS = +DIAFILE_DIRS = +PLANTUML_JAR_PATH = +PLANTUML_CFG_FILE = +PLANTUML_INCLUDE_PATH = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES diff --git a/external/devops b/external/devops new file mode 160000 index 0000000..c3be8da --- /dev/null +++ b/external/devops @@ -0,0 +1 @@ +Subproject commit c3be8da2dfa9abc382d8680746c7ca411f6fc7ea diff --git a/include/mstd/compile.hpp b/include/mstd/compile.hpp new file mode 100644 index 0000000..bae2261 --- /dev/null +++ b/include/mstd/compile.hpp @@ -0,0 +1,43 @@ +/***************************************************************************** + + + mstd library + Copyright (C) 2025-now Jakob Gamper + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + +******************************************************************************/ + +#ifndef __MSTD__COMPILE_HPP__ +#define __MSTD__COMPILE_HPP__ + +/** + * @brief Ignore buggy code + * + * Define this macro to ignore code that is known to be buggy in certain + * environments/libraries/compilers. + * + * @note at the moment the exact value of this macro does not matter + * as long as it is defined or not defined + * + */ +#ifdef MSTD_IGNORE_BUGGY_CODE +#undef MSTD_IGNORE_BUGGY_CODE +#define MSTD_IGNORE_BUGGY_CODE 1 +#else +#define MSTD_IGNORE_BUGGY_CODE 0 +#endif + +#endif // __MSTD__COMPILE_HPP__ \ No newline at end of file diff --git a/include/mstd/enum.hpp b/include/mstd/enum.hpp index 9b9d186..e2cb3c3 100644 --- a/include/mstd/enum.hpp +++ b/include/mstd/enum.hpp @@ -20,15 +20,18 @@ ******************************************************************************/ -#ifndef __MSTD_ENUM_HPP__ -#define __MSTD_ENUM_HPP__ +#ifndef __MSTD__ENUM_HPP__ +#define __MSTD__ENUM_HPP__ #include // IWYU pragma: keep #include // IWYU pragma: keep #include // IWYU pragma: keep +#include // IWYU pragma: keep #include // IWYU pragma: keep #include // IWYU pragma: keep +#include "mstd/type_traits/enum_traits.hpp" // IWYU pragma: keep + // // Element expanders // @@ -60,6 +63,11 @@ static constexpr auto values = \ std::to_array({LIST(MSTD_ENUM_MAKE_VALUE)}); \ \ + static constexpr std::span values_view() \ + { \ + return values; \ + } \ + \ static constexpr auto names = \ std::to_array({LIST(MSTD_ENUM_MAKE_STRING)}); \ \ @@ -91,13 +99,15 @@ return static_cast(e); \ } \ \ - static constexpr std::size_t index(EnumName e) \ + static constexpr std::optional index(EnumName e) \ { \ for (std::size_t i = 0; i < size; ++i) \ if (values[i] == e) \ return i; \ - return static_cast(-1); \ + return std::nullopt; \ } \ - }; + }; \ + \ + static constexpr EnumName##Meta enum_meta(EnumName) { return {}; } -#endif // __MSTD_ENUM_HPP__ \ No newline at end of file +#endif // __MSTD__ENUM_HPP__ \ No newline at end of file diff --git a/include/mstd/error.hpp b/include/mstd/error.hpp index 4269b71..40215ab 100644 --- a/include/mstd/error.hpp +++ b/include/mstd/error.hpp @@ -20,26 +20,63 @@ ******************************************************************************/ -#ifndef __MSTD_ERROR_HPP__ -#define __MSTD_ERROR_HPP__ +#ifndef __MSTD__ERROR_HPP__ +#define __MSTD__ERROR_HPP__ #include +#include "compile.hpp" + namespace mstd { - // clang-format off /** * @brief a struct that is always false - * - * @tparam T + * + * @tparam T */ template - struct always_false : std::false_type{}; - // clang-format on + struct always_false : std::false_type + { + }; } // namespace mstd +#define MSTD_CAT(a, b) a##b +#define MSTD_CAT2(a, b) MSTD_CAT(a, b) + #define MSTD_COMPILE_FAIL(msg) \ static_assert(::mstd::always_false::value, msg) -#endif // __MSTD_ERROR_HPP__ \ No newline at end of file +#define MSTD_WARN_BUGGY_LIBRARY(library_name) +#define MSTD_WARN_BUGGY_HEADER(header_file) + +#if !MSTD_IGNORE_BUGGY_CODE + +#undef MSTD_WARN_BUGGY_LIBRARY +#undef MSTD_WARN_BUGGY_HEADER + +/** + * @brief Warn about a buggy library + */ +#define MSTD_WARN_BUGGY_LIBRARY(library_name) \ + namespace MSTD_CAT2(mstd::buggy, __COUNTER__) \ + { \ + [[deprecated("Buggy library: " library_name " — don't use it!")]] \ + inline int buggy_marker = 0; \ + inline int buggy_marker_alias = buggy_marker; \ + } + +/** + * @brief Warn about a buggy header + */ +#define MSTD_WARN_BUGGY_HEADER(header_file) \ + namespace MSTD_CAT2(mstd::buggy, __COUNTER__) \ + { \ + [[deprecated("Buggy header: " header_file " — don't use it!")]] \ + inline int buggy_marker = 0; \ + inline int buggy_marker_alias = buggy_marker; \ + } + +#endif + +#endif // __MSTD__ERROR_HPP__ \ No newline at end of file diff --git a/include/mstd/functional.hpp b/include/mstd/functional.hpp index efb11c4..2d04802 100644 --- a/include/mstd/functional.hpp +++ b/include/mstd/functional.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __FUNCTIONAL_HPP__ -#define __FUNCTIONAL_HPP__ +#ifndef __MSTD__FUNCTIONAL_HPP__ +#define __MSTD__FUNCTIONAL_HPP__ namespace mstd { @@ -56,4 +56,4 @@ namespace mstd } // namespace mstd -#endif // __FUNCTIONAL_HPP__ \ No newline at end of file +#endif // __MSTD__FUNCTIONAL_HPP__ \ No newline at end of file diff --git a/include/mstd/math.hpp b/include/mstd/math.hpp index 6685d2e..94b1d46 100644 --- a/include/mstd/math.hpp +++ b/include/mstd/math.hpp @@ -20,9 +20,9 @@ ******************************************************************************/ -#ifndef __MSTD_MATH_HPP__ -#define __MSTD_MATH_HPP__ +#ifndef __MSTD__MATH_HPP__ +#define __MSTD__MATH_HPP__ #include "math/power.hpp" // IWYU pragma: export -#endif // __MSTD_MATH_HPP__ \ No newline at end of file +#endif // __MSTD__MATH_HPP__ \ No newline at end of file diff --git a/include/mstd/math/power.hpp b/include/mstd/math/power.hpp index 530bc78..222fa32 100644 --- a/include/mstd/math/power.hpp +++ b/include/mstd/math/power.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_MATH_POWER_HPP__ -#define __MSTD_MATH_POWER_HPP__ +#ifndef __MSTD__MATH__POWER_HPP__ +#define __MSTD__MATH__POWER_HPP__ #include @@ -40,7 +40,7 @@ namespace mstd * @param base value raised to the power @p N. */ template - inline static constexpr T cpow(const T base) + static inline constexpr T cpow(const T base) { if constexpr (N < 0) return static_cast(1) / cpow<-N>(base); @@ -80,4 +80,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_MATH_POWER_HPP__ +#endif // __MSTD__MATH__POWER_HPP__ diff --git a/include/mstd/pack.hpp b/include/mstd/pack.hpp index a20f7e8..92c7f5c 100644 --- a/include/mstd/pack.hpp +++ b/include/mstd/pack.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_PACK_HPP__ -#define __MSTD_PACK_HPP__ +#ifndef __MSTD__PACK_HPP__ +#define __MSTD__PACK_HPP__ #include "pack/integer_pack.hpp" // IWYU pragma: export #include "pack/integer_pack_operations.hpp" // IWYU pragma: export @@ -29,4 +29,4 @@ #include "pack/ratio_pack_operations.hpp" // IWYU pragma: export #include "type_traits/pack_traits.hpp" // IWYU pragma: export -#endif // __MSTD_PACK_HPP__ \ No newline at end of file +#endif // __MSTD__PACK_HPP__ \ No newline at end of file diff --git a/include/mstd/pack/integer_pack.hpp b/include/mstd/pack/integer_pack.hpp index be238d8..9490875 100644 --- a/include/mstd/pack/integer_pack.hpp +++ b/include/mstd/pack/integer_pack.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_INTEGER_PACK_HPP__ -#define __MSTD_INTEGER_PACK_HPP__ +#ifndef __MSTD__PACK__INTEGER_PACK_HPP__ +#define __MSTD__PACK__INTEGER_PACK_HPP__ #include #include @@ -93,10 +93,10 @@ namespace mstd if (vals[i] != 0) return i; - return -1; + return static_cast(-1); } }; } // namespace mstd -#endif // __MSTD_INTEGER_PACK_HPP__ +#endif // __MSTD__PACK__INTEGER_PACK_HPP__ diff --git a/include/mstd/pack/integer_pack_details.hpp b/include/mstd/pack/integer_pack_details.hpp index 2da5c9f..f7527e7 100644 --- a/include/mstd/pack/integer_pack_details.hpp +++ b/include/mstd/pack/integer_pack_details.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_INTEGER_PACK_DETAILS_HPP__ -#define __MSTD_INTEGER_PACK_DETAILS_HPP__ +#ifndef __MSTD__PACK__INTEGER_PACK_DETAILS_HPP__ +#define __MSTD__PACK__INTEGER_PACK_DETAILS_HPP__ #include #include @@ -114,9 +114,9 @@ namespace mstd * @tparam F The function to apply. */ template - using pack_zip_t = decltype(pack_zip_impl( - std::make_index_sequence{} - )); + using pack_zip_t = + decltype(pack_zip_impl(std::make_index_sequence{}) + ); /********************* * * @@ -158,4 +158,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_INTEGER_PACK_DETAILS_HPP__ +#endif // __MSTD__PACK__INTEGER_PACK_DETAILS_HPP__ diff --git a/include/mstd/pack/integer_pack_operations.hpp b/include/mstd/pack/integer_pack_operations.hpp index 2b2b600..8c877ad 100644 --- a/include/mstd/pack/integer_pack_operations.hpp +++ b/include/mstd/pack/integer_pack_operations.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_INTEGER_PACK_OPERATIONS_HPP__ -#define __MSTD_INTEGER_PACK_OPERATIONS_HPP__ +#ifndef __MSTD__PACK__INTEGER_PACK_OPERATIONS_HPP__ +#define __MSTD__PACK__INTEGER_PACK_OPERATIONS_HPP__ #include "integer_pack.hpp" #include "integer_pack_details.hpp" @@ -60,4 +60,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_INTEGER_PACK_OPERATIONS_HPP__ \ No newline at end of file +#endif // __MSTD__PACK__INTEGER_PACK_OPERATIONS_HPP__ \ No newline at end of file diff --git a/include/mstd/pack/ratio_pack.hpp b/include/mstd/pack/ratio_pack.hpp index 4ca5ccd..6c6ca0a 100644 --- a/include/mstd/pack/ratio_pack.hpp +++ b/include/mstd/pack/ratio_pack.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_RATIO_PACK_HPP__ -#define __MSTD_RATIO_PACK_HPP__ +#ifndef __MSTD__PACK__RATIO_PACK_HPP__ +#define __MSTD__PACK__RATIO_PACK_HPP__ #include #include @@ -87,4 +87,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_RATIO_PACK_HPP__ +#endif // __MSTD__PACK__RATIO_PACK_HPP__ diff --git a/include/mstd/pack/ratio_pack_details.hpp b/include/mstd/pack/ratio_pack_details.hpp index a9c7360..da9cb58 100644 --- a/include/mstd/pack/ratio_pack_details.hpp +++ b/include/mstd/pack/ratio_pack_details.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_RATIO_PACK_DETAILS_HPP__ -#define __MSTD_RATIO_PACK_DETAILS_HPP__ +#ifndef __MSTD__PACK__RATIO_PACK_DETAILS_HPP__ +#define __MSTD__PACK__RATIO_PACK_DETAILS_HPP__ #include #include @@ -129,4 +129,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_RATIO_PACK_DETAILS_HPP__ +#endif // __MSTD__PACK__RATIO_PACK_DETAILS_HPP__ diff --git a/include/mstd/pack/ratio_pack_operations.hpp b/include/mstd/pack/ratio_pack_operations.hpp index def54af..2742a7e 100644 --- a/include/mstd/pack/ratio_pack_operations.hpp +++ b/include/mstd/pack/ratio_pack_operations.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_RATIO_PACK_OPERATIONS_HPP__ -#define __MSTD_RATIO_PACK_OPERATIONS_HPP__ +#ifndef __MSTD__PACK__RATIO_PACK_OPERATIONS_HPP__ +#define __MSTD__PACK__RATIO_PACK_OPERATIONS_HPP__ #include "ratio_pack.hpp" #include "ratio_pack_details.hpp" @@ -82,4 +82,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_RATIO_PACK_OPERATIONS_HPP__ \ No newline at end of file +#endif // __MSTD__PACK__RATIO_PACK_OPERATIONS_HPP__ \ No newline at end of file diff --git a/include/mstd/physics/potentials/lie_potential.hpp b/include/mstd/physics/potentials/lie_potential.hpp index 6653dbe..0462dff 100644 --- a/include/mstd/physics/potentials/lie_potential.hpp +++ b/include/mstd/physics/potentials/lie_potential.hpp @@ -46,8 +46,18 @@ namespace mstd Rep _coeff2{}; public: - /// @brief Constructs the potential with prefactors for the attractive - /// and repulsive terms. + virtual ~LiePotential() = default; + + /** + * @brief Constructs the potential with prefactors for the attractive + * and repulsive terms. + * + * @note The coefficients correspond to the terms + * \f$-c_1 r^{-M} + c_2 r^{-N}\f$ in the potential expression. + * + * @param c1 Coefficient for the attractive term. + * @param c2 Coefficient for the repulsive term. + */ constexpr LiePotential(Rep c1, Rep c2) : _coeff1(c1), _coeff2(c2) {} /// @brief Evaluates only the potential energy at a distance @p r. @@ -96,7 +106,7 @@ namespace mstd constexpr LieShiftedPotential(Rep c1, Rep c2, Rep rc) : LiePotential(c1, c2), _radialCutoff(rc) { - std::tie(_energyCutoff, _forceCutoff) = eval(_radialCutoff); + std::tie(_energyCutoff, _forceCutoff) = _Base::eval(rc); } /// @brief Energy corrected so that it vanishes at the cutoff. diff --git a/include/mstd/quantity.hpp b/include/mstd/quantity.hpp index bf51a41..4921cd6 100644 --- a/include/mstd/quantity.hpp +++ b/include/mstd/quantity.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNITS_HPP__ -#define __MSTD_UNITS_HPP__ +#ifndef __MSTD__QUANTITY_HPP__ +#define __MSTD__QUANTITY_HPP__ + +#include "mstd/error.hpp" // IWYU pragma: export + +MSTD_WARN_BUGGY_LIBRARY("mstd/quantity.hpp") #include "mstd/type_traits/quantity_traits.hpp" // IWYU pragma: export #include "quantity/dim.hpp" // IWYU pragma: export @@ -32,4 +36,4 @@ #include "quantity/unit_impl.hpp" // IWYU pragma: export #include "quantity/unit_operations.hpp" // IWYU pragma: export -#endif // __MSTD_UNITS_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/dim.hpp b/include/mstd/quantity/dim.hpp index bb5550e..3f0bd5a 100644 --- a/include/mstd/quantity/dim.hpp +++ b/include/mstd/quantity/dim.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNITS_DIMENSION_HPP__ -#define __MSTD_UNITS_DIMENSION_HPP__ +#ifndef __MSTD__QUANTITY__DIM_HPP__ +#define __MSTD__QUANTITY__DIM_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/dim.hpp") #include @@ -120,4 +124,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_UNITS_DIMENSION_HPP__ +#endif // __MSTD__QUANTITY__DIM_HPP__ diff --git a/include/mstd/quantity/dim_details.hpp b/include/mstd/quantity/dim_details.hpp index 9115af4..f2e219f 100644 --- a/include/mstd/quantity/dim_details.hpp +++ b/include/mstd/quantity/dim_details.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_DIM_DETAILS_HPP__ -#define __MSTD_DIM_DETAILS_HPP__ +#ifndef __MSTD__QUANTITY__DIM_DETAILS_HPP__ +#define __MSTD__QUANTITY__DIM_DETAILS_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/dim_details.hpp") #include "mstd/pack.hpp" @@ -100,4 +104,4 @@ namespace mstd } // namespace details } // namespace mstd -#endif // __MSTD_DIM_DETAILS_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__DIM_DETAILS_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/dim_impl.hpp b/include/mstd/quantity/dim_impl.hpp index 975c55d..5d1909e 100644 --- a/include/mstd/quantity/dim_impl.hpp +++ b/include/mstd/quantity/dim_impl.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_DIMENSION_IMPL_HPP__ -#define __MSTD_DIMENSION_IMPL_HPP__ +#ifndef __MSTD__QUANTITY__DIM_IMPL_HPP__ +#define __MSTD__QUANTITY__DIM_IMPL_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/dim_impl.hpp") #include "dim.hpp" #include "dim_operations.hpp" @@ -125,4 +129,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_DIMENSION_IMPL_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__DIM_IMPL_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/dim_operations.hpp b/include/mstd/quantity/dim_operations.hpp index cecf6a6..e28570e 100644 --- a/include/mstd/quantity/dim_operations.hpp +++ b/include/mstd/quantity/dim_operations.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_DIM_OPERATIONS_HPP__ -#define __MSTD_DIM_OPERATIONS_HPP__ +#ifndef __MSTD__QUANTITY__DIM_OPERATIONS_HPP__ +#define __MSTD__QUANTITY__DIM_OPERATIONS_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/dim_operations.hpp") #include "dim.hpp" #include "dim_details.hpp" @@ -71,4 +75,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_DIM_OPERATIONS_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__DIM_OPERATIONS_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/dim_ratio.hpp b/include/mstd/quantity/dim_ratio.hpp index 347e905..2584d00 100644 --- a/include/mstd/quantity/dim_ratio.hpp +++ b/include/mstd/quantity/dim_ratio.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_DIM_RATIO_HPP__ -#define __MSTD_DIM_RATIO_HPP__ +#ifndef __MSTD__QUANTITY__DIM_RATIO_HPP__ +#define __MSTD__QUANTITY__DIM_RATIO_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/dim_ratio.hpp") #include "enums.hpp" #include "mstd/pack.hpp" @@ -107,4 +111,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_DIM_RATIO_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__DIM_RATIO_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/dim_ratio_details.hpp b/include/mstd/quantity/dim_ratio_details.hpp index 0b329f0..068d2c3 100644 --- a/include/mstd/quantity/dim_ratio_details.hpp +++ b/include/mstd/quantity/dim_ratio_details.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_DIM_RATIO_DETAILS_HPP__ -#define __MSTD_DIM_RATIO_DETAILS_HPP__ +#ifndef __MSTD__QUANTITY__DIM_RATIO_DETAILS_HPP__ +#define __MSTD__QUANTITY__DIM_RATIO_DETAILS_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/dim_ratio_details.hpp") #include "dim_details.hpp" #include "dim_ratio.hpp" @@ -85,4 +89,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_DIM_RATIO_DETAILS_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__DIM_RATIO_DETAILS_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/dim_ratio_impl.hpp b/include/mstd/quantity/dim_ratio_impl.hpp index d9dbcb5..4d5bcdd 100644 --- a/include/mstd/quantity/dim_ratio_impl.hpp +++ b/include/mstd/quantity/dim_ratio_impl.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_DIM_RATIO_IMPL_HPP__ -#define __MSTD_DIM_RATIO_IMPL_HPP__ +#ifndef __MSTD__QUANTITY__DIM_RATIO_IMPL_HPP__ +#define __MSTD__QUANTITY__DIM_RATIO_IMPL_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/dim_ratio_impl.hpp") #include "dim_ratio.hpp" #include "dim_ratio_operations.hpp" @@ -111,4 +115,4 @@ namespace mstd using angle_dim_ratio = typename angle_dim_ratio_impl::type; } // namespace mstd -#endif // __MSTD_DIM_RATIO_IMPL_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__DIM_RATIO_IMPL_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/dim_ratio_operations.hpp b/include/mstd/quantity/dim_ratio_operations.hpp index 05cf3e9..ee1625c 100644 --- a/include/mstd/quantity/dim_ratio_operations.hpp +++ b/include/mstd/quantity/dim_ratio_operations.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_DIM_RATIO_OPERATIONS_HPP__ -#define __MSTD_DIM_RATIO_OPERATIONS_HPP__ +#ifndef __MSTD__QUANTITY__DIM_RATIO_OPERATIONS_HPP__ +#define __MSTD__QUANTITY__DIM_RATIO_OPERATIONS_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/dim_ratio_operations.hpp") #include "dim_ratio.hpp" #include "dim_ratio_details.hpp" @@ -83,4 +87,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_DIM_RATIO_OPERATIONS_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__DIM_RATIO_OPERATIONS_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/enums.hpp b/include/mstd/quantity/enums.hpp index d44744f..ab2ca1a 100644 --- a/include/mstd/quantity/enums.hpp +++ b/include/mstd/quantity/enums.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNITS_ENUMS_HPP__ -#define __MSTD_UNITS_ENUMS_HPP__ +#ifndef __MSTD__QUANTITY__ENUMS_HPP__ +#define __MSTD__QUANTITY__ENUMS_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/enums.hpp") #include @@ -54,7 +58,7 @@ namespace mstd X(Amount) \ X(Luminous) - MSTD_ENUM(SIDimId, size_t, SIDIMID_LIST) + MSTD_ENUM(SIDimId, size_t, SIDIMID_LIST) // cppcheck-suppress syntaxError /** * @brief Enumeration of the extra dimension IDs. @@ -72,9 +76,13 @@ namespace mstd X(Info) \ X(Count) - MSTD_ENUM(ExtraDimId, size_t, EXTRADIMID_LIST) + MSTD_ENUM( + ExtraDimId, + size_t, + EXTRADIMID_LIST + ) // cppcheck-suppress syntaxError // NOLINTEND } // namespace mstd -#endif // __MSTD_UNITS_ENUMS_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__ENUMS_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/quantity.hpp b/include/mstd/quantity/quantity.hpp index 54996c9..f1fed49 100644 --- a/include/mstd/quantity/quantity.hpp +++ b/include/mstd/quantity/quantity.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNITS_QUANTITY_HPP__ -#define __MSTD_UNITS_QUANTITY_HPP__ +#ifndef __MSTD__QUANTITY__QUANTITY_HPP__ +#define __MSTD__QUANTITY__QUANTITY_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_LIBRARY("mstd/quantity.hpp") #include @@ -67,7 +71,6 @@ namespace mstd /** * @brief Construct a Quantity from a base value (SI unit). * - * @param from_base_tag Tag to indicate base value construction. * @param base The base value in SI units. */ constexpr Quantity(from_base_t, Rep base) // base (SI) ctor @@ -362,4 +365,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_UNITS_QUANTITY_HPP__ +#endif // __MSTD__QUANTITY__QUANTITY_HPP__ diff --git a/include/mstd/quantity/quantity_impl.hpp b/include/mstd/quantity/quantity_impl.hpp index e196c72..4821440 100644 --- a/include/mstd/quantity/quantity_impl.hpp +++ b/include/mstd/quantity/quantity_impl.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNITS_QUANTITY_IMPL_HPP__ -#define __MSTD_UNITS_QUANTITY_IMPL_HPP__ +#ifndef __MSTD__QUANTITY__QUANTITY_IMPL_HPP__ +#define __MSTD__QUANTITY__QUANTITY_IMPL_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/quantity_impl.hpp") #include "quantity.hpp" #include "unit_impl.hpp" @@ -93,4 +97,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_UNITS_QUANTITY_IMPL_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__QUANTITY_IMPL_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/unit.hpp b/include/mstd/quantity/unit.hpp index 1caec56..b7210f8 100644 --- a/include/mstd/quantity/unit.hpp +++ b/include/mstd/quantity/unit.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNITS_UNIT_HPP__ -#define __MSTD_UNITS_UNIT_HPP__ +#ifndef __MSTD__QUANTITY__UNIT_HPP__ +#define __MSTD__QUANTITY__UNIT_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/unit.hpp") #include "dim_details.hpp" #include "dim_ratio.hpp" @@ -79,4 +83,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_UNITS_UNIT_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__UNIT_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/unit_details.hpp b/include/mstd/quantity/unit_details.hpp index e4815a4..6931004 100644 --- a/include/mstd/quantity/unit_details.hpp +++ b/include/mstd/quantity/unit_details.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNITS_DETAILS_HPP__ -#define __MSTD_UNITS_DETAILS_HPP__ +#ifndef __MSTD__QUANTITY__UNIT_DETAILS_HPP__ +#define __MSTD__QUANTITY__UNIT_DETAILS_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/unit_details.hpp") #include "dim.hpp" #include "dim_ratio_operations.hpp" @@ -234,4 +238,4 @@ namespace mstd::details } // namespace mstd::details -#endif // __MSTD_UNITS_DETAILS_HPP__ +#endif // __MSTD__QUANTITY__UNIT_DETAILS_HPP__ diff --git a/include/mstd/quantity/unit_impl.hpp b/include/mstd/quantity/unit_impl.hpp index 461f0eb..9d65afd 100644 --- a/include/mstd/quantity/unit_impl.hpp +++ b/include/mstd/quantity/unit_impl.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNIT_IMPL_HPP__ -#define __MSTD_UNIT_IMPL_HPP__ +#ifndef __MSTD__QUANTITY__UNIT_IMPL_HPP__ +#define __MSTD__QUANTITY__UNIT_IMPL_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/unit_impl.hpp") #include @@ -204,4 +208,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_UNIT_IMPL_HPP__ \ No newline at end of file +#endif // __MSTD__QUANTITY__UNIT_IMPL_HPP__ \ No newline at end of file diff --git a/include/mstd/quantity/unit_operations.hpp b/include/mstd/quantity/unit_operations.hpp index 9e650a6..dc132ea 100644 --- a/include/mstd/quantity/unit_operations.hpp +++ b/include/mstd/quantity/unit_operations.hpp @@ -20,8 +20,12 @@ ******************************************************************************/ -#ifndef __MSTD_UNIT_OPERATIONS_HPP__ -#define __MSTD_UNIT_OPERATIONS_HPP__ +#ifndef __MSTD__QUANTITY__UNIT_OPERATIONS_HPP__ +#define __MSTD__QUANTITY__UNIT_OPERATIONS_HPP__ + +#include "mstd/error.hpp" + +MSTD_WARN_BUGGY_HEADER("mstd/quantity/unit_operations.hpp") #include "mstd/pack.hpp" #include "mstd/ratio.hpp" @@ -129,4 +133,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_UNIT_OPERATIONS_HPP__ +#endif // __MSTD__QUANTITY__UNIT_OPERATIONS_HPP__ diff --git a/include/mstd/ratio.hpp b/include/mstd/ratio.hpp index 612c4e5..4e827b1 100644 --- a/include/mstd/ratio.hpp +++ b/include/mstd/ratio.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_UNITS_RATIO_HPP__ -#define __MSTD_UNITS_RATIO_HPP__ +#ifndef __MSTD__RATIO_HPP__ +#define __MSTD__RATIO_HPP__ #include #include @@ -120,4 +120,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_UNITS_RATIO_HPP__ \ No newline at end of file +#endif // __MSTD__RATIO_HPP__ \ No newline at end of file diff --git a/include/mstd/type_traits.hpp b/include/mstd/type_traits.hpp index af73ccc..4449fe5 100644 --- a/include/mstd/type_traits.hpp +++ b/include/mstd/type_traits.hpp @@ -20,12 +20,13 @@ ******************************************************************************/ -#ifndef __MSTD_TYPE_TRAITS_HPP__ -#define __MSTD_TYPE_TRAITS_HPP__ +#ifndef __MSTD__TYPE_TRAITS_HPP__ +#define __MSTD__TYPE_TRAITS_HPP__ +#include "type_traits/enum_traits.hpp" // IWYU pragma: export #include "type_traits/math_traits.hpp" // IWYU pragma: export #include "type_traits/pack_traits.hpp" // IWYU pragma: export #include "type_traits/quantity_traits.hpp" // IWYU pragma: export #include "type_traits/ratio_traits.hpp" // IWYU pragma: export -#endif // __MSTD_TYPE_TRAITS_HPP__ \ No newline at end of file +#endif // __MSTD__TYPE_TRAITS_HPP__ \ No newline at end of file diff --git a/include/mstd/type_traits/enum_traits.hpp b/include/mstd/type_traits/enum_traits.hpp new file mode 100644 index 0000000..e00cff4 --- /dev/null +++ b/include/mstd/type_traits/enum_traits.hpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + + mstd library + Copyright (C) 2025-now Jakob Gamper + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + +******************************************************************************/ + +#ifndef __MSTD__TYPE_TRAITS__ENUM_TRAITS_HPP__ +#define __MSTD__TYPE_TRAITS__ENUM_TRAITS_HPP__ + +#include + +namespace mstd +{ + /** + * @brief A helper type alias to extract the enum metadata type + * + * @tparam E The enum type + */ + template + using enum_meta_t = decltype(enum_meta(std::declval())); + + /** + * @brief A concept to check if a type has enum metadata + * + * This concept checks if a type is an enum and has a corresponding + * enum_meta specialization, which is true for enums defined with MSTD_ENUM. + * + * @tparam E The type to check + */ + template + concept has_enum_meta = + std::is_enum_v && requires { typename enum_meta_t; }; + +} // namespace mstd + +#endif // __MSTD__TYPE_TRAITS__ENUM_TRAITS_HPP__ \ No newline at end of file diff --git a/include/mstd/type_traits/pack_traits.hpp b/include/mstd/type_traits/pack_traits.hpp index 10ef53a..670f399 100644 --- a/include/mstd/type_traits/pack_traits.hpp +++ b/include/mstd/type_traits/pack_traits.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_PACK_TRAITS_HPP__ -#define __MSTD_PACK_TRAITS_HPP__ +#ifndef __MSTD__TYPE_TRAITS__PACK_TRAITS_HPP__ +#define __MSTD__TYPE_TRAITS__PACK_TRAITS_HPP__ #include "ratio_traits.hpp" @@ -64,4 +64,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_PACK_TRAITS_HPP__ \ No newline at end of file +#endif // __MSTD__TYPE_TRAITS__PACK_TRAITS_HPP__ \ No newline at end of file diff --git a/include/mstd/type_traits/quantity_traits.hpp b/include/mstd/type_traits/quantity_traits.hpp index adacc7c..90b2f01 100644 --- a/include/mstd/type_traits/quantity_traits.hpp +++ b/include/mstd/type_traits/quantity_traits.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_TYPE_TRAITS_QUANTITY_TRAITS_HPP__ -#define __MSTD_TYPE_TRAITS_QUANTITY_TRAITS_HPP__ +#ifndef __MSTD__TYPE_TRAITS__QUANTITY_TRAITS_HPP__ +#define __MSTD__TYPE_TRAITS__QUANTITY_TRAITS_HPP__ #include "pack_traits.hpp" #include "ratio_traits.hpp" @@ -125,4 +125,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_TYPE_TRAITS_QUANTITY_TRAITS_HPP__ \ No newline at end of file +#endif // __MSTD__TYPE_TRAITS__QUANTITY_TRAITS_HPP__ \ No newline at end of file diff --git a/include/mstd/type_traits/ratio_traits.hpp b/include/mstd/type_traits/ratio_traits.hpp index a1a85cf..b7ab7d5 100644 --- a/include/mstd/type_traits/ratio_traits.hpp +++ b/include/mstd/type_traits/ratio_traits.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_RATIO_TRAITS_HPP__ -#define __MSTD_RATIO_TRAITS_HPP__ +#ifndef __MSTD__TYPE_TRAITS__RATIO_TRAITS_HPP__ +#define __MSTD__TYPE_TRAITS__RATIO_TRAITS_HPP__ /** * @file ratio_traits.hpp @@ -50,4 +50,4 @@ namespace mstd } // namespace mstd -#endif // __MSTD_RATIO_TRAITS_HPP__ \ No newline at end of file +#endif // __MSTD__TYPE_TRAITS__RATIO_TRAITS_HPP__ \ No newline at end of file diff --git a/scripts/.gitignore b/scripts/.gitignore deleted file mode 100644 index 9b2e9dc..0000000 --- a/scripts/.gitignore +++ /dev/null @@ -1 +0,0 @@ -singularity_test diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh new file mode 100755 index 0000000..7bd72cf --- /dev/null +++ b/scripts/cppcheck.sh @@ -0,0 +1,14 @@ +cppcheck --enable=all \ + --enable=performance \ + --enable=style \ + --enable=information \ + --enable=portability \ + --error-exitcode=1 \ + --suppressions-list=.cppcheck.suppress \ + --suppress=missingIncludeSystem \ + --inline-suppr \ + --inconclusive \ + -I include \ + include test + +cpp_checks --dirs include --dirs test diff --git a/test/math/test_cpow.cpp b/test/math/test_cpow.cpp index 1cfd182..d078eda 100644 --- a/test/math/test_cpow.cpp +++ b/test/math/test_cpow.cpp @@ -1,3 +1,25 @@ +/***************************************************************************** + + + mstd library + Copyright (C) 2025-now Jakob Gamper + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + +******************************************************************************/ + #include #include #include diff --git a/test/quantity/test_utils.hpp b/test/quantity/test_utils.hpp index 6b61afb..23479e5 100644 --- a/test/quantity/test_utils.hpp +++ b/test/quantity/test_utils.hpp @@ -20,8 +20,8 @@ ******************************************************************************/ -#ifndef __MSTD_TEST_UTILS_HPP__ -#define __MSTD_TEST_UTILS_HPP__ +#ifndef __QUANTITY__TEST_UTILS_HPP__ +#define __QUANTITY__TEST_UTILS_HPP__ #include @@ -30,4 +30,4 @@ STATIC_REQUIRE(__VA_ARGS__) \ /* NOLINTEND */ -#endif // __MSTD_TEST_UTILS_HPP__ +#endif // __QUANTITY__TEST_UTILS_HPP__