Giter Site home page Giter Site logo

packtpublishing / the-modern-cpp-challenge Goto Github PK

View Code? Open in Web Editor NEW
302.0 27.0 102.0 12.63 MB

The Modern C++ Challenge, published by Packt

License: MIT License

CMake 0.45% C++ 26.42% Python 2.55% C 55.46% Makefile 5.72% Awk 0.04% Shell 2.87% M4 1.27% HTML 0.11% Batchfile 0.11% Assembly 0.22% Perl 1.15% Roff 3.07% DIGITAL Command Language 0.49% Objective-C++ 0.03% VBScript 0.03% Raku 0.02%

the-modern-cpp-challenge's Introduction

$5 Tech Unlocked 2021!

The $5 campaign runs from December 15th 2020 to January 13th 2021.

The Modern C++ Challenge

This is the code repository for The Modern C++ Challenge, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

About the Book

C++ is one of the most widely-used programming languages and has applications in a variety of fields, such as gaming, GUI programming, and operating systems, to name a few. Through the years, C++ has evolved into (and remains) one of the top choices for software developers worldwide. This book will show you some notable C++ features and how to implement them to meet your application needs. Each problem is unique and doesn't just test your knowledge of the language; it tests your ability to think out of the box and come up with the best solutions. With varying levels of difficulty, you'll be faced with a wide variety of challenges. And in case you're stumped, you don't have to worry: we've got the best solutions to the problems in the book. So are you up for the challenge?

Instructions and Navigation

All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02.

The code will look like the following:

int main()
{
   std::cout << "Hello, World!\n";
}

As previously mentioned, you need a basic familiarity with the C++ language and the standard library in order to be able to utilize this book, or you can learn that along the way. In any case, this book will teach you how to solve problems, but it will not teach you about the language and features utilized in the solutions. You will need a compiler with C++17 support; a complete list of required libraries as well as possible compilers you can use can be found in the Software Hardware List available in the code bundle. In the following sections, you will find detailed instructions for downloading and building the code from this book.

Errata

  • The correct implementation for the postfix operator++ is as follows:
ipv4 operator++(int)
{
   ipv4 result(*this);
   ++(*this);
   return result;
}
  • Page 250: The first line of the second code block must be read as "std::vector encoder::from_base64(std::string data)" instead of "std::vector encored::from_base64(std::string data)".

Related Products

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781789535426

the-modern-cpp-challenge's People

Contributors

gaurav-packt avatar jijom avatar packt-itservice avatar packt-pradeeps avatar packtutkarshr avatar shruthis-shetty avatar

Stargazers

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

Watchers

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

the-modern-cpp-challenge's Issues

does codes compile on Linux?

Hi,

I have tried some of examples to compile but have got failed to do. Just wonder if it does have specific requirement to compile on Linux such as gcc or C++ version?

For example:

The-Modern-Cpp-Challenge/Chapter02/problem_19

template<typename C, typename... Args>
void push_back(C& c, Args&&... args)
{
(c.push_back(args), ...);
}

c02.cpp:1175:27: error: expected primary-expression before ‘...’ token
(c.push_back(args), ...);
^
c02.cpp:1175:27: error: expected ‘)’ before ‘...’ token
c02.cpp:1175:31: error: parameter packs not expanded with ‘...’:
(c.push_back(args), ...);
^
c02.cpp:1175:31: note: ‘args’

Uses gcc (Debian 4.9.2-10) 4.9.2

Is that code wrong or have I something missed?

Many thanks

Chapter 2/ Problem 16

the postfix operator++ does not work correctly, because it returns this* instead result:

    ipv4& operator++(int)  // need return by value ipv4 opetrator++(int)
    {
        ipv4 result(*this);
        ++(*this);
        return *this; // need result
    }

Chapter03/problem_26 alternative solution

About the proposed solution on
https://github.com/PacktPublishing/The-Modern-Cpp-Challenge/blob/master/Chapter03/problem_26/main.cpp

Maybe a bit more compact solution could be:

#include <iostream>
#include <vector>
#include <sstream>
#include <cassert>

using namespace std;

template <typename C>
string join_strings(C const & c, const char delimiter) {
    ostringstream oss;
    for (const auto &i : c) {
        if(oss.tellp()) oss << delimiter;
        oss << i;
    }
    return oss.str();
}

int main()
{
    auto l1 = {"one"s, "two"s, "three"s};
    assert(join_strings(l1,' ') == "one two three"s );
    auto l2 = {""s};
    assert(join_strings(l2,' ') == ""s );
    auto l3 = vector<string>();
    assert(join_strings(l3,' ') == ""s );
    auto l4= vector<string> {"one"}; // C str
    assert(join_strings(l4,' ') == "one"s );
    return 0;
}

The link on README direct to a 404 web page

This is the code repository for The Modern C++ Challenge, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

first link from this paragraph direct to an 404 page

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.