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 case - it seems an error-prone approach for the terminally lazy.
Borrowing an example, I'd ...
// BOOST Includes
#include <boost/assign.hpp> // Boost::Assign
#include <boost/assign/list_of.hpp> // Boost::Assign::List_Of
#include <boost/assign/std/map.hpp> // Boost::Assign::Map_List_Of
#include <boost/tuple/tuple.hpp> // Boost::Tuples
// STD Includes
#include <map>
#include <vector>
#include <string>
// Using namespaces
us...
I have some code that looks like this:
typedef tuple<int, int, double> DataPoint;
vector<DataPoint> data;
vector<double> third_column_only;
// Code to read in data goes here.
transform(data.begin(), data.end(), back_inserter(values), tuples::get<1, DataPoint>);
Unfortunately, the last line doesn't compile - it gives me a message like ...
I have been using a using a boost tuple as the value in an STL map.
Up until now, I only had to construct the tuple and insert into the map and at a later stage retrieve the values.
Now I need to be able to change the tuple in the map. Is this possible, or have I run into the one place you should'nt be using tuples instead of structs.
...
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 like:
std::map<int, std::set<boost::tuple> >
but not exctly sure how to exactly do this, bossib...
Hi,
I was playing around with variadic templates (gcc 4.5) and hit this problem :
template <typename... Args>
boost::tuple<Args...>
my_make_tuple(Args... args)
{
return boost::tuple<Args...>(args...);
}
int main (void)
{
boost::tuple<int, char> t = my_make_tuple(8, 'c');
}
GCC error message :
sorry, unimplemented: cannot expa...
#include <list>
#include <boost/tuple/tuple.hpp>
template<class InputIterator>
void f(InputIterator it)
{
typedef boost::tuple<typename InputIterator::value_type, int> Pair;
std::list<Pair> paired;
typename std::list<Pair>::const_iterator output;
for(output=paired.begin(); output!=paired.end(); ++output)
{
ou...
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 adding init functions, I've found the following solution. The only restriction it places on a...