Mentions légales du service

Skip to content
Snippets Groups Projects
Sébastien Gilles's avatar
GILLES Sebastien authored
Types notebook: add the possibility to declare std::string from string litterals with 's' suffix (I learned that while preparing string view notebooks).
602a031e
History

Table of Contents

About this tutorial

This tutorial is heavily inspired from a C++ tutorial created by David Chamont (CNRS) that was given as a lecture with the help of Vincent Rouvreau (Inria) in 2016; latest version of this tutorial used as the basis of current one may be found there.

Current version provides two major modifications:

  • The tutorial is now in english.
  • Jupyter notebooks using Xeus-cling kernel are now used, thus enabling a sort of interpreted C++ which is rather helpful for teaching it (even if it is clearly not yet mature...)

I have rewritten entirely and modified heavily several chapters, but the backbone remains heavily indebted to David and Vincent and the TP is still very similar to the original one.

As the original tutorial, the present lecture is released under the Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) licence.

Goal of this tutorial

This is an introductory lecture to the modern way of programming C++; at the end of it you should:

  • Understand the syntax and basic mechanisms of the C++ language in version 14/17.
  • Know the different programming styles.
  • Know of and be able to use the most useful part of the standard library.
  • Be aware of many good programming practices in C++.

How to run it?

Local installation

As this tutorial relies heavily on Xeus-cling kernel, the only requirement is to install this environment on your machine.

Unfortunately, the support of this kernel is still experimental on Windows; I advise you to use any variant of Linux or macOS (for Windows 10 users you may install Ubuntu in your Windows session; I haven't tried this myself).

Should the procedure described below not work at some point I invite you to check the link above, but at the time of this writing you need to:

  • Install miniconda3 environment (apparently using full-fledged anaconda may lead to conflict in dependencies).
  • Create a new conda environment and activate it:
conda env create -f environment.yml
conda activate formation_cpp

Don't forget to activate it each time you intend to run the lecture!

WARNING At the moment, Conda packaging is broken for the most recent version of macOS (11.3). A ticket has been issued and is under work; in the meanwhile use Binder (or a workaround through a Docker image).

  • Then you can run the notebook by going into its root directory (or internal links won't work...) in a terminal and typing:
jupyter lab

BEWARE: I strongly advise to use a dedicated environment for the notebook: the ultimate goal is to use a real C++ environment for your project, and the anaconda environment hides the native C++ compiler on your machine.

NOTE: It is possible to use the notebooks directly from some IDEs like VSCode.

Docker machine

It is possible to execute the notebooks from a Docker machine by simply:

docker run -p 8888:8888 registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp:latest

The simply in your browser just simply go to http://localhost:8888/.