Questions tagged [boost-tuples]

A Boost C++ library providing an implementation of tuple, a fixed-sized collection of elements, possibly of different types

54 questions
3
votes
4 answers

Tuples of unknown size/parameter types

I need to create a map, from integers to sets of tuples, the tuples in a single set have the same size. The problem is that the size of a tuple and its parameter types can be determined at runtime, not compile time. I am imagining something…
myahya
  • 3,079
  • 7
  • 38
  • 51
3
votes
1 answer

How to assign a boost::tuple to boost::shared_ptr

In my code I have something like this shrd_ptr_obj st = boost::make_shared(); Myobj tp = boost::make_tuple(0,0,0,0,0 ); How do I make st point to tp ?
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
3
votes
2 answers

Issue with key of std::map

Consider the following code. A tuple consisting of integer and vector of integer is defined as the key of a map. However, I was surprised that the compiler does not throw any error when inserting or looking for a tuple consisting of integer and…
sam
  • 55
  • 4
2
votes
3 answers

Define tuple with variable size

I want to define a boost fusion::vector in my class with the size defined by a template parameter. ATM I'm doing this with a specialization of a helper class, but I think there should be a way to do this with boost mpl/fusion or something else in…
Smittii
  • 187
  • 1
  • 10
2
votes
1 answer

Traversing a C++ tuple in an order defined at runtime

It's possible to iterate over a boost or std tuple, but can I iterate in an order determined at runtime, while still retaining type information? Suppose my tuple was filled with objects of type Foo: #include using namespace std; template…
user2023370
  • 10,488
  • 6
  • 50
  • 83
2
votes
2 answers

How does std::thread store variadic arguments passed through its constructor?

Let's say I declare a thread with the following code: #include #include void printStuff(const char* c, long x) { std::cout << x << " bottles of " << c << " on the wall\n"; } int main() { std::thread t(printStuff, "beer",…
2
votes
3 answers

Does `boost::make_tuple` make copies?

I have something like this in my code val = boost::make_tuple(objA , objB); My question is does boost::make_tuple make copies of objA and objB ?
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
2
votes
1 answer

Boost::tuple's equivalent to Python's itemgetter?

I have some code that looks like this: typedef tuple DataPoint; vector data; vector third_column_only; // Code to read in data goes here. transform(data.begin(), data.end(), back_inserter(values), tuples::get<1,…
user161827
1
vote
1 answer

Using boost::mpl::vector to create variadic templates?

I'm stuck with C++03 for now, and I want to create a global function that accepts any number of type-safe arguments (up to a reasonable limit if necessary, like 9). I have access to the full boost library in my code base, so I'm hoping…
void.pointer
  • 24,859
  • 31
  • 132
  • 243
1
vote
1 answer

How does the boost tuple 'get' method work?

After delving into the source of the excellent boost tuple class (tuple_basic.hpp), I can see that a recursive templated algorithm is used in the 'get' method for accessing the tuple members. What I'm struggling to understand is how a numeric…
Gearoid Murphy
  • 11,834
  • 17
  • 68
  • 86
1
vote
1 answer

Reference to ‘tuple’ is ambiguous in SESHAT

I have tried to build SESHAT(Handwritten math expression parser). And I have got an error like this below: In file included from rnnlib4seshat/DataSequence.hpp:26:0, from symrec.h:30, from production.h:28, from…
Duy Huynh
  • 31
  • 6
1
vote
2 answers

Segmentation Faults with boost::tuple and std::map

I have trouble with using code similar to the following one: std::map, int> m; boost::tuple key = boost::make_tuple(1,2,3); m.find(key); The compiler does not see any errors. But when I start my program a…
Bastian
  • 4,638
  • 6
  • 36
  • 55
1
vote
1 answer

error: boost.fusion::for_each() and struct derived from boost.tuple

on compilation this code: struct any_type: boost::tuple { ... }; struct functor { void operator()(const std::string& v) { std::cout << v << std::endl; } }; int main() { any_type type; …
niXman
  • 1,698
  • 3
  • 16
  • 40
1
vote
1 answer

no == defined for boost::tuples

I have this code: ... #include "boost/tuple/tuple_comparison.hpp" ... template function memoize(const Args && ... args) { using noRef = boost::tuple
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
1
vote
2 answers

How to initialize a tuple of non-default-constructible not-copyable objects?

Given some classes with parameterized constructors, such as: class A { public: A(bool b, int i) { /*...*/ } private: A(const A&) {} }; class B { public: B(char c, double d) { /* ... */ } private: B(const B&) {} }; How to properly…
shrike
  • 4,449
  • 2
  • 22
  • 38