gitwtfhub

wtf is cpp-primer?

mooophy/cpp-primer — explained in plain English

Analysis updated 2026-06-24

8,297C++Audience · developerComplexity · 1/5LicenseSetup · moderate

TL;DR

A complete set of worked exercise solutions for the C++ Primer textbook (5th edition), organized chapter by chapter across all 19 chapters, covering modern C++11 and C++14 with compilable source files.

Mindmap

mindmap
  root((cpp-primer))
    Content
      Chapter solutions
      19 chapters
      C++11 and C++14
    Topics covered
      Variables and classes
      Standard library
      Templates
      Advanced features
    How to use
      Compare solutions
      Compile and run
      Study reference
    Compilers
      Visual Studio
      GCC
      Clang

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Check your answer to a C++ Primer exercise against a reference implementation when you get stuck.

REASON 2

Study how C++11 and C++14 features like lambdas, move semantics, and templates are used correctly in practice.

REASON 3

Compile and run individual exercise solutions to see the expected output and understand the intended behavior.

What's in the stack?

C++

How it stacks up

mooophy/cpp-primerlove2d/lovestd-microblock/chromatic
Stars8,2978,2998,287
LanguageC++C++C++
Setup difficultymoderateeasymoderate
Complexity1/53/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · moderate Time to first run · 30min

Each file must be compiled with C++14 support: use -std=c++14 on Linux or -std=c++1y on macOS.

Released into the public domain under CC0, use for any purpose with no restrictions whatsoever.

Wtf does this do

This repository is a collection of worked answers to the exercises in C++ Primer, 5th Edition, a widely used textbook for learning the C++ programming language. The solutions cover the modern C++11 and C++14 standards that the book's 5th edition introduced. The repository is organized to match the book's chapter structure. It runs from Chapter 1 (Getting Started) through all four major parts of the book: the basics of variables, strings, functions, and classes, the standard C++ library including containers and algorithms, tools for building reusable classes, and advanced topics such as templates and specialized library features. In total, answers are available across all 19 chapters. Each exercise solution is stored as a C++ source file you can compile and run yourself. The README lists the compilers the author recommends: Visual Studio 2015 or later on Windows, g++ 5.0 or later on Linux, and Clang 3.7 or later on macOS. Each file needs to be compiled with a C++14 flag, such as -std=c++14 on Linux or -std=c++1y on macOS. The repository is licensed under CC0, which means the code has been placed in the public domain and you can use it for any purpose without restriction. If you are working through C++ Primer and get stuck on an exercise, this is a reference to compare your approach against. The solutions were contributed over time by the repository owner and others, and some chapters may have fuller coverage than others. There is also a linked Chinese-language discussion group for readers who prefer that.

Yoink these prompts

Prompt 1
I'm stuck on C++ Primer Chapter 12, exercise 12.14. Show me a solution using shared_ptr that correctly manages a StrBlob dynamic array.
Prompt 2
In the cpp-primer solutions, how is a Chapter 16 templates exercise structured? Explain how function template type deduction works in that example.
Prompt 3
I want to compile a solution from the cpp-primer repo on macOS with Clang. What flags do I need and how do I run it?
Prompt 4
Show me how the cpp-primer solutions handle Chapter 7 class exercises, specifically constructors, member functions, and access control.

Frequently asked questions

wtf is cpp-primer?

A complete set of worked exercise solutions for the C++ Primer textbook (5th edition), organized chapter by chapter across all 19 chapters, covering modern C++11 and C++14 with compilable source files.

What language is cpp-primer written in?

Mainly C++. The stack also includes C++.

What license does cpp-primer use?

Released into the public domain under CC0, use for any purpose with no restrictions whatsoever.

How hard is cpp-primer to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is cpp-primer for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.