The unordered_set::cend() method is a built-in function in C++ STL which is used to return a const_iterator pointing to past-the-end element in the unordered_set container or in one of it’s bucket. This function does not directly point to any element in the container. It is only used to denote the end of a container or the open end of a range as in [cbegin, cend).
Note: A const_iterator can only be used to access elements, it cannot modify the elements present in the container.
Parameter: This function accepts a single parameter n. This is an optional parameter and specifies the bucket number. If this parameter is not passed then the cend() method will return a const_iterator pointing to the position just after the last element of the container and if this parameter is passed then the cend() method will return a const_iterator pointing to the position just after the last element in a specific bucket in the unordered_set container.
Return Value: This function returns a const_iterator pointing to the position just after the last element in the container or a specified bucket in the container.
Below programs illustrate the unordered_set::cend() function:
Elements present in sampleSet are: 25 5 10 15 20
Elements present in sampleSet are: Welcome To GeeksforGeeks For Geeks Computer Science Portal
- set cbegin() and cend() function in C++ STL
- unordered_multimap cend() function in C++ STL
- map cbegin() and cend() function in C++ STL
- unordered_multiset cend() function in C++ STL
- multiset cbegin() and cend() function in C++ STL
- list cbegin() and cend() function in C++ STL
- forward_list::cend() in C++ STL with Example
- unordered_map cend in C++ STL
- match_results cbegin() add cend() in C++ STL
- multimap::cbegin() and multimap::cend() in C++ STL
- array::cbegin() and array::cend() in C++ STL
- vector :: cbegin() and vector :: cend() in C++ STL
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- exp() function C++
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.