Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
1 vote
1 answer
80 views

There are six algorithms that will output a range(which is denoted by an output iterator) in <numeric>: adjacent_difference, partial_sum, inclusive_scan, exclusive_scan, transform_inclusive_scan ...
o_oTurtle's user avatar
  • 1,271
5 votes
4 answers
316 views

I very often find myself wanting to filter a vector based on its index rather than its values. auto some_values = std::vector{1, 0, 4, 6, 2}; // Somewhere I figure out which items to remove. // This ...
Elliott's user avatar
  • 2,730
1 vote
0 answers
148 views

I want to call standard library algorithms with the ExecutionPolicy for vectorization. At the same time the call should also work in a constexpr context. Unfortunately the ExecutionPolicy overloads of ...
Benjamin Buch's user avatar
2 votes
1 answer
263 views

I have a vector of a class Planters which contain vectors of Plants. My goal is to return a vector of plants containing the plants from planter 1, followed by plants from planter 2, etc. example: ...
callum arul's user avatar
1 vote
1 answer
919 views

I have a class called InfoBlob and two enums called Action and Emotion. My function is supposed to take in a vector<InfoBlobs> blobs, and return a vector<Action> actions, corresponding to ...
callum arul's user avatar
1 vote
1 answer
307 views

I am new to C++. I was trying using the accumulate algorithm from the numeric library. Consider the following code segment. int a[3] = {1, 2, 3}; int b = accumulate(a, a + 3, 0); It turns out that ...
lamc's user avatar
  • 367
0 votes
1 answer
70 views

Let's say : std::sort(beg1, beg2, pred); This algorithm takes a range of iterators for the container and a predicate. It takes an LegacyRandomAccessIterator. I do understand the the 5 iterator ...
user avatar
0 votes
1 answer
216 views

I have a std::vector<vec3> points where vec3 has float x, y, z. I want to find the min/max bounds of all the points. I.e. the min and max of all vec3::x, vec3::y, vec3::z separately in the ...
jozxyqk's user avatar
  • 17.7k
-1 votes
2 answers
278 views

Given a std::vector of vertices containing some 3d integer data: struct Vertex{ int x; int y; int z; } std::vector<Vertex> vertices = {{10, 10, 10}, {20,20,20}, {30,30,30}, {40,40,...
revolutionary's user avatar
23 votes
5 answers
4k views

I have a vector of integers: std::vector<int> values = {1,2,3,4,5,6,7,8,9,10}; Given that values.size() will always be even. I simply want to convert the adjacent elements into a pair, like ...
dev-here's user avatar
  • 348
1 vote
1 answer
93 views

Using the following containers: std::vector<std::pair<std::string, int>> keyVals = { {"A", 1}, {"B", 2}, {"C", 3} }; std::vector<std::string> keys ...
johnco3's user avatar
  • 2,661
2 votes
1 answer
104 views

I have the next C++ code snippet: ... static constexpr const char* my_char_array [10] { // Some literals here... } // Member of a class std::vector<std::string> splitted_input { // Contains C++ ...
Alex Vergara's user avatar
  • 2,335
-1 votes
1 answer
353 views

I am new to using lambda functions in C++. I have been researching the web, and found several articles, explaining the syntax and purpose of lambda function, but I have not come found articles which ...
Sap BH's user avatar
  • 91
3 votes
3 answers
334 views

Given a string: std::string str{"This i_s A stRIng"}; Is it possible to transform it to lowercase and remove all non-alpha characters in a single pass? Expected result: this is a string I ...
cbrng's user avatar
  • 63
2 votes
2 answers
696 views

std::adjacent_find looks for the first two consecutive elements that satisfies the given predicate. I am looking for other algorithms that also has a predicate that takes the (previous, current) pair. ...
user877329's user avatar
  • 6,296

15 30 50 per page
1
2 3 4 5
25