Search
 
SCRIPT & CODE EXAMPLE
 

CPP

tuple c++

#include <tuple>

std::tuple<char, int, bool> my_tuple = {'H', 56, false};
Comment

c++ tuple

std::tuple<int, int> foo_tuple() 
{
  return {1, -1};  // Error until N4387
  return std::tuple<int, int>{1, -1}; // Always works
  return std::make_tuple(1, -1); // Always works
}
Comment

c++ tuple

#include <tuple>

std::tuple<int, int> foo_tuple() 
{
  return {1, -1};  // Error until N4387
  return std::tuple<int, int>{1, -1}; // Always works
  return std::make_tuple(1, -1); // Always works
}
Comment

c++ tuple

std::tuple<types...>

std::make_tuple(vals...)
Comment

c++ tuple example

#include <tuple>

....

std::tuple<int, int, int> tpl;

std::get<0>(tpl) = 1;
std::get<1>(tpl) = 2;
std::get<2>(tpl) = 3;
Comment

C++ tuple

// C++ code to demonstrate tuple, get() and make_pair()
#include<iostream>
#include<tuple> // for tuple
using namespace std;
int main()
{
    // Declaring tuple
    tuple <char, int, float> geek;
  
    // Assigning values to tuple using make_tuple()
    geek = make_tuple('a', 10, 15.5);
  
    // Printing initial tuple values using get()
    cout << "The initial values of tuple are : ";
    cout << get<0>(geek) << " " << get<1>(geek);
    cout << " " << get<2>(geek) << endl;
  
    // Use of get() to change values of tuple
    get<0>(geek) = 'b';
    get<2>(geek) =  20.5;
  
     // Printing modified tuple values
    cout << "The modified values of tuple are : ";
    cout << get<0>(geek) << " " << get<1>(geek);
    cout << " " << get<2>(geek) << endl;
  
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ construnctor 
Cpp :: run c++ program in mac terminal 
Cpp :: string length c++ 
Cpp :: convert all characters in string to uppercase c++ 
Cpp :: loop through a vector in c++ 
Cpp :: prime numbers less than a given number c++ 
Cpp :: memcpy c++ usage 
Cpp :: c++ vector loop delete 
Cpp :: c++ console color 
Cpp :: file open cpp 
Cpp :: vector fin element c++ 
Cpp :: cpp init multidimensional vector 
Cpp :: check uppercase c++ 
Cpp :: read comma separated text file in c++ 
Cpp :: Parenthesis Checker using stack in c++ 
Cpp :: convert string to lpwstr 
Cpp :: casting c++ 
Cpp :: time_t to int 
Cpp :: c++ get string between two characters 
Cpp :: cout hex c++ 
Cpp :: c++ array rev pointer 
Cpp :: rotate array cpp 
Cpp :: C++ break with for loop 
Cpp :: quick sort c+++ 
Cpp :: c++ hashmaps 
Cpp :: string vector to string c++ 
Cpp :: stack overflow c++ 
Cpp :: letter occurrence in string c++ 
Cpp :: c++ Program to check if a given year is leap year 
Cpp :: gcc suppress warning inline 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =