{"name":"cpp-cheatsheet: A Comprehensive Modern C++ Reference Guide","description":"The cpp-cheatsheet repository by mortennobel offers a concise and comprehensive reference for modern C++, covering C++11 and C++14 features. It serves as an invaluable resource for developers looking for quick syntax reminders and standard library usage. This cheatsheet is ideal for both learning and daily development tasks.","github":"https://github.com/mortennobel/cpp-cheatsheet","url":"https://osrepos.com/repo/mortennobel-cpp-cheatsheet","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/mortennobel-cpp-cheatsheet","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/mortennobel-cpp-cheatsheet.md","json":"https://osrepos.com/repo/mortennobel-cpp-cheatsheet.json","topics":["cheatsheet","cpp","cpp11","cpp14","C++","programming","reference","development"],"keywords":["cheatsheet","cpp","cpp11","cpp14","C++","programming","reference","development"],"stars":null,"summary":"The cpp-cheatsheet repository by mortennobel offers a concise and comprehensive reference for modern C++, covering C++11 and C++14 features. It serves as an invaluable resource for developers looking for quick syntax reminders and standard library usage. This cheatsheet is ideal for both learning and daily development tasks.","content":"## Introduction\n\nThe [cpp-cheatsheet](https://github.com/mortennobel/cpp-cheatsheet) repository, maintained by mortennobel, provides a concise and comprehensive reference for modern C++. This cheatsheet is an invaluable resource for anyone working with C++, specifically focusing on features introduced in C++11 and C++14. It is based on Phillip M. Duxbury's C++ Cheatsheet and further edited by Morten Nobel-Jørgensen, with C++11 additions inspired by ISOCPP.org. The primary goal is to offer a clear, quick overview of essential C++ concepts and standard library components.\n\n## Installation\n\nTo make use of the cpp-cheatsheet, there is no traditional \"installation\" required as it is a documentation-based repository. You can access the full content directly on GitHub or clone the repository to have a local copy for offline reference.\n\nTo clone the repository, use the following command:\n\nbash\ngit clone https://github.com/mortennobel/cpp-cheatsheet.git\n\n\nOnce cloned, you can open the `README.md` file in your preferred markdown viewer or directly browse the content in your terminal.\n\n## Examples\n\nThe cheatsheet covers a wide range of C++ topics, from basic syntax to advanced features and standard library usage. Here are a few examples of the structured information you'll find:\n\n### Preprocessor\n\ncpp\n                            // Comment to end of line\n                            /* Multi-line comment */\n#include  <stdio.h>         // Insert standard header file\n#include \"myfile.h\"         // Insert file in current directory\n#define X some text         // Replace X with some text\n#define F(a,b) a+b          // Replace F(1,2) with 1+2\n#define X \\\n some text                  // Multiline definition\n#undef X                    // Remove definition\n#if defined(X)              // Conditional compilation (#ifdef X)\n#else                       // Optional (#ifndef X or #if !defined(X))\n#endif                      // Required after #if, #ifdef\n\n\n### Literals\n\ncpp\n255, 0377, 0xff             // Integers (decimal, octal, hex)\n2147483647L, 0x7fffffffl    // Long (32-bit) integers\n123.0, 1.23e2               // double (real) numbers\n'a', '\\141', '\\x61'         // Character (literal, octal, hex)\n'\\n', '\\\\', '\\'', '\\\"'      // Newline, backslash, single quote, double quote\n\"string\\n\"                  // Array of characters ending with newline and \\0\n\"hello\" \"world\"             // Concatenated strings\ntrue, false                 // bool constants 1 and 0\nnullptr                     // Pointer type with the address of 0\n\n\n### Memory Management with `shared_ptr`\n\ncpp\n#include <memory>           // Include memory (std namespace)\nshared_ptr<int> x;          // Empty shared_ptr to a integer on heap. Uses reference counting for cleaning up objects.\nx = make_shared<int>(12);   // Allocate value 12 on heap\nshared_ptr<int> y = x;      // Copy shared_ptr, implicit changes reference count to 2.\ncout << *y;                 // Dereference y to print '12'\nif (y.get() == x.get()) {   // Raw pointers (here x == y)\n    cout << \"Same\";  \n}  \ny.reset();                  // Eliminate one owner of object\nif (y.get() != x.get()) { \n    cout << \"Different\";  \n}  \nif (y == nullptr) {         // Can compare against nullptr (here returns true)\n    cout << \"Empty\";  \n}  \ny = make_shared<int>(15);   // Assign new value\ncout << *y;                 // Dereference x to print '15'\ncout << *x;                 // Dereference x to print '12'\n\n\n## Why Use This\n\nThe cpp-cheatsheet is an excellent resource for several reasons:\n\n*   **Comprehensive Coverage:** It provides a broad overview of C++ syntax, standard library components, and modern features up to C++14.\n*   **Quick Reference:** Its concise format makes it perfect for quickly looking up syntax or function signatures during development or study.\n*   **Educational Tool:** Ideal for students learning C++ or experienced developers brushing up on specific topics.\n*   **Modern C++ Focus:** Explicitly highlights C++11 and C++14 additions, ensuring relevance for contemporary projects.\n*   **Community Driven:** The repository encourages comments and feedback, fostering continuous improvement.\n\n## Links\n\n*   **GitHub Repository:** [https://github.com/mortennobel/cpp-cheatsheet](https://github.com/mortennobel/cpp-cheatsheet){:target=\"_blank\"}","metrics":{"detailViews":8,"githubClicks":4},"dates":{"published":null,"modified":"2026-03-01T09:12:44.000Z"}}