CPP – copy_if

The algorithm copy_if is useful, it can help us to get all elements that meet special conditions. C++ template OutputIt copy_if( InputIt first, InputIt last, OutputIt d_first, UnaryPredicate pred ); Possible implement: C++ template OutputIt copy_if(InputIt first, InputIt last, OutputIt d_first, UnaryPredicate pred) { while (first != last) { if Read more…

CPP – Ignore Case To Compare String

STL Algorithm std::lexicographical_compare is an algorithm which can be used to compare string lexicographically.We can give our comparing function to make it work without pay attention to capital and small letter. C++ template constexpr bool lexicographical_compare( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp ); Example: C++ #include Read more…

CPP – Unique Copy In STL

std::unique_copy is an algorithm which can be used to copy elements without duplicating objects in adjacent locations. template< class InputIt, class OutputIt > OutputIt uniquecopy( InputIt first, InputIt last, OutputIt dfirst ); Usage example: C++ #include #include #include #include int main() { std::string s1 = “This is a story about Read more…

Content Summary
: Input your strings, the tool can get a brief summary of the content for you.

X