(C++) BoostArrayExample1
February 24, 2017 · View on GitHub
(C++) BoostArrayExample1

boost::array example 1 is a boost::array example.
Technical facts
Operating system(s) or programming environment(s)
Lubuntu 15.04 (vivid)
Qt Creator 3.1.1
- G++ 4.9.2
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); }