{"id":19368340,"url":"https://github.com/jerryym/cpp_template","last_synced_at":"2026-06-13T03:34:08.342Z","repository":{"id":154877603,"uuid":"348270193","full_name":"Jerryym/Cpp_Template","owner":"Jerryym","description":"函数模板与类模板","archived":false,"fork":false,"pushed_at":"2022-03-27T11:38:20.000Z","size":534,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-18T03:03:37.880Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jerryym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-03-16T08:33:52.000Z","updated_at":"2022-03-19T11:26:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"a8e4dfec-8fe7-45fa-9ac2-d3f07c3370ba","html_url":"https://github.com/Jerryym/Cpp_Template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Jerryym/Cpp_Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerryym%2FCpp_Template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerryym%2FCpp_Template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerryym%2FCpp_Template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerryym%2FCpp_Template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jerryym","download_url":"https://codeload.github.com/Jerryym/Cpp_Template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerryym%2FCpp_Template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34271500,"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-13T02:00:06.617Z","response_time":62,"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-10T08:06:11.373Z","updated_at":"2026-06-13T03:34:08.327Z","avatar_url":"https://github.com/Jerryym.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 函数模板与类模板\n- 参数化多样性：将程序所处理的对象的类型参数化，使得一段程序可以用于处理多种不同类型的对象\n\n### 函数模板\n- 定义形式\n\n```\ntemplate\u003c模板参数表\u003e\n类型名 函数表(参数表)\n{\n    函数体的定义\n}\n```\n- 模板参数表\n    - class(或typename)标识符，指明可以接收一个类型参数\n    - \"类型说明符\"标识符，指明可以接收一个由\"类型说明符\"所规定类型的常量作为参数\n    - template\u003c参数表\u003eclass标识符，指明可以接收一个类模板名作为参数\n- 函数模板的使用形式与函数的区别\n    - 函数模板本省再编译时不生成任何目标代码，只有由模板生成的实例会生成目标代码\n    - 被多个源文件引用的函数模板，应当连同函数体一同放在头文件中，而不能像普通函数那样只将声明放在头文件中\n    - 函数指针只能指向模板的实例，不能指向模板本身\n\n### 类模板\n- 可以为类定义一种模式，使得类中的某些数据成员、某些成员函数的参数、返回值或局部变量能去任意类型\n- 语法形式\n\n```\ntemplate\u003c模板参数表\u003e\nclass 类名\n{\n    类成员声明\n}\n```\n- 在类模板外定义成员函数，其语法形式\n\n```\ntemplate\u003c模板参数表\u003e\n类型名 类名\u003c模板参数标识符列表\u003e::函数名(参数表)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerryym%2Fcpp_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerryym%2Fcpp_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerryym%2Fcpp_template/lists"}