{"id":13729813,"url":"https://github.com/rollbear/dry-comparisons","last_synced_at":"2026-02-20T18:45:14.069Z","repository":{"id":46125965,"uuid":"140959453","full_name":"rollbear/dry-comparisons","owner":"rollbear","description":"C++17 Utility classes for comparing multiple values in one simple expression","archived":false,"fork":false,"pushed_at":"2024-08-10T07:08:27.000Z","size":55,"stargazers_count":207,"open_issues_count":2,"forks_count":13,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-08T02:38:02.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rollbear.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-07-14T16:04:48.000Z","updated_at":"2025-03-10T15:59:01.000Z","dependencies_parsed_at":"2024-01-07T16:32:07.458Z","dependency_job_id":"6756bdea-9713-46cf-bf2c-a3e47a8466f8","html_url":"https://github.com/rollbear/dry-comparisons","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rollbear/dry-comparisons","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollbear%2Fdry-comparisons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollbear%2Fdry-comparisons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollbear%2Fdry-comparisons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollbear%2Fdry-comparisons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rollbear","download_url":"https://codeload.github.com/rollbear/dry-comparisons/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollbear%2Fdry-comparisons/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29660324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T16:33:43.953Z","status":"ssl_error","status_checked_at":"2026-02-20T16:33:43.598Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-08-03T02:01:05.599Z","updated_at":"2026-02-20T18:45:14.051Z","avatar_url":"https://github.com/rollbear.png","language":"C++","readme":"# dry-comparisons\n\n![CI](https://github.com/rollbear/dry-comparisons/workflows/CI/badge.svg)\n[![codecov](https://codecov.io/gh/rollbear/dry-comparisons/branch/main/graph/badge.svg?token=XBT5Df1L3m)](https://codecov.io/gh/rollbear/dry-comparisons)\n\nThis is the source code for the `any_of`, `all_of` and `none_of` C++17 utility mentioned in the blog post\n[\"DRY multicomparisons\"](http://playfulprogramming.blogspot.com/2018/07/dry-multicomparisons.html)\n\nPublic domain.\n\n## Usage\n\n```Cpp\nusing rollbear::any_of;\n\nclass Machine\n{\npublic:\n  ...\n  void func() {\n    assert(state == any_of(S1, S3)); // assert(state == S1 || state == S3);\n    ...\n  }\nprivate:\n  enum { S0, S1, S2, S3 } state;\n};\n```\n\nThe types available are `any_of`, `all_of` and `none_of`.\n\n*iff* all member types can be inserted into an ostream, an instance of `any_of`, `all_of` or\n`none_of` may be printed, e.g. `std::cout \u003c\u003c rollbear::any_of{1,3,5}`, which\nwill produce the output `any_of{1,3,5}`. \n\n*iff* it is possible to do logical and/or operations on all members, instances\nof `any_of`, `all_of` and `none_of` may be used directly as boolean expressions.\n\n* `bool(any_of{a,b,c}) == bool(a || b || c)`\n* `bool(all_of{a,b,c}) == bool(a \u0026\u0026 b \u0026\u0026 c)`\n* `bool(none_of{a,b,c}) == !bool(a || b || c)`\n\n*iff* the members are callable, the resulting object is also callable.\n\n* `any_of{std::plus{}, std::minus{}}(3,2) == 5`\n* `all_of{std::plus{}, std::minus{}}(3,2) \u003e 0`\n* `none_of{std::plus{}, std::minus{}}(3,2) == 0`\n\nwith SFINAE friendly checks that the calls can be made for the values given. The\nlogical conditions are short cirquited, in the normal logical expression manners.\n\nFurther more, it is also possible to do relational comparisons. For example:\n\n`assert(all_of(s1, s2) \u003e \".\")`, providing the expressions `s1` and `s2` are\ngreater-than comparable with a string literal.\n\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frollbear%2Fdry-comparisons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frollbear%2Fdry-comparisons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frollbear%2Fdry-comparisons/lists"}