I would like to overload operator<<(std::ostream&, std::chrono::duration<std::uint64, std::nano>) - and ideally without requiring user ...
I would like to overload operator<<(std::ostream&, std::chrono::duration<std::uint64, std::nano>) - and ideally without requiring user ...
I'm learning std::set . Here is my codes: Output: 1 I use struct cmp to custom elements's sort rules,if abs(a-b)<=3 the new element will be del ...
The task (from a Bulgarian judge, click on "Език" to change it to English): I am given the size of the first (S1 = A) of N corals. The size of every ...
I want to pass variable names to std::make_tuple(), but it wouldn't let me. I'm using C++14, is there a way to achieve what I want? This throws an ...
while(!st.empty() && nums[i%n] >= st.top()) st.pop(); this code works but while(nums[i%n] >= st.top() && !st.empty()) st.pop() ...
This is probably easiest to explain with examples. std::vector<int> a; a.push_back(1); a[0] = 2; const std::vector<int>& b = a; b.pus ...
I have a std::multimap<int, X*> where X is a user-defined type. I want to find a specific key-value-pair within this multimap (i.e. an iterator ...
I figured out that this code might cause segmentation fault. because ptr ends up pointing to the popped element. but I don't know the exact reason ...
So I intend to use this stack-based allocator for std::vector, and I use 2 arrays for the allocation(because vectors grow and copy the old buffer to t ...
I have a std::unordered_multimap, and would like to iterate over all elements with a given key k, without iterating the full map, but optimally traver ...
The image shows the error displayed in the push(), pop(), empty() functions I am currently using MacOS Ventura 13.1 , it would be great if anyone co ...
I have a function template where the return type of the function is the template argument. According to https://en.cppreference.com/w/cpp/language/tem ...
Assume that one thread calls only the following functions continuously. here, insert_data check whether a key exists in std::unordered_map, and if it ...
I have a vector/container of classes and I want to find the element that has the max/min value of a specific member; for example: Is there an "STL" ...
I am trying to build a comparator for a map to be used with sort() function. consider a map object called right with an id and coordinates as the basi ...
I see std::string has many constructors https://cplusplus.com/reference/string/string/string/. But which one am I using when I do: I bet is: f ...
I have written this code and want to insert value in the vector of vector like this : v.push_back(vector<pair<int,string> >({1,"A"})); ?? ...
I was just looking into why the function std::remove_if wasn't working the way I expected, and learned about the C++ "erase-remove idiom" where I'm su ...
I am getting below error: :60:8: error: request for member 'push' in 'pq', which is of non-class type 'std::priority_queue, std::vector >, std: ...
Is the iterator type requirement for std::array<T,N>::iterator implementation defined or is it always defined to be a pointer to value_type? ...