https://github.com/goblinhack/c-plus-plus-examples
A collection of C++ examples, all compilable. Covers from C++11 to C++20.
https://github.com/goblinhack/c-plus-plus-examples
c-plus-plus c-plus-plus-11 c-plus-plus-14 c-plus-plus-17 cplusplus cplusplus-11 cplusplus-14 cplusplus-17 std std-map std-thread tutorial
Last synced: 8 months ago
JSON representation
A collection of C++ examples, all compilable. Covers from C++11 to C++20.
- Host: GitHub
- URL: https://github.com/goblinhack/c-plus-plus-examples
- Owner: goblinhack
- License: gpl-2.0
- Created: 2020-05-14T14:05:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-25T19:03:55.000Z (10 months ago)
- Last Synced: 2025-04-10T01:08:17.443Z (8 months ago)
- Topics: c-plus-plus, c-plus-plus-11, c-plus-plus-14, c-plus-plus-17, cplusplus, cplusplus-11, cplusplus-14, cplusplus-17, std, std-map, std-thread, tutorial
- Language: C++
- Homepage:
- Size: 1.2 MB
- Stars: 16
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Modern C++ examples
===================
Are you looking for a collection of short straightforward snippets of
modern C++ covering the core features in C++11 and beyond? Of course
you are!
As I'm constantly learning C++ myself (disclaimer, I'm not an expert,
just enthusiastic), I wanted to create some simple examples of each
of the main features of the language. You can build each example
individually or as a whole.
Let me know if this is useful to anyone or if there are any areas you want
covered. Suggestions, enhancements and errata welcome.
This is a (probably perpetual) work in progress!
[How to print hello world in color in C++, because why not](hello_world_color/README.md)
[How to use read a file in far too many ways](std_file_read/README.md)
[How to use scoped enums](scoped_enums/README.md)
[How to use std::initializer_list](initializer_lists/README.md)
[How to use std::initializer_list with your own container like class](initializer_lists_with_custom_vector/README.md)
[How to use constexpr for fame and profit](constexpr/README.md)
[How to use decltype](decltype/README.md)
[How to use range-based for loops](range_based_for_loop/README.md)
[How to use range-based for loops with your own iterator](range_based_for_loop_custom_begin_end/README.md)
[How to use lambdas](lambda/README.md)
[How to use std::to_string with custom classes and templates](std_to_string/README.md)
[How to use std::for_each and how it differs from std::transform](std_for_each_and_transform/README.md)
[How to use std::map with a custom key](std_map_with_custom_key/README.md)
[How to use std::map for reverse sorting](std_map_reverse_sort/README.md)
[How to use std::unordered_map](std_unordered_map/README.md)
[How to use std::multiset and std::multiset::equal_range](std_multiset/README.md)
[How to use std::set](std_set/README.md)
[How to use std::unordered_set](std_unordered_set/README.md)
[How to use std::sort with a custom container and iterators](std_sort_with_custom_iterators/README.md)
[How to use std::function and the 'using' keyword](std_function_and_using/README.md)
[How to use std::bind](std_bind/README.md)
[How to use std::bind with methods or proxy functions](std_bind_with_a_method/README.md)
[How to use std::bind with callback inside a class](std_bind_with_a_class_callback/README.md)
[How to use std::move to avoid the cost of temporaries](std_move/README.md)
[How to use std::forward to invoke the exactly correct function through a template](std_forward/README.md)
[How to use std::unique_ptr](std_unique_ptr/README.md)
[How to use std::unique_ptr with a custom deallocator](std_unique_ptr_with_custom_deallocator/README.md)
[How to use std::unique_ptr for file handling](std_unique_ptr_for_file_handling/README.md)
[How to use std::shared_ptr](std_shared_ptr/README.md)
[How to use std::shared_ptr with your own wrapper for extra debugging](std_shared_ptr_wrapper/README.md)
[How to use std::thread in three different ways](std_thread/README.md)
[How to use std::thread and std::mutex to implement a timeout around a function](std_thread_timeout/README.md)
[How to use variadic templates for recursion instanity](variadic_templates/README.md)
[How to use std::thread and variadic templates to call a function with variable number and types of args](std_thread_timeout_template/README.md)
[How to use std::function with variadic templates](std_function_with_variadic_template/README.md)
[TODO How to use std::remove_if and std::erase](TODO/README.md)
[TODO How to use std::erase_if](TODO/README.md)
[TODO How to use std::mutex](TODO/README.md)
[TODO How to use std::chrono](TODO/README.md)
[TODO How to use std::accumulate and std::reduce](TODO/README.md)
To build all the examples, just do:
```C++
make
```
To build all the examples and the documentation and run every examle, do:
```C++
sh ./RUNME
```