Code implementations for various C++ challenges as found in the book The Modern C++ Challenge. The code is organized into folders that follow the various sections of the books. Each solutions will include a readme or a full write up on my blog.
The code in this repository requires:
- C++17 compliant compiler
- CMake
Optionally, you can also build unit tests for most of the code. If you turn this option on, you will also need:
- GTest
Simply configure and build with CMake. No other external dependencies are needed.
This challenge involved modeling an IPv4 address in C++. The specific requirements were:
- Be able to read an address from a string like:
ip::address addr = ip::from_string("127.0.0.1");
- Be able to write an address to a string.
- Be able to enumerate a range of addresses; for example:
ip::address start = {0,0,0,0};
ip::address end = {255, 255, 255, 255};
while(start < end)
{
start++;
std::cout << start << std::endl;
}
Full write up is availble on my blog.
This challenge involved modeling a 2D array in C++ with support for:
- Element access (
at()
anddata()
) - Capacity querying
- Iterators
- Filling
- Swapping
- Movable
mcc::matrix<double, 3, 3> data;
std::iota(data.begin(), data.end(), 1.0);
/*
data now looks like
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
*/