(C++) BoostTupleExample1

February 24, 2017 · View on GitHub

 

 

 

 

 

(C++) BoostTupleExample1

 

BoostQt
CreatorLubuntu

 

Boost.Tuple example 1 is a Boost.Tuple example.

 

Technical facts

 

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.9.2

 

 

 

 

 

Qt project file: ./CppBoostTupleExample1/CppBoostTupleExample1.pro

 


include(../../ConsoleApplication.pri) #Or uncomment 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++11 -Wall -Wextra -Weffc++ # # unix { #   QMAKE_CXXFLAGS += -Werror # } include(../../Libraries/Boost.pri) #Or uncomment the code below # win32 { #   INCLUDEPATH += \ #     ../../Libraries/boost_1_54_0 # } SOURCES += main.cpp

 

 

 

 

 

./CppBoostTupleExample1/main.cpp

 


#include <cassert> #include <string> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-but-set-parameter" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include <boost/tuple/tuple.hpp> #pragma GCC diagnostic pop int main() {   typedef boost::tuple<int,double,std::string> Tuple;   static_assert(boost::tuples::length<Tuple>::value == 3,"Tuple has size 3");   static_assert(std::is_same<boost::tuples::element<0,Tuple>::type,int>(),"First element is int");   static_assert(std::is_same<boost::tuples::element<1,Tuple>::type,double>(),"Second element is double");   static_assert(std::is_same<boost::tuples::element<2,Tuple>::type,std::string>(),"Third element is std::string");   Tuple t = boost::tuples::make_tuple(123,3.14159,"Bilderbikkel");   const int x1 = boost::get<0>(t);   const double x2 = boost::get<1>(t);   const std::string x3 = boost::get<2>(t);   boost::get<0>(t) = x1 + 1;   boost::get<1>(t) = x2 + 1.0;   boost::get<2>(t) = x3 + " was here";   assert(boost::get<0>(t) == 124);   assert(boost::get<1>(t) == 4.14159);   assert(boost::get<2>(t) == "Bilderbikkel was here"); }