(C++) StdIotaExample1
February 24, 2017 · View on GitHub
(C++) StdIotaExample1
Technical facts
Operating system(s) or programming environment(s)
Lubuntu 15.04 (vivid)
Qt Creator 3.1.1
- G++ 4.9.2
Libraries used:
STL: GNU ISO C++ Library, version
4.9.2
Qt project file: ./CppStdIotaExample1/CppStdIotaExample1.pro
include(../../ConsoleApplication.pri) #Or use the code below # QT += core # QT += gui # CONFIG += console # CONFIG -= app_bundle # TEMPLATE = app # CONFIG(release, debug|release) { # DEFINES += NDEBUG NTRACE_BILDERBIKKEL # } # QMAKE_CXXFLAGS += -std=c++1y -Wall -Wextra -Weffc++ # unix { # QMAKE_CXXFLAGS += -Werror # } SOURCES += main.cpp
./CppStdIotaExample1/main.cpp
#include <algorithm> #include <iostream> #include <iterator> #include <vector> int main() { //Create a std::vector consisting of ten zeroes std::vector<int> v(10,0); //Let iota assign incrementing values to the std::vector, //starting from zero std::iota(v.begin(),v.end(),0); //Show the std::vector std::copy(v.begin(),v.end(),std::ostream_iterator<int>(std::cout," ")); } /* Screen output 0 1 2 3 4 5 6 7 8 9 */