Why std::stable_sort does not compile when std::sort does?
The code below fails to compile on GCC and CLang (msvc fails because of the experimental/propagate_const).
Why the type of the iterator to `std::views::transform` does not seem to be a deterministic type?
I want to get the type of the iterator to the const-casted contents of the vector. I thought I can use decltype
for it.
Why the type of the iterator to `std::views::transform` does not seem to be a deterministic type?
I want to get the type of the iterator to the const-casted contents of the vector. I thought I can use decltype
for it.
Why the type of the iterator to `std::views::transform` does not seem to be a deterministic type?
I want to get the type of the iterator to the const-casted contents of the vector. I thought I can use decltype
for it.
How to write a const iterator to const std::shared_ptr stored in std::vector<std::shared_ptr>?
Suppose I have vector of pointers to objects of class Widget
, which are heavy objects with no owner. More often than not, my code needs to iterate over this vector, but needs only access to const Widget
.
auto and template argument deduction
While reading C++ 20 book came across this function:
Macro resolving to #define or constexpr depending on #if _cplusplus
I have a header file of constants shared among both C++ and C executables. I don’t want to duplicate the constants which I want as constexpr
in C++ and #define
s in C.
What is the difference between std::fill_n and std::ranges::fill_n?
I’m having a hard time seeing the practical difference between std::fill_n and std::ranges::fill_n.
Check if type T is a std::span
I am iterating over an argument sequence at compile-time, and I want to check if one of the arguments may be a span. If so, I will do span-things.
std::generate – access previous element in vector
I am using std::generate to construct a struct and push into a vector. In order to construct the struct, I need to refer to the previous struct in the sequence. Is there any way to do this in c++20 ? I would rather not use boost or a 3rd party library.
Thank you!