fork download
  1. #include <initializer_list>
  2. #include <iterator>
  3. #include <cstdio>
  4.  
  5. template <class T> T minArgs(const std::initializer_list<T> &Arguments)
  6. {
  7. const T* Smallest = Arguments.begin();
  8. for (const T* I = Arguments.begin(); I != Arguments.end(); ++I)
  9. {
  10. if (*I < *Smallest) Smallest = I;
  11. }
  12. return *Smallest;
  13. }
  14.  
  15. int main()
  16. {
  17. int min = minArgs({12, 44, 23});
  18. std::printf("%i\n", min);
  19. return 0;
  20. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
12