{"id":18406478,"url":"https://github.com/georgiifirsov/patternmatching","last_synced_at":"2025-04-12T20:29:05.821Z","repository":{"id":159274045,"uuid":"243108668","full_name":"GeorgiiFirsov/PatternMatching","owner":"GeorgiiFirsov","description":"Short header-only library that allows you to use pattern matching in C++. Written in pure standard C++14.","archived":false,"fork":false,"pushed_at":"2020-03-11T20:48:48.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T04:29:04.149Z","etag":null,"topics":["cplusplus","cplusplus-14","cpp","cpp14","functional-programming","pattern-matching","templates"],"latest_commit_sha":null,"homepage":"https://georgyfirsov.github.io/src/cpp_pattern_matching.html","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GeorgiiFirsov.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":"2020-02-25T21:43:12.000Z","updated_at":"2020-03-11T20:48:50.000Z","dependencies_parsed_at":"2023-06-11T16:09:55.733Z","dependency_job_id":null,"html_url":"https://github.com/GeorgiiFirsov/PatternMatching","commit_stats":null,"previous_names":["georgiifirsov/patternmatching"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgiiFirsov%2FPatternMatching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgiiFirsov%2FPatternMatching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgiiFirsov%2FPatternMatching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgiiFirsov%2FPatternMatching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeorgiiFirsov","download_url":"https://codeload.github.com/GeorgiiFirsov/PatternMatching/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248628476,"owners_count":21136087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cplusplus","cplusplus-14","cpp","cpp14","functional-programming","pattern-matching","templates"],"created_at":"2024-11-06T03:09:16.350Z","updated_at":"2025-04-12T20:29:05.772Z","avatar_url":"https://github.com/GeorgiiFirsov.png","language":"C++","readme":"# PatternMatching\n\n**Motivation:** there's no pattern matching in C++, but sometimes it can make your code\nmore clean, than without it. Consider this example:\n\n```cpp\n//\n// You need to call Java fucntion from C++.\n// Usually you do this way:\n//\n\nint JavaCallHelper(int elem)\n{\n    return jni-\u003eCallIntFunction( elem );\n}\n\nfloat JavaCallHelper(float elem)\n{\n    return jni-\u003eCallFloatFunction( elem );\n}\n\ntemplate\u003ctypename _Type\u003e\nauto JavaCall(_Type elem)\n{\n    return JavaCallHelper(elem);\n}\n```\n\nWith pattern matching you can do such beautiful thing:\n```cpp\ntemplate\u003ctypename _Type\u003e\nauto JavaCall(_Type elem)\n{\n    // Elements are passed as tuple in order \n    // to support multiple arguments\n    return match::Match(\n        std::make_tuple( elem ),\n        [](int elem)   { return jni-\u003eCallIntFunction( elem ); },\n        [](float elem) { return jni-\u003eCallFloatFunction( elem ); }\n    );\n}\n```\n\n### Advantages\n\n- Header only library\n- C++14 supported\n- Dispatch is a compile-time process =\u003e no runtime delay\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgiifirsov%2Fpatternmatching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgiifirsov%2Fpatternmatching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgiifirsov%2Fpatternmatching/lists"}