Let suppose the values in my set are
S={1,2,3,4};
Now I want to know how many numbers are there which are smaller than 3,then I will use s.lower_bound(3);
But I am not able to get the count of numbers less than 3 when I write
S.lower_bound(3)-s.begin().
The class template
std::setdoes not have random access iterators. So the operator-is not defined for its iterators. You need to use the standard functionstd::distancePay attention to that the index will be one less than the number of elements that precede the current element provided that the number is not equal to 0.