Use this tag for questions about the C++ standard library template std::tuple. It represents an ordered, heterogeneous sequence of objects. Also add the tag [c++] when using this tag.
Questions tagged [stdtuple]
403 questions
-1
votes
1 answer
printing class object using variadic templates
I am trying to understand folding and variadic templates.
I designed a very naive Tuple class. I can create a tuple object, but I would like to print the object. It seems odd that this problem hasn’t been touched almost anywhere (at least I haven’t…

not_here_to_play
- 148
- 7
-1
votes
1 answer
C++ temporary object references
Assuming MyClass has an implicit constructor that takes an int as an argument, why is there a difference between MyClass being explicitly constructed vs. implicitly done so in terms of when the temporary gets destroyed? In one case it results in a…

user3882729
- 1,339
- 8
- 11
-1
votes
1 answer
how to create a four tuple (ip addresses and port numbers) key in c++?
I want to create a data structure to efficiently store and retrieve IP packets.
I need to use four tuple (IP addresses and port numbers) as a key for the data structure.
I have searched and I found map data structure but it seems it cannot search on…

kikilinux
- 61
- 1
- 7
-1
votes
1 answer
how to create a complex type using tuples and variadic templates
In first place, I'm not a very skilled programmer in C++11 and templates, I read a lot of posts but I can't figure out how to write my idea (if is even possible), saying that, this is my idea.
My idea is create a complex compiler-time type, I'm…

Trungus
- 165
- 8
-1
votes
2 answers
template looping through tuple
I'm playing with variadic templates and I'm currently trying to implement operator<< for tuple.
I've tried the following code but it doesn't compile (GCC 4.9 with -std=c++11).
template
void print(ostream& s,…

hynner
- 1,352
- 1
- 11
- 20
-1
votes
2 answers
Understanding segfault with static size array of std::tuple in class
I have a class that where I want to store three datapoints for each pixel in an image. I thought std::tuple would be a nice way to do this so:
class CameraManager {
private:
static const int width_ = 700;
static const int height_ = 574;
…

user1443778
- 581
- 1
- 5
- 20
-1
votes
1 answer
using tuple with class as type C++
I have defined a method for class Rettangolo like this
std::tuple Rettangolo::interseca(Point *sol_p, Point *pvet){
//code
//code
return std::make_tuple(1, *pto1, *pto2); //example of return
//more code
}
My problem is to use the…

squirrel
- 1
-2
votes
2 answers
Select & build a compile-time tuple structure based on a runtime-provided mapping
I am working on a piece that requires some compile-time data structures to be created from a run-time provided mapping. If the runtime provided mapping matches the pre-defined compile-time pattern, the appropriate data structure should be created.…

user3641187
- 405
- 5
- 10
-2
votes
1 answer
Is there a way to pass variables to std::make_tuple(var1, var2)?
I want to pass variable names to std::make_tuple(), but it wouldn't let me. I'm using C++14, is there a way to achieve what I want?
std::tuple get_student(int id)
{
int gpa = 3;
return std::make_tuple(gpa);
}
This throws an error…

Jason Ma
- 1
- 2
-2
votes
1 answer
Does std::tuple accept auto as a type
I have to return an int and a function object to the caller, I was thought of returning a tuple like make_tuple(int,[](some){}) I am now on GCC that doesn't support decltpe(auto) as a return type, is ther any way i could make my return type as…

RaGa__M
- 2,550
- 1
- 23
- 44
-2
votes
2 answers
Clean dynamically generated nested Tuples
I have a class whose __iter__() method return a itertools.product() of a dynamically generated data.
This data do a Cartesian product of arbitrarily nested dicts, and now I need to flatten it, but in a streamlined way, aggregating intermediate…

rsalmei
- 3,085
- 1
- 14
- 15
-4
votes
1 answer
Fail to use std::get to reach tuple element
Original post:
I am having an object in a complex project. So I may not be able to provide very detail API of all these classes, but I am trying to abstract my problem without need of detail.
First of all, the code below works fine:
auto ha =…

Summer Sun
- 947
- 13
- 33
-5
votes
1 answer
Transform std::pair to std::tuple with any number of elements
I need the following meta code adapted from std::pair to std::tuple with any number of elements. I don't want to implement it separately for every possible number of elements.
template
struct merge_pairs
{ typedef…
user4590120