You need not to use std::sort
. It can be done in a simpler way:
if ( std::adjacent_find( myvector.begin(), myvector.end(), std::not_equal_to<>() ) == myvector.end() )
{
std::cout << "All elements are equal each other" << std::endl;
}
More Related Contents:
- c++ vector size. why -1 is greater than zero
- Reorder vector using a vector of indices [duplicate]
- How to make elements of vector unique? (remove non adjacent duplicates)
- Howto create combinations of several vectors without hardcoding loops in C++?
- Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? [duplicate]
- Create an algorithm that asks the user for two positive numbers, call them “first” and “last”, and prints the sum of all the numbers between first [closed]
- What is the most effective way for float and double comparison?
- Fast bignum square computation
- Detecting endianness programmatically in a C++ program
- Signed/unsigned comparisons
- Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both
- Why isn’t vector a STL container?
- Finding the centroid of a polygon?
- What is the difference between std::array and std::vector? When do you use one over other? [duplicate]
- How to get a random element from a C++ container?
- how do you insert the value in a sorted vector?
- LRU cache design
- c++ sort keeping track of indices [duplicate]
- Bjarne Stroustrup says we must avoid linked lists
- How to add two numbers without using ++ or + or another arithmetic operator
- Are there any better methods to do permutation of string?
- C++ std::vector vs array in the real world
- c++: can vector contain objects of type Derived?
- Is std::vector memory freed upon a clear?
- Getting a vector into a function that expects a vector
- How can I get the maximum or minimum value in a vector?
- Initializing a ublas vector from a C array
- vector and const
- Mapping elements in 2D upper triangle and lower triangle to linear structure
- Fastest way to get the integer part of sqrt(n)?