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
0
votes
1 answer
std::get returns error while working with vector of tuples
I'm trying to create a vector that holds tuples
this is my code:
std::vector>> vec;
...
...
for (i = 0; i < 5; i++) {
…

Fleev
- 77
- 8
0
votes
1 answer
How to derive from a variadic template class in C++
I have variadic template class which is just a wrapper for std::tuple :
template
class Tpl
{
public:
Tpl() {}
Tpl(Child ...args) : child(args...)
{}
template
T& Get()
{
return…

Fabian
- 152
- 2
- 14
0
votes
2 answers
perfect forwarding failing for lvalues
I have a utility function which iterates over a tuple, and for each element, calls a function with that element, and finally calls another function with the result of all the tuple elements.
To better illustrate:
There is a tuple of various types…

Steve Lorimer
- 27,059
- 17
- 118
- 213
0
votes
1 answer
Retrieving values of stored tuple with auto c++
If I store a tuple in a class as such:
class BaseA { } //So that I can store A in a class
template
class A : public BaseA {
public:
//I'm omitting the constructors
private:
std::tuple storedTup;
}
Would you be…

TrevorPeyton
- 629
- 3
- 10
- 22
0
votes
2 answers
Retuning multiple vectors from a function in c++?
I want to return multiple vectors from a function.
I am not sure either tuple can work or not. I tried but is not working.
xxx myfunction (vector> matrix1 , vector> matrix2) {
// some functional code: e.g.
//…

aly
- 17
- 5
0
votes
1 answer
Creating a tuple of data and sending unpacked as a function arguements
Hi I was wonder if anyone could help me with this. I'm trying to implement the CallFunction (the bit with the comment in). I'm not sure how to go about doing it.
[Question] I want to create a tuple of types created from the ...Arguments, but I want…

Azelekia
- 35
- 1
- 4
0
votes
1 answer
Tuple of pointers to functions returning reference to variadic types
Don't let the question title scare you off! I believe this is simply a question of syntax.
I have this class
template
class test_class{
public:
template
T &get(){return std::get(m_values);}
…

RamblingMad
- 5,332
- 2
- 24
- 48
0
votes
2 answers
Forwarding tuple arguments to a function in VS2012
I'm trying to forward tuple arguments to a function in VS2012 (update 3).
My understanding is that this is possible in C++11 using variadic templates, unfortunately, VS2012 only supports "fake" variadics.
auto Values = std::make_tuple(4, 8);
auto…

lcs
- 4,227
- 17
- 36
0
votes
2 answers
getter to variadic container - get<0>() only working on concrete types?
I needed a special kind of variadic container and had some unforseen problems, so I created the following minimal example (see comments):
#include
#include…

André Müller
- 71
- 5
0
votes
1 answer
map C++ overloaded function over heterogenous tuple?
In C++, is it possible to map an overloaded function over a heterogenous tuple? For example:
double f(dobule);
size_t f(std::string);
auto t = std::make_tuple(3.14, "a string");
// should be the same as std::make_tuple(f(std::get<0>(t)),…

Cotton Seed
- 363
- 3
- 13
0
votes
1 answer
How to extract/expand variadic template parameters
template
class Base
{
T1 t1;
T2 t2;
};
template
class Derived
: public Base< std::tuple>,
std::tuple> > //does not work
{
};
Derived…

Steffen Roeber
- 127
- 7
0
votes
1 answer
Unpacking std::pair>> to tuple
So I'm trying to come up with a function which converts a;
std::pair>
data type, into a std::tuple;
std::tuple
It should work in the general case, with an arbitrary number of mixed type arguments, the format for the pairs…

Skeen
- 4,614
- 5
- 41
- 67
-1
votes
3 answers
Is it possible to retrieve an element from a tuple using a non-const variable and as_const()?
As title states, I'm wondering if it's possible to pass in a variable to std::get<>() of a tuple?
I have a header file, which contains a struct that holds numerous params (and functions) that are used to instantiate different object types. The…

enoon.erehwon
- 21
- 3
-1
votes
1 answer
The compiler bug? Returning std::vector and std::string in std::tuple. But I got strange values
I would like to return multiple values and declare that function using auto.
But that does not work well. Values can not be returned correctly. It was overwritten.
I try to execute following functions f1~f3. Those function should return vector and…

Harumo Sasatake
- 41
- 1
- 6
-1
votes
1 answer
Convert template into std::tuple>
Suppose abc is defined as:
template
struct abc;
and xyz as
template
struct xyz;
Is it possible to declare an attribute in xyz such as std::tuple> for each T in Ts?

canellas
- 491
- 5
- 17