stl-algorithm
STL algorithm to delete all the objects in a container?
Is there a STL utility/algorithm to do delete *the_object_iterator; on all the objects? So that I can clear() safely? The STL container is a set and the objects are pointers to C++ classes created wit[详细]
2023-04-09 04:31 分类:问答quick-sorts iterator requirements
tl;dr: Is it is possible to implement quicksort on a doubly linked list efficiently? My understanding before thinking about it was, no, its not.[详细]
2023-04-08 04:04 分类:问答stdlib "Unique" method does not work
I\'m trying to use the C++ Standard Library algorithm unique (with BinaryPredicate). I\'ve created a vector of pairs; each pair is like \"(first=a vector of 4 doubles, second=an integer)\". The seco[详细]
2023-04-06 17:22 分类:问答Why doesn't the move constructor get called in the fill_n
The error I get says that the fill_n line below is trying to use the deleted copy constructor: why is it not trying to use the move constructor?I tried wrapping it in a std::move but that didn\'t help[详细]
2023-04-02 09:33 分类:问答How do I remove duplicates from a C++ array?
I have an array of structs; the array is of size N. I want to remove duplicates from the array; that is, do an in-place change, converting the array to have a single appearance of each struct. Additi[详细]
2023-03-30 17:51 分类:问答istream_iterator try to parse invalid data
Hi was I hoping someone would help understand this behaviour of the below code. #include <iostream>[详细]
2023-03-29 07:41 分类:问答How to use std::find/std::find_if with a vector of custom class objects?
I have a class representing a user ca开发者_高级运维lled Nick and I want to use std::find_if on it, where I want to find if the userlist vector has an object included with the same username I pass in.[详细]
2023-03-25 00:11 分类:问答Composability of STL algorithms
The STL algorithms are a pretty useful thing in C++. But one thing that kind of irks me is that they seem to lack composability.[详细]
2023-03-21 20:07 分类:问答Using C++ std::equal on a container of shared_ptr
I have a container of std::shared_ptr.I want to compare two containers using std::equal.The class A has operator== defined.I want equal to compare if each element is equivalent using its operator==, n[详细]
2023-02-20 22:29 分类:问答Using STL algorithms with shared_ptr, function objects
I have a set of shared_ptr, and I\'d like to use remove_copy_if with a custom function object for the predicate.I didn\'t know the \"best\" way to do it.Right now, I\'ve got this working:[详细]
2023-02-19 15:44 分类:问答