simontoth, 1 month ago to cpp When working with exceptions in C++, there are three main levels of guarantees a function can provide when an exception is thrown. 🧵👇 Compiler Explorer link: https://compiler-explorer.com/z/T9YKKa5oW #cpp #cplusplus #coding #programming #dailybiteofcpp
When working with exceptions in C++, there are three main levels of guarantees a function can provide when an exception is thrown.
🧵👇
Compiler Explorer link: https://compiler-explorer.com/z/T9YKKa5oW
#cpp #cplusplus #coding #programming #dailybiteofcpp
simontoth, 2 months ago to cpp The std::forward is a conditional r-value (specifically x-value) cast. std::forward is primarily designed to work in conjunction with universal references and will only cast to an r-value if the template argument isn't an l-value reference type. Compiler Explorer link: https://compiler-explorer.com/z/E5dcPh6T3 #cpp #cplusplus #coding #programming #dailybiteofcpp
The std::forward is a conditional r-value (specifically x-value) cast.
std::forward is primarily designed to work in conjunction with universal references and will only cast to an r-value if the template argument isn't an l-value reference type.
Compiler Explorer link: https://compiler-explorer.com/z/E5dcPh6T3
simontoth, 4 months ago to cpp C++20 introduced a set of safe integral comparison functions that can compare different integral types without introducing accidental conversions. Compiler Explorer: https://compiler-explorer.com/z/3Phjhrcqv #cpp #cplusplus #coding #programming #dailybiteofcpp
C++20 introduced a set of safe integral comparison functions that can compare different integral types without introducing accidental conversions.
Compiler Explorer: https://compiler-explorer.com/z/3Phjhrcqv
simontoth, 4 months ago to cpp 📆 Day 21 of Advent of Code 2023 is here. Today, we are counting reachable spaces. 🧐 Very sneaky problem today (specifically part two). 🤓 Maths to the rescue. https://open.substack.com/pub/simontoth/p/daily-bite-of-c-advent-of-code-day-f73?r=1g4l8a&utm_campaign=post&utm_medium=web #cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
📆 Day 21 of Advent of Code 2023 is here. Today, we are counting reachable spaces.
🧐 Very sneaky problem today (specifically part two).
🤓 Maths to the rescue.
https://open.substack.com/pub/simontoth/p/daily-bite-of-c-advent-of-code-day-f73?r=1g4l8a&utm_campaign=post&utm_medium=web
#cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
simontoth, 4 months ago to cpp 📆 Day 18 of Advent of Code 2023 is here. Today, we are digging out a lava duct. 🤯 Part two today was a horrible debug-fest for me. 😋 Anyone who found part two easy? 😅 https://open.substack.com/pub/simontoth/p/daily-bite-of-c-advent-of-code-day-e9d?r=1g4l8a&utm_campaign=post&utm_medium=web #cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
📆 Day 18 of Advent of Code 2023 is here. Today, we are digging out a lava duct.
🤯 Part two today was a horrible debug-fest for me.
😋 Anyone who found part two easy? 😅
https://open.substack.com/pub/simontoth/p/daily-bite-of-c-advent-of-code-day-e9d?r=1g4l8a&utm_campaign=post&utm_medium=web
simontoth, 5 months ago to cpp 📆 Day 7 of Advent of Code 2023 is here. Today, we are analyzing "Poker" hands. 😴 I have to apologize for laziness today. I went the easy route. 🤔 Did you take the time to come up with a fancy encoding to analyze the hands? https://open.substack.com/pub/simontoth/p/daily-bite-of-c-advent-of-code-day-078?r=1g4l8a&utm_campaign=post&utm_medium=web #cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
📆 Day 7 of Advent of Code 2023 is here. Today, we are analyzing "Poker" hands.
😴 I have to apologize for laziness today. I went the easy route.
🤔 Did you take the time to come up with a fancy encoding to analyze the hands?
https://open.substack.com/pub/simontoth/p/daily-bite-of-c-advent-of-code-day-078?r=1g4l8a&utm_campaign=post&utm_medium=web
simontoth, 5 months ago to cpp 📆 Day 2 of Advent of Code 2023 is here. Today, we are parsing information about cubes. 😱 Did you struggle with the parsing? 😉 What was your approach? https://open.substack.com/pub/simontoth/p/daily-bite-of-c-advent-of-code-day-e49?r=1g4l8a&utm_campaign=post&utm_medium=web #cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
📆 Day 2 of Advent of Code 2023 is here. Today, we are parsing information about cubes.
😱 Did you struggle with the parsing? 😉 What was your approach?
https://open.substack.com/pub/simontoth/p/daily-bite-of-c-advent-of-code-day-e49?r=1g4l8a&utm_campaign=post&utm_medium=web
simontoth, 7 months ago to cpp C++20 introduced the <bit> header with a group of functions for manipulating and querying bits in unsigned integers. These functions were previously only available as compiler extensions. Compiler Explorer link: https://compiler-explorer.com/z/qEWzzcfv9 #cpp #cplusplus #coding #programming #dailybiteofcpp
C++20 introduced the <bit> header with a group of functions for manipulating and querying bits in unsigned integers.
These functions were previously only available as compiler extensions.
Compiler Explorer link: https://compiler-explorer.com/z/qEWzzcfv9
simontoth, 10 months ago to cpp Tuesday common C++ interview problem: O(1) region sum. Given a 2D grid of integers, provide a method that calculates the sum of a sub-region: int64_t Grid::region_sum(Coord top_left, Coord bottom_right) const; The methods must operate in O(1). You are allowed preprocessing and O(|grid|) memory. Solve it yourself: https://compiler-explorer.com/z/nxvqrqfWq Solution: https://compiler-explorer.com/z/31GMbscxT #cpp #cplusplus #coding #programming #dailybiteofcpp
Tuesday common C++ interview problem: O(1) region sum.
Given a 2D grid of integers, provide a method that calculates the sum of a sub-region:
The methods must operate in O(1). You are allowed preprocessing and O(|grid|) memory.
Solve it yourself: https://compiler-explorer.com/z/nxvqrqfWq Solution: https://compiler-explorer.com/z/31GMbscxT
simontoth, 10 months ago to cpp The C++23 standard introduced a monadic interface for std::optional<T>. transform(f(T)->U)->std::optional<U> only invoked when the source isn't empty and_then(f(T)->std::optional<U>)->std::optional<U> only invoked when the source isn't empty or_else(f()->std::optional<T>)->std::optional<T> only invoked when the source is empty Compiler Explorer link: https://compiler-explorer.com/z/4dzc776Gq #cpp #cplusplus #coding #programming #dailybiteofcpp
The C++23 standard introduced a monadic interface for std::optional<T>.
only invoked when the source isn't empty
only invoked when the source is empty
Compiler Explorer link: https://compiler-explorer.com/z/4dzc776Gq