我找不到訪問真實對象的方法,hana::for_each
迭代元組。遍歷boost :: hana :: tuple
struct A {
std::string name;
}
struct B {
std::string name;
}
using type_t = decltype(boost::hana::tuple_t<A, B>);
type_t names;
boost::hana::for_each(names, [&](const auto& a) {
std::cout << a.name << std::endl;
});
的a
類型似乎是hana::tuple_impl<...>
,似乎是不澆注料其基礎類型decltype(std::decay_t<a>)::type
。
我基本上想迭代一個模板對象(容器)的列表,它們具有相同的接口但包含不同的值。更好的方式來實現這一點是值得歡迎
我懷疑這'decltype(升壓::花:: tuple_t )'。這是什麼意思?本身不是'tuple_t '*類型*嗎? – Nawaz
@Nawaz文檔說它的用法就像這樣'auto types = hana :: tuple_t;'所以我猜這是一個C++ 14變量模板。 http://www.boost.org/doc/libs/1_61_0/libs/hana/doc/html/index.html –
Etherealone