A Boost C++ library providing an implementation of tuple, a fixed-sized collection of elements, possibly of different types
Questions tagged [boost-tuples]
54 questions
45
votes
9 answers
Boost::Tuples vs Structs for return values
I'm trying to get my head around tuples (thanks @litb), and the common suggestion for their use is for functions returning > 1 value.
This is something that I'd normally use a struct for , and I can't understand the advantages to tuples in this…

Roddy
- 66,617
- 42
- 165
- 277
12
votes
2 answers
boost tuple: increasing maximum number of elements
The boost tuple documentation says:
The current version supports tuples
with 0-10 elements. If necessary, the
upper limit can be increased up to,
say, a few dozen elements.
However, I could not find where it says how to do this.
I would like…

Tom
- 5,219
- 2
- 29
- 45
12
votes
1 answer
Why can't std::tuple be element-wise constructed with a std::tuple of compatible types?
I can't initialize std::tuple elements element-wise from a std::tuple of compatible types. Why doesn't it work as with boost::tuple?
#include
#include
template
struct Foo
{
// error: cannot convert…

LogicStuff
- 19,397
- 6
- 54
- 74
8
votes
2 answers
const std::map?
// BOOST Includes
#include // Boost::Assign
#include // Boost::Assign::List_Of
#include // Boost::Assign::Map_List_Of
#include …
Maciek
7
votes
2 answers
C++ Cannot call base class method from within derived class
this is my first question, I hope I do everything correct.
I try to derive a class from a boost tuple. Boost's tuples provide a get() template method to access the individual fields. Interestingly I cannot use the method from within the derived…

Evil Azrael
- 73
- 1
- 3
6
votes
2 answers
Boost tuple performance
According to boost::tuple documentation, accessing a single element of a tuple has the same performance as accessing a member variable. For example, given the following declaration:
tuple t1(A(), B(), C());
struct T { A a; B b; C c; }
T…

FireAphis
- 6,650
- 8
- 42
- 63
6
votes
1 answer
Is Boost.Tuple compatible with C++0x variadic templates?
I was playing around with variadic templates (gcc 4.5) and hit this problem :
template
boost::tuple
my_make_tuple(Args... args)
{
return boost::tuple(args...);
}
int main (void)
{
boost::tuple…

Arzar
- 13,657
- 3
- 25
- 25
5
votes
3 answers
How to write a `<<` operator for boost::tuple?
In the sample code below, it shows that boost::tuple can be created implicitly from the first template argument.
Because of that I am not able to write a << operator as it becomes ambiguous.
Also I don't understand why ostringstream& << float is…

balki
- 26,394
- 30
- 105
- 151
5
votes
2 answers
Solving the mixin constructor problem in C++ using variadic templates
I've recently tackled the constructor problem, where various mixins classes that decorate each other (and a topmost host class) have different constructor signatures. To maintain a single constructor in the resulting decorated class, and without…

Eitan
- 862
- 1
- 7
- 17
5
votes
1 answer
Sorting deque of boost tuples
Not sure if I have a simple typo somewhere, but I'm running into issues in sorting a deque of tuples.
So, my deque looks like this:
std::deque > messages;
And then I have my call to…

erik
- 3,810
- 6
- 32
- 63
4
votes
1 answer
Constructing one concrete boost::tuple type using another
Given:
typedef boost::tuple< T1, T2, T3, ..., Tn > Tuple_Tn
where the types T1, ... Tn are all defined,
And given type T_another, I'd like to define a new tuple type:
typedef boost::tuple< T1, T2, T3, ..., Tn, T_another > Tuple_T_plus_1
But here…

Lev
- 727
- 5
- 17
4
votes
2 answers
boost::bind doesn't work with boost::tuple::get()
I am trying to use boost::bind and STL with boost::tuple, but each time I try to compile I get the following error.
error: call of overloaded ‘bind(,
boost::arg<1>&)’ is ambiguous
Do you know what I…

Abruzzo Forte e Gentile
- 14,423
- 28
- 99
- 173
4
votes
1 answer
C++ Tuple of Boost.Range - get Tuple of element types?
I am experimenting with Boost.Range and the Boost Tuple. If I have a Tuple of ranges, how can I typedef a Tuple or the corresponding element values? To put this another way, what do I put in place of /*?*/ here:
typedef…

paperjam
- 8,321
- 12
- 53
- 79
4
votes
2 answers
Sum the components of a tuple up by using std::get, std::tuple_size, std::tuple_element
I've got a custom class that has a tuple-like interface. Because I want my code to be as generic as possible, I thought that it would be a good idea to base my algorithms on the functions std::get, std::tuple_size, std::tuple_element so you just…

Max
- 63
- 1
- 5
3
votes
3 answers
number of templated parameters in a boost::tuple
I am using boost::tuple for my code.
Suppose that I want to store an equivalent of a structure having 3 members
typedef boost::tuple< std::string, int, double > my_struct;
Is there any way of method to call on the tuple that will give me the…

Abruzzo Forte e Gentile
- 14,423
- 28
- 99
- 173