|
Boost Users : |
Subject: Re: [Boost-users] iterator over boost::tuple
From: Louis Dionne (ldionne.2_at_[hidden])
Date: 2015-07-06 14:53:57
Uthpal Urubail <uthpal.urubail <at> altair.com> writes:
>
> Experts,
> What is the best way to iterator over boost::tuple and return value?
> Example:
> For(int i=0;i<boost::tuples::length<T>::value;i++)
> {
> Boost_tuple_example.get<i>();
> }
> Regards,
> UJ
If you're in C++14, Hana to the rescue!
------------------------------------------------------------------------------
#include <boost/hana/tuple.hpp>
#include <string>
namespace hana = boost::hana;
int main() {
auto xs = hana::make_tuple(1, 'x', std::string{"foobar"});
hana::for_each(xs, [](auto x) {
// use x
});
}
------------------------------------------------------------------------------
Regards,
Louis
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net