Skip to content

Latest commit

 

History

History
106 lines (59 loc) · 3.46 KB

CppStdMinmax.md

File metadata and controls

106 lines (59 loc) · 3.46 KB

std::minmax is an algorithm to obtain the begin and end of a container at the same time.

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

  • STL STL: GNU ISO C++ Library, version 4.6.1

 

 

 

 

 

Qt project file: CppMinmax.pro

 


#------------------------------------------------- # # Project created by QtCreator 2012-01-29T10:21:35 # #------------------------------------------------- QT       += core QT       -= gui QMAKE_CXXFLAGS += -std=c++0x TARGET = CppMinmax CONFIG   += console CONFIG   -= app_bundle TEMPLATE = app SOURCES += main.cpp

 

 

 

 

 

main.cpp

 


#include <algorithm> #include <cassert> int main() {   const std::vector<int> v = { 100,1,2,3,4,5,6,7,8,9,-100 };   const std::pair<std::vector<int>::const_iterator,std::vector<int>::const_iterator> p     = std::minmax(v.begin(),v.end());   assert(p.first  == v.begin());   assert(p.second == v.end());   const int min = *(p.first);   const int max = *(p.second-1);   assert(min ==  100);   assert(max == -100); }