Git Product home page Git Product logo

c-plus-plus-examples's Introduction

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

How to use read a file in far too many ways

How to use scoped enums

How to use std::initializer_list

How to use std::initializer_list with your own container like class

How to use constexpr for fame and profit

How to use decltype

How to use range-based for loops

How to use range-based for loops with your own iterator

How to use lambdas

How to use std::to_string with custom classes and templates

How to use std::for_each and how it differs from std::transform

How to use std::map with a custom key

How to use std::map for reverse sorting

How to use std::unordered_map

How to use std::multiset and std::multiset::equal_range

How to use std::set

How to use std::unordered_set

How to use std::sort with a custom container and iterators

How to use std::function and the 'using' keyword

How to use std::bind

How to use std::bind with methods or proxy functions

How to use std::bind with callback inside a class

How to use std::move to avoid the cost of temporaries

How to use std::forward to invoke the exactly correct function through a template

How to use std::unique_ptr

How to use std::unique_ptr with a custom deallocator

How to use std::unique_ptr for file handling

How to use std::shared_ptr

How to use std::shared_ptr with your own wrapper for extra debugging

How to use std::thread in three different ways

How to use std::thread and std::mutex to implement a timeout around a function

How to use variadic templates for recursion instanity

How to use std::thread and variadic templates to call a function with variable number and types of args

How to use std::function with variadic templates

TODO How to use std::remove_if and std::erase

TODO How to use std::erase_if

TODO How to use std::mutex

TODO How to use std::chrono

TODO How to use std::accumulate and std::reduce

To build all the examples, just do:

   make 

To build all the examples and the documentation and run every examle, do:

   sh ./RUNME

c-plus-plus-examples's People

Contributors

goblinhack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.