The second version (2), takes as argument a specific comparison function that determine the "uniqueness" of an element. In fact, any behavior can be implemented (and not only an equality comparison), but notice that the function will call binary_pred(*i,*(i-1)) for all pairs of elements (where i is an iterator to an element, starting from the second) and remove i from the list if the predicate returns true.
Note that the predicate is called with the second number as the first argument and the preceding number as the second argument.
unique will iterate through the list starting with a comparison for 4 and 2. Your predicate will return false so 4 is not deleted. Ditto for 6 and 4. Now with 5 and 6 your predicate will return true, so 5 will be deleted. Finally for 3 and 6, your predicate will return true, thereby removing 3. You should end up with {2,4,6}.
Removes all consecutive duplicate elements from the container. Only the first element in each group of equal elements is left.
The cppreference.com page makes no assertion about the order of the arguments to the predicate. Since it seems to be expecting a test for equality, the order of arguments to the predicate would not be expected to make a difference. The underlined portion of the quote would imply that if true is returned, the second number is deleted, which matches with what we're seeing.
edit:
But even if the arguments were passed in the wrong order, the output shouldn't be just 2, right ?
Yes, it makes perfect sense. In the cout displays I provided above, I was assuming that the first argument was being deleted (per the documentation on this site). If you change the "should delete" to the second argument, then all you are left with is {2}.
Run assumes second argument to predicate is deleted:
Comparing: 2 < 4 (true)
Should delete: 4
Comparing: 2 < 6 (true)
Should delete: 6
Comparing: 2 < 5 (true)
Should delete: 5
Comparing: 2 < 3 (true)
Should delete: 3
2
I was going to report this as an error on the list::unique page, but in checking the C++14 standard ยง 23.3.4.6 I see the same wording that is on this site's list::unique page.
Effects: Erases all but the first element from every consecutive group of equal elements referred to by the iterator i in the range [first + 1,last) for which *i == *(i-1) (for the version with no arguments) or pred(*i, *(i - 1)) (for the version with a predicate argument) holds. Invalidates only the iterators and references to the erased elements.
The C++17 standard also has the same wording. So bottom line, chalk this up to a peculiarity of the MS implementation.