使用Boost.Hana和通用lambdas:
#include <tuple>
#include <iostream>
#include <boost/hana.hpp>
#include <boost/hana/ext/std/tuple.hpp>
struct A {};
struct B {};
struct C {};
struct D {};
struct E {};
int main() {
using namespace std;
using boost::hana::for_each;
A a;
B b;
C c;
D d;
E e;
for_each(tie(a, b, c, d, e), [](auto &x) {
cout << typeid(x).name() << endl;
});
}
Run Code Online (Sandbox Code Playgroud)
http://coliru.stacked-crooked.com/a/ccb37ec1e453c9b4
| 归档时间: |
|
| 查看次数: |
344 次 |
| 最近记录: |