Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) StdIotaExample1

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

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

*/

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml