I were writing a qsort compare function callback for this scenario: int matrix[3][4] = { {1,2,3,4}, {5,6,7,8}, {9,1,2,3}, }; qsort(matrix, 3, ...
I were writing a qsort compare function callback for this scenario: int matrix[3][4] = { {1,2,3,4}, {5,6,7,8}, {9,1,2,3}, }; qsort(matrix, 3, ...
The question is simple: why can't I use propagate_const for arrays? The following line gives errors: The errors (gcc version 13.0): The the goa ...
Const casting container value-types seems not possible. A comment in the other question suggests iterators as a solution, yet does not go into detail. ...
I want to write a generic functions that takes in a sequence, while guaranteeing to not alter said sequence. Yet the above example still would take ...
What I need is to get an Element in a certain index from the collection to do operations like Element::insertValues. It is a bad practice doing it a ...
Why can 'operator*' member function of std::unique_ptr be marked const (https://en.cppreference.com/w/cpp/memory/unique_ptr/operator*) while functions ...
I am getting a it is thrown by this code in MSVC (2022, V17.1) <algorithm> header. template <class _FwdIt, class _Ty, class _Pr> _NODI ...
Here's an (admittedly brain-dead) refactoring algorithm I've performed on several occasions: Start with a .cpp file that compiles cleanly and (AFA ...
Sample code: Invocations: Question: why msvc requires const while others don't? Or why others don't require const? ...
Normally people write the main function like this: However, this came to my mind: or maybe I should write it like this cause it seems more intui ...
Line 3 is disallowed in C and is invalid in C++. However, one gets an error in C++, but only a warning in C. The question is - why only a warning? ...
I have a wrapper around a C-API: #[repr(transparent)] pub struct Request(http_request_t); This wrapper provides several methods for interacting wit ...
I have sometimes problems with understanding const correctness, especially if it is the logical constness of an object. Let's say I have a class that ...
I'm trying to finish this code, and right now I am facing a error with the Selection Sort Algorithm: and I have to sort the graph by the number ...
I thought the only way to declare a const<vector> is: ...
Assume that I have a Widget class and a collection of Widgets: WidgetCollection::findNiceWidget() gives access to one of the Widgets in the collect ...
I've been working on a custom ReversibleContainer, and I thought I was on the right track, but I've hit a snag in testing while going through the sema ...
I have a struct like this On this struct I want to act upon various functions. In particular there are some function for which I want an instance o ...
Could somebody please give me a little advice regarding const correctness within a C++ wrapper class which encapsulates some legacy C functionality. ...
Good evening! I find this question to be interesting for other people, too. So I choose this one to finally ask my first question on stack overflow. ...