
In article
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
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
(&)()) In the tutorial it is written that tuple
t2() should construct the object via the default constructor. This syntax is not correct. "tuple
t2();" declares a function named t2 that returns a tuple , 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
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