fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iterator>
  4.  
  5. template <typename T, typename... Args>
  6. bool allequal(T a, Args... rest)
  7. {
  8. std::initializer_list<T> values = {a, rest...};
  9. return std::adjacent_find(begin(values), end(values), std::not_equal_to<T>()) == end(values);
  10. }
  11.  
  12. int main()
  13. {
  14. std::cout << allequal(3, 2, 3, 3);
  15. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
Standard output is empty