Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) TieExample1

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppTieExample1/CppTieExample1.pro

 

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

#
#
# Type of compile
#
#

CONFIG(release, debug|release) {
  DEFINES += NDEBUG NTRACE_BILDERBIKKEL
}

QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -Weffc++

unix {
  QMAKE_CXXFLAGS += -Werror
}

#
#
# Boost
#
#

win32 {
  INCLUDEPATH += \
    ../../Libraries/boost_1_54_0
}

 

 

 

 

 

./CppTieExample1/main.cpp

 

#include <cassert>
#include <string>
#include <tuple>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/tuple/tuple.hpp>
#pragma GCC diagnostic pop


int main()
{
  //C++11 std::tuple
  {
    int i = 0;
    double d = 0.0;
    std::string s;
    std::tie(i,d,s) = std::make_tuple(1,1.1,"x");
    assert(i == 1);
    assert(d == 1.1);
    assert(s == "x");
  }
  //boost::tie
  {
    int i = 0;
    double d = 0.0;
    std::string s;
    boost::tie(i,d,s) = boost::make_tuple(1,1.1,"x");
    assert(i == 1);
    assert(d == 1.1);
    assert(s == "x");
  }
  //Boost.Tuple
  {
    int i = 0;
    double d = 0.0;
    std::string s;
    boost::tuples::tie(i,d,s) = boost::tuples::make_tuple(1,1.1,"x");
    assert(i == 1);
    assert(d == 1.1);
    assert(s == "x");
  }
  assert(1==2);
}

 

 

 

 

 

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