A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rturrado/the_modern_cpp_challenge below:

rturrado/the_modern_cpp_challenge: My solutions to the 100 problems of The Modern C++ Challenge, a book by Marius Bancila (published by Packt).

My solutions to the 100 problems of The Modern C++ Challenge, a book by Marius Bancila (published by Packt).

These exercises were initially implemented as a project within a bigger Visual Studio solution, Catching up with modern C++, as a way of practicing modern C++ (11/14/17/20). However, anyone downloading that project would need to:

The goal behind The Modern C++ Challenge project is twofold. On one hand, let users download, build, and execute the code with a minimal effort (ideally without needing to install any library). On the personal side, get some hands-on experience with CMake and other tools of the C++ ecosystem. I've also taken the chance to improve the original code with:

Since the unixlike-builds branch uses gcc, which doesn't have support yet for all the C++20 features (especially the <format> library), a few problems are implemented differently in that branch. Basically, the date and time problems use Howard Hinnant's <date> library instead of the <format> library. This should be the only difference between main release v2.0.0 unixlike-builds release v1.0.0.

Once gcc will have support for all the C++20 features, the main branch should be suitable to be used in Unix-like systems, and the unixlike-builds branch should be dropped.

The instructions below refer to Windows/msvc.

Most of the required software can be installed from the Visual Studio 2022 Installer.

You can download the current version of the Boost libraries from https://www.boost.org/users/download/.

Should you want to make use of sccache (https://github.com/mozilla/sccache), you could install it via scoop.

From a PowerShell terminal, as non-administrator:

PS C:\> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
PS C:\> irm get.scoop.sh | iex
PS C:\> scoop install sccache

From a cmd:

C:\projects> git config core.symlinks true
C:\projects> git clone --recurse-submodules https://github.com/rturrado/the_modern_cpp_challenge

There are several options to run CMake from Visual Studio.

C:\projects\the_modern_cpp_challenge> cmake --preset windows-msvc-debug-tests

From Visual Studio, once CMake finishes, type CTRL+B or build from Build > Build All menu.

Or, from the command line:

C:\projects\the_modern_cpp_challenge> cmake --build --preset windows-msvc-debug-tests

The following build presets are available (the configuration presets have the same name):

All successful builds will generate:

Builds with the option -DTHE_MODERN_C++_CHALLENGE_BUILD_TESTS=ON (debug build presets) will also generate:

Builds with the option -DTHE_MODERN_C++_CHALLENGE_BUILD_BENCHMARKS=ON (release-benchmarks and release-github build presets) will also generate:

From Visual Studio: the main binary receives a res folder as an argument (a resource directory used by some of the problems). The way to set this parameter from within Visual Studio is via the .vs\launch.vs.json, which is not in the repository since it is a user file. The example below shows a possible launch.vs.json file. Notice args only contains the path of the res folder. Notice also that you should provide one configuration entry per output binary (not for the benchmark binary).

{
  "version": "0.2.1",
  "defaults": {},
    "configurations": [
        {
            "type": "default",
            "project": "CMakeLists.txt",
            "projectTarget": "the_modern_c++_challenge.exe (src\\Debug\\the_modern_c++_challenge.exe)",
            "name": "the_modern_c++_challenge.exe (src\\Debug\\the_modern_c++_challenge.exe)",
            "args": [
                "C:\\projects\\the_modern_c++_challenge\\res"
            ]
        }
    ]
}

Choose the_modern_c++_challenge.exe from Select Startup Item, and click the green "play" button.

Or, from the command line:

C:\projects\the_modern_cpp_challenge> .\out\build\windows-msvc-debug-tests\src\Debug\the_modern_c++_challenge.exe res

Build with:

C:\projects\the_modern_cpp_challenge> cmake --preset windows-msvc-debug-tests
C:\projects\the_modern_cpp_challenge> cmake --build --preset windows-msvc-debug-tests

You can run the test executable directly:

C:\projects\the_modern_cpp_challenge> .\out\build\windows-msvc-debug-tests\test\Debug\the_modern_c++_challenge_test.exe res

Or execute the tests via ctest:

C:\projects\the_modern_cpp_challenge\out\build\windows-msvc-debug-tests> ctest -C Debug --output-on-failure

Alternatively, if you want a less verbose ouptut:

C:\projects\the_modern_cpp_challenge> .\out\build\windows-msvc-debug-tests\test\Debug\the_modern_c++_challenge_test.exe res --gtest_brief=1

Or:

C:\projects\the_modern_cpp_challenge\out\build\windows-msvc-debug-tests> ctest -C Debug --output-on-failure --progress

Build with:

C:\projects\the_modern_cpp_challenge> cmake --preset windows-msvc-release-benchmarks
C:\projects\the_modern_cpp_challenge> cmake --build --preset windows-msvc-release-benchmarks

And run with:

C:\projects\the_modern_cpp_challenge> .\out\build\windows-msvc-release-benchmarks\benchmark\Release\the_modern_c++_challenge_benchmark.exe

The Boost libraries have to be downloaded by the user before building the project:

The following libraries are used in this project, but are automatically downloaded and made available via CMake's FetchContent:

The same happens with the list below. I'm showing them apart because they are forks of my own. You can check their README files to see how I adapted the original libraries to use them in this project.

Finally, this group of libraries is automatically managed via vcpkg:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4