Hi everyone!
I'm doing a test to try and improve my understanding of vectors and boost tuples and am having the following problem.
I have simplified the issue down to the code pasted below and am working with:
- MS Visual C++ 2008
- Boost library 1.38
Aim
- I want to create a vector of tuple<int, double> elements and pass it by reference to a method/template to populate it.
At the moment in the populate method I can create the tuple element and insert it into a vector also created in the method, but I cannot insert the tuple into the vector which has been passed to the method by reference.
Notes
- I cannot change any of the code in main(), I can only write code in the populateData method.
- Not other fancy libraries etc
Error
- The error occurs in the tuple_basic.hpp and I have included it below (cut the length of it but important info is there)
Any help or info would be appreciated!!
Thanks!!!
Code Start===============================================================
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include "stdafx.h"
#include <vector>
#include <iostream>
#include <string>
#include <sstream>
#include <numeric>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_io.hpp>
template <typename CONTAINER>
void populateData(CONTAINER& container, size_t count)
{
typedef boost::tuple<int, double> row1_t;
std::vector<row1_t> myVect;
for(size_t i=0 ; i<count ; i++)
{
intTuple tempTuple((int(i)));
myVect.push_back(tempTuple);
row1_t myTuple((int(i)), (double(i))/10);
myVect.push_back(myTuple); //This works!
container.push_back(myTuple); //THIS IS THE PROBLEM LINE
};
};
int main()
{
typedef boost::tuple<int, double> row1_t;
typedef std::vector<row1_t> vec1_t;
vec1_t vec1;
populateData(vec1, 100);
TEST_REQUIRE_EQUAL(vec1.size(), 100);
TEST_CHECK_EQUAL_AS_STR(vec1[1],"(1 0.1)");
TEST_CHECK_EQUAL_AS_STR(vec1[99],"(99 9.9)");
}
|
Code End================================================================
Full Error:
1>------ Build started: Project: wintonExpertTest, Configuration: Debug Win32 ------
1>Compiling...
1>wintonExpertTest.cpp
1>c:\program files\boost\boost_1_38\boost\tuple\detail\tuple_basic.hpp(373) : error C2039: 'tail' : is not a member of 'boost::tuples::cons<HT,TT>'
1> with
1> [
1> HT=double,
1> TT=boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type
1> ]
1> c:\program files\boost\boost_1_38\boost\tuple\detail\tuple_basic.hpp(373) : see reference to function template instantiation 'boost::tuples::cons<HT,TT>::cons<T0,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type>(const boost::tuples::cons<HT,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type> &)' being compiled
1> with
1> [
1> HT=double,
1> TT=boost::tuples::cons<double,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type>,
1> T0=double
1> ]
1> c:\program files\boost\boost_1_38\boost\tuple\detail\tuple_basic.hpp(626) : see reference to function template instantiation 'boost::tuples::cons<HT,TT>::cons<T0,boost::tuples::cons<double,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type>>(const boost::tuples::cons<HT,boost::tuples::cons<double,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type>> &)' being compiled