Hello, someone could tell me what is wrong in this piece of code #include "boost/tuple/tuple.hpp" using namespace boost::tuples; int main(){ tuple<int, double> t2(); get<0>(t2)=int(10); } I get the following error message: g++ try.cpp try.cpp: In function ‘int main()’: try.cpp:5: error: no matching function for call to ‘get(boost::tuples::tuple<int, double, 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> (&)()) In the tutorial it is written that tuple<int, double> t2() should construct the object via the default constructor. Why I cannot access the first element (it works if I give an initial value, for instance using tuple<int, double> t2(1); I get a similar error if I use the method get<N>() instead of the function. I am using gnu compiler gcc version 4.4.1 (GCC) in a i386 linux machine. Thank you, Luca -- Luca Formaggia
On Thu, 22 Apr 2010, luca formaggia wrote:
Hello,
someone could tell me what is wrong in this piece of code
#include "boost/tuple/tuple.hpp" using namespace boost::tuples; int main(){ tuple<int, double> t2(); get<0>(t2)=int(10); }
I get the following error message:
g++ try.cpp try.cpp: In function ‘int main()’: try.cpp:5: error: no matching function for call to ‘get(boost::tuples::tuple<int, double, 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> (&)())
In the tutorial it is written that tuple<int, double> t2() should construct the object via the default constructor.
This syntax is not correct. "tuple<int, double> t2();" declares a function named t2 that returns a tuple<int, double>, not an actual tuple. Leave off the extra parentheses to get a working version.
Why I cannot access the first element (it works if I give an initial value, for instance using tuple<int, double> t2(1); I get a similar error if I use the method get<N>() instead of the function.
Adding an initial value disambiguates the statement so it is no longer a function declaration. The version of get you use does not matter to this problem. -- Jeremiah Willcock
In article <alpine.LRH.2.00.1004221714070.12496@flowerpot.osl.iu.edu>, jewillco@osl.iu.edu says...
On Thu, 22 Apr 2010, luca formaggia wrote:
Hello,
someone could tell me what is wrong in this piece of code
#include "boost/tuple/tuple.hpp" using namespace boost::tuples; int main(){ tuple<int, double> t2(); get<0>(t2)=int(10); }
I get the following error message:
g++ try.cpp try.cpp: In function ?int main()?: try.cpp:5: error: no matching function for call to ?get(boost::tuples::tuple<int, double, 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> (&)())
In the tutorial it is written that tuple<int, double> t2() should construct the object via the default constructor.
This syntax is not correct. "tuple<int, double> t2();" declares a function named t2 that returns a tuple<int, double>, not an actual tuple. Leave off the extra parentheses to get a working version.
Why I cannot access the first element (it works if I give an initial value, for instance using tuple<int, double> t2(1); I get a similar error if I use the method get<N>() instead of the function.
Adding an initial value disambiguates the statement so it is no longer a function declaration. The version of get you use does not matter to this problem.
Or use initialization syntax: typedef tuple<int,double> tuple_; tuple_ t2 = tuple_(); -- http://crazyeddiecpp.blogspot.com/
participants (3)
-
Jeremiah Willcock
-
luca formaggia
-
Noah Roberts