Print a tuple using get_head() and get_tail() in while-loop

A

Alex Vinokur

Suppose we have the following tuple
boost::tuple<int, std::string, bool, double> t (/* initialization */)

I would like to print that tuple using get_head() and get_tail() in
while-loop

while (/* What is a cindition */)
{
std::cout << t.get_head() << std::endl;
// What to do with t.get_tail()
}


Alex Vinokur
 
K

kwikius

Alex Vinokur said:
Suppose we have the following tuple
boost::tuple<int, std::string, bool, double> t (/* initialization */)

I would like to print that tuple using get_head() and get_tail() in
while-loop

while (/* What is a cindition */)
{
std::cout << t.get_head() << std::endl;
// What to do with t.get_tail()
}

You need to use a compile time recursion Its not as complicated as it
sounds, just some template specialisations to make recursion of a function..
See here for some example

http://tinyurl.com/6oe3fs

regards
Andy Little
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top