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 :: factorial of large number 
Cpp :: cpp #include "" < 
Cpp :: c++ get last element in vector 
Cpp :: how to use a non const function from a const function 
Cpp :: structure of a function in C++ 
Cpp :: C++ Integer Input/Output 
Cpp :: C++ Nested if...else 
Cpp :: how to find even and odd numbers in c++ 
Cpp :: search by value in map in stl/cpp 
Cpp :: c++ array pointer 
Cpp :: data types in c++ 
Cpp :: c++ variable types 
Cpp :: changing values of mat in opencv c++ 
Cpp :: initialising 2d vector 
Cpp :: disallowcopy c++ 
Cpp :: sweetalert2 email and password 
Cpp :: makefile for single cpp file 
Cpp :: adding variables c++ 
Cpp :: string concatenation operator overloading c++ 
Cpp :: minheap cpp stl 
Cpp :: c++ string find last number 
Cpp :: statements 
Cpp :: find first of a grammar 
Cpp :: oop in c++ have 5 
Cpp :: c++ create function pointer 
Cpp :: invert a binary tree 
Cpp :: initialisation of a c++ variable 
Cpp :: data type c++ 
Cpp :: rgb type def 
Cpp :: even or odd program in c++ 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =