{"id":16945068,"url":"https://github.com/muggenhor/awesome-assert","last_synced_at":"2026-07-05T13:31:49.018Z","repository":{"id":145236341,"uuid":"76727087","full_name":"muggenhor/awesome-assert","owner":"muggenhor","description":"Simple C++ assertion library with expression decomposition","archived":false,"fork":false,"pushed_at":"2026-02-24T17:50:06.000Z","size":159,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-24T21:52:16.320Z","etag":null,"topics":["assert","cpp","cpp14","cpp17"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muggenhor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-12-17T13:58:10.000Z","updated_at":"2026-02-24T17:50:11.000Z","dependencies_parsed_at":"2024-01-13T14:41:51.887Z","dependency_job_id":"3b5e4a7a-a12c-4023-9640-6e547f36b0ad","html_url":"https://github.com/muggenhor/awesome-assert","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/muggenhor/awesome-assert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muggenhor%2Fawesome-assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muggenhor%2Fawesome-assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muggenhor%2Fawesome-assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muggenhor%2Fawesome-assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muggenhor","download_url":"https://codeload.github.com/muggenhor/awesome-assert/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muggenhor%2Fawesome-assert/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35156494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-05T02:00:06.290Z","response_time":100,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","cpp","cpp14","cpp17"],"created_at":"2024-10-13T21:19:43.020Z","updated_at":"2026-07-05T13:31:49.012Z","avatar_url":"https://github.com/muggenhor.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AwesomeAssert\n\n[![Tests](https://github.com/muggenhor/awesome-assert/actions/workflows/flake.yml/badge.svg)](https://github.com/muggenhor/awesome-assert/actions/workflows/flake.yml)\n\nAn assert implementation that aims to provide usable information while maintaining as small a performance footprint as possible when _not_ failing.\n\n## Usage\n\nThis library is intended to be used by `#include \u003cawesome/assert.hpp\u003e` and use of one of these three assert macros:\n\n```cppp\n#define AWESOME_EXPECTS(\u003cboolean-expr\u003e)  // precondition\n#define AWESOME_ASSERT(\u003cboolean-expr\u003e)   // invariant\n#define AWESOME_ENSURES(\u003cboolean-expr\u003e)  // postcondition\n```\n\n* `AWESOME_ASSERT` is for conditions that the containing component is responsible for meeting.\n* `AWESOME_EXPECTS` is for checking of *documented* pre-conditions of the public API of your component.\n* `AWESOME_ENSURES` is for checking whether results and state adhere to *documented* post-conditions.\n\nGenerally you'll want to use `AWESOME_EXPECTS` and `AWESOME_ENSURES` at the boundary of your component's public interface.\nWhile sticking to `AWESOME_ASSERT` for internals.\n\nThere are some limitations to the complexity of expressions you can pass to these assert macros.\nThese limitations stem from relying on expression decomposition to be able to produce error messages that include the values of the operands.\nBut we're documenting them here to prevent confusion.\n\n```cpp\nAWESOME_ASSERT(x COMP y);\nAWESOME_ASSERT(x COMP y \u0026\u0026 y COMP z);\nAWESOME_ASSERT(x COMP y || y COMP z);\n```\n\nWhere `COMP` is one of these binary comparison operators: `==`, `!=`, `\u003c`, `\u003c=`, `\u003e`, `\u003e=` and `\u0026` (bitwise and, for use as bitmask test operator).\n\nNote that only a *single* instance of a logical operator (`\u0026\u0026` or `||`) is allowed because introspection fails beyond that.\nAdditionally `x`, `y` and `z` represent actual values here (or function calls that produce them), not boolean expressions.\n\nIn most cases you shouldn't experience any problems resulting from these limitations.\nThe most common problem is having more than two boolean expressions combined with `\u0026\u0026`.\nIn almost all cases the solution for that is to have a separate assert statement per such boolean expression.\n\n## Requirements\n\n### Capture and Log Context When Failing\n\nFor binary comparisons, don't just log the stringified expression, log the values of the two operands.\nFor unary expressions, i.e. convertible-to-bool, log the value of that expression.\n\nThis should work without having to use separate macros for every comparison operator.\n\n### Code Locality for Non-Failing Path\n\nThe compiler-generated code (assembly) should not branch to a distant site when the asserted condition is met.\nPreferably no branch at all should occur when the asserted condition is met.\n\n### Don't Waste Cycles on Diagnostics for Non-Failing Path\n\nNo preparation of diagnostic information should happen at all when the asserted condition is met.\n\nThe largest performance impact permitted when not failing the condition is register spill-over.\nSpecifically the register spill-over caused by the need to retain the values of the comparison expression is permitted.\n\nTODO: Look into compiler optimizations capable of reconstructing the values instead of storing them.\n\n### Customizable Handling\n\nPermit the user to override the failure handler.\nIt should stay `[[noreturn]]` though.\nPreferrably `noexcept` as well, although that should probably be customizable.\n\n## License\n\nCopyright (C) 2016-2018 Giel van Schijndel\n\nAwesomeAssert is free software: you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public License\nas published by the Free Software Foundation, either version 3 of\nthe License, or (at your option) any later version.\n\nAwesomeAssert is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the\nGNU Lesser General Public License along with AwesomeAssert.\nIf not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuggenhor%2Fawesome-assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuggenhor%2Fawesome-assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuggenhor%2Fawesome-assert/lists"}