list::unique() is an inbulit function in C++ STL which removes all duplicate consecutive elements from the list.
Parameters:The function accepts a single and optional 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 b);
Return value: This function does not return anything.
Below is the implementation of above function:
List is: 2.55 3.15 4.16 4.77 12.65 13.59 List is: 2.55 3.15 4.16 12.65 13.59
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count number of unique Triangles using STL | Set 1 (Using set)
- forward_list::unique() in C++ STL
- list::push_front() and list::push_back() in C++ STL
- list::pop_front() and list::pop_back() in C++ STL
- list::front() and list::back() in C++ STL
- list::empty() and list::size() in C++ STL
- list::remove() and list::remove_if() in C++ STL
- list::emplace_front() and list::emplace_back() in C++ STL
- list::begin() and list::end() in C++ STL
- How to insert elements in C++ STL List ?
- Delete elements in C++ STL list
- List in C++ Standard Template Library (STL)
- list::clear() in C++ STL
- list::swap() in C++ STL
- list::operator= in C++ STL
- std::list::sort in C++ STL
- list cbegin() and cend() function in C++ STL
- list assign() function in C++ STL
- list push_back() function in C++ STL
- list back() function in C++ STL
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.