ldionne on gh-pages
Update benchmarks to 490dbf6 fo… (compare)
ldionne on gh-pages
Update benchmarks to 490dbf6 fo… (compare)
ldionne on gh-pages
Update benchmarks to 490dbf6 fo… (compare)
ldionne on gh-pages
Update benchmarks to 490dbf6 fo… (compare)
ldionne on gh-pages
Update benchmarks to 490dbf6 fo… (compare)
hana::common
in lieu of std::common_type
? The libc++ version on my recently updated mac still has that bug.
std::common_type<void, void>
does not compile
std::common_type_t
was working for me on my linux box because I was using libstd++
std::common_type
if you don’t need it to allow being specialized for user-defined types.
Undefined symbols for architecture x86_64
std::get<Type>(tuple)
will be map[hana::type_c<Type>]
.
std::tuple
with Hana’s algorithms by including <boost/hana/ext/std/tuple.hpp>
, and std::pair
by including <boost/hana/ext/std/pair.hpp>
. See the documentation section on external adapters.
std::tuple
, hana::to<hana::ext::std::tuple_tag>(some_hana_tuple)
will do the trick. The other way around, hana::to<hana::tuple_tag>(some_std_tuple)
should also work.
index_of
function, find_if
seems to return only by copy and map is not ordered.
auto tuple = hana::make_tuple(1, 1.0f, 1.0);
auto types = hana::tuple_t<float, double, int>;
hana::sort(tuple, [](auto x, auto y) {
return hana::index_of(types, hana::decltype_(x)) <
hana::index_of(types, hana::decltype_(y));
});
#include<boost/hana.hpp>
namespace hana = boost::hana;
auto rearrange = [](auto xs, auto spec) {
auto type_map = hana::unpack(
hana::range_c<int, 0, hana::length(xs)>,
[&](auto... i) {
return hana::make_map(hana::make_pair(
hana::decltype_(xs[i]), i)...);
});
return hana::unpack(spec,
[&](auto... x) {
return hana::make_tuple(xs[type_map[hana::decltype_(x)]]...);
});
};
int main()
{
BOOST_HANA_RUNTIME_ASSERT(
rearrange(
hana::make_tuple(1, 1.0f, 1.0),
hana::tuple_t<double, int, float>)
== hana::make_tuple(1.0, 1, 1.0f));
}