{"id":23542938,"url":"https://github.com/cypri1-dev/42_cpp07","last_synced_at":"2025-05-15T06:31:24.374Z","repository":{"id":268791139,"uuid":"905480044","full_name":"cypri1-dev/42_CPP07","owner":"cypri1-dev","description":"This project introduces C++ templates with three tasks: implementing functions to swap values, return the smaller or larger of two, applying a function to each array element, and creating a dynamic array class with bounds checking, size retrieval, and safe memory management.","archived":false,"fork":false,"pushed_at":"2024-12-19T13:52:03.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T09:25:32.201Z","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/cypri1-dev.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":"2024-12-18T23:09:57.000Z","updated_at":"2024-12-19T13:52:07.000Z","dependencies_parsed_at":"2024-12-19T00:23:36.060Z","dependency_job_id":"72fb0848-93ad-4cde-9c8a-7cf2471bea2c","html_url":"https://github.com/cypri1-dev/42_CPP07","commit_stats":null,"previous_names":["cypri1-dev/42_cpp07"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cypri1-dev%2F42_CPP07","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cypri1-dev%2F42_CPP07/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cypri1-dev%2F42_CPP07/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cypri1-dev%2F42_CPP07/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cypri1-dev","download_url":"https://codeload.github.com/cypri1-dev/42_CPP07/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254287852,"owners_count":22045862,"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":[],"created_at":"2024-12-26T06:17:03.271Z","updated_at":"2025-05-15T06:31:24.349Z","avatar_url":"https://github.com/cypri1-dev.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003e\u003cimg src=\"https://raw.githubusercontent.com/ayogun/42-project-badges/refs/heads/main/covers/cover-cpp-bonus.png\"\u003e\u003c/h1\u003e \n\n## Table of Contents\n\n- [Overview](#overview)\n- [Exercises](#exercises)\n  - [Exercise 00: Generic Functions](#exercise-00-generic-functions)\n  - [Exercise 01: `iter` Function](#exercise-01-iter-function)\n  - [Exercise 02: Template Class `Array`](#exercise-02-template-class-array)\n- [Requirements](#requirements)\n- [Usage](#usage)\n\n## Overview\n\nThis module explores C++ templates through practical exercises to enhance understanding and application. Each task focuses on creating flexible and reusable code.\n\n## Exercises\n\n### Exercise 00: Generic Functions\n\n- **Objective**: Implement the following generic functions:\n  - `swap`: Exchanges the values of two arguments.\n  - `min`: Returns the smaller of two values. If equal, returns the second value.\n  - `max`: Returns the larger of two values. If equal, returns the second value.\n- **Key Features**:\n  - Functions must work with any comparable types.\n  - Templates must be defined in header files.\n\n### Exercise 01: `iter` Function\n\n- **Objective**: Implement a template function `iter` that applies a given function to each element of an array.\n- **Key Features**:\n  - Takes the address of an array, its length, and a function to apply.\n  - Works with any type of array.\n\n### Exercise 02: Template Class `Array`\n\n- **Objective**: Develop a template class `Array` to handle elements of type `T`.\n- **Key Features**:\n  - Constructor without parameters: Creates an empty array.\n  - Constructor with `unsigned int n`: Creates an array of `n` elements initialized by default.\n  - Copy constructor and assignment operator: Ensure modifying one does not affect the other.\n  - Access elements via `[]` with bounds checking. Throws an exception if out of bounds.\n  - Member function `size()`: Returns the number of elements in the array.\n\n## Requirements\n\n- Templates must be fully implemented in header files.\n- Memory management must use `new[]` without over-allocating.\n- Code must not access unallocated memory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcypri1-dev%2F42_cpp07","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcypri1-dev%2F42_cpp07","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcypri1-dev%2F42_cpp07/lists"}