{"id":20191428,"url":"https://github.com/htfy96/cpp-cmp","last_synced_at":"2026-06-17T16:01:51.084Z","repository":{"id":86701931,"uuid":"60190072","full_name":"htfy96/cpp-cmp","owner":"htfy96","description":"Header-only library providing smart `cmp` function for C++11","archived":false,"fork":false,"pushed_at":"2016-06-02T04:10:11.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T11:44:13.513Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/htfy96.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":"2016-06-01T15:42:53.000Z","updated_at":"2025-09-17T03:02:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e0c9dbc-505d-4b3a-b0ea-c820e1ad5dd5","html_url":"https://github.com/htfy96/cpp-cmp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/htfy96/cpp-cmp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Fcpp-cmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Fcpp-cmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Fcpp-cmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Fcpp-cmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htfy96","download_url":"https://codeload.github.com/htfy96/cpp-cmp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2Fcpp-cmp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34453446,"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-06-17T02:00:05.408Z","response_time":127,"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":[],"created_at":"2024-11-14T03:49:01.380Z","updated_at":"2026-06-17T16:01:51.034Z","avatar_url":"https://github.com/htfy96.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cpp-cmp ![test status](https://travis-ci.org/htfy96/cpp-cmp.svg?branch=master)\n\nHeader-only library providing smart `cmp` function for C++11.\n\n## Usage\n\n```cpp\n#include \"cmp.hpp\"\n```\n\n```cpp\nusing namespace cppcmp;\n// cppcmp::cmp\nassert(-1 == cmp(-3, 5));\n//assert(1 == cmp(100L, '\\0')); // must be of the same type\n\n\nassert(-1 == cmp( std::forward_as_tuple(std::string(\"AAA\"), 20),\n                std::forward_as_tuple(std::string(\"AAA\"), 30)\n              ));\n\nstd::string x(\"abcd\");\nassert(0 == cmp( std::forward_as_tuple(x.size(), x),\n                std::forward_as_tuple(x.size(), x)\n                ));\n\n\nstruct user_defined_type\n{\n    // ...\n    // User defined type could provide \u003c and ==\n    bool operator\u003c(const user_defined_type\u0026 other) const\n    {\n        return x_ \u003c other.x_;\n    }\n    bool operator==(const user_defined_type\u0026 other) const\n    {\n        return x_ == other.x_;\n    }\n};\n\nuser_defined_type a(23), b(16);\nassert(1 == cmp(a, b));\n\n\nstruct user_defined_type_cmp\n{\n    // ...\n    // you can also provide 'cmp' member function\n    int cmp(const user_defined_type_cmp\u0026 other) const\n    {\n        if (x_ == other.x_) return 0;\n        return x_ \u003c other.x_ ? -1 : 1;\n    }\n};\nuser_defined_type_cmp c(-10), d(42);\nassert(-1, cmp(c, d));\n\n\nnamespace cppcmp\n{\n    // Also, you can directly provide cmp in cppcmp namespace\n    int cmp(const vector\u003cint\u003e\u0026 a, const vector\u003cint\u003e\u0026 b)\n    {\n        return cmp(a.size(), b.size());\n    }\n}\n```\n\n### Precedence\n\noverrided `cppcmp::cmp` \u003e member function `cmp` \u003e `operator \u003c` + `operator ==`\n\n## License\n\nApache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtfy96%2Fcpp-cmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtfy96%2Fcpp-cmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtfy96%2Fcpp-cmp/lists"}