Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) BoostArrayExample1

 

Boost

 

boost::array example 1 is a boost::array example.

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppBoostArrayExample1/CppBoostArrayExample1.pro

 

exists (../../ConsoleApplication.pri) {
  include(../../ConsoleApplication.pri)
}
!exists (../../ConsoleApplication.pri) {
  QT += core
  QT += gui
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  CONFIG   += console
  CONFIG   -= app_bundle
  TEMPLATE = app
  CONFIG(release, debug|release) {
    DEFINES += NDEBUG NTRACE_BILDERBIKKEL
  }
  QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -Weffc++
  unix {
    QMAKE_CXXFLAGS += -Werror
  }
}

exists(../../Libraries/Boost.pri) {
  include(../../Libraries/Boost.pri)
}
!exists(../../Libraries/Boost.pri) {
  win32 {
    INCLUDEPATH += \
      ../../Libraries/boost_1_55_0
  }
}

SOURCES += main.cpp

 

 

 

 

 

./CppBoostArrayExample1/main.cpp

 

#include <cassert>
#include <boost/array.hpp>

int main()
{
  //const boost::array<int,3> v = { 0,1 }; //Does compile: too few elements is not checked in assignment
  //const boost::array<int,3> v = { 0,1,2,3 }; //Does not compile: too many elements is checked in assignment

  //Note: at around 2013-05-01, v needed to be initialized with double braces:
  //  const boost::array<int,3> v = {{ 0,1,2 }};
  const boost::array<int,3> v = { 0,1,2 };

  //static_assert(v.size() == 3,""); //Not allowed, v.size() is not a constexpr
  assert(v.size() == 3);
  assert(v[1] == 1);
}

 

 

 

 

 

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