forward_list::unique() is an inbuilt function in C++ STL which removes all consecutive duplicate elements from the forward_list. It uses binary predicate for comparison.
Parameters: The function accepts a single parameter which is a binary predicate that returns true if the elements should be treated as equal. It has following syntax:
bool name(data_type a, data_type a)
Return value: The function does not return anything.
List of elements before unique operation is: 1 1 1 1 2 2 2 2 3 3 3 2 4 4 List of elements after unique operation is: 1 2 3 2 4
- Program to create Custom Vector Class in C++
- std::is_trivially_copy_constructible in C/C++
- Difference between Python and C++
- tgamma() method in C/C++ with Examples
- boost::type_traits::is_array Template in C++
- boost is_pointer template in C++
- Stack of Pair in C++ STL with Examples
- Modulo Operator (%) in C/C++ with Examples
- fpclassify() method in C/C++ with Examples
- Operator Overloading '<<' and '>>' operator in a linked list class
- How to find the Entry with largest Value in a C++ Map
- Visibility Modes in C++ with Examples
- Program to implement Separate Chaining in C++ STL without the use of pointers
- Speed up Code executions with help of Pragma in C/C++
- Vector of Vectors in C++ STL with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : babaurbeautiful