Boost logo

Boost :

Subject: Re: [boost] Nasty compile time reflection and iteration for POD types using C++14 without macro
From: Paul Fultz II (pfultz2_at_[hidden])
Date: 2016-03-22 16:04:54

That looks pretty cool. This could be useful in Fit as well for fit::unpack.

* there's no known to me way to make get<>() method constexpr

On gcc and clang, you could try something like this:

#define CONST_FOLD(x) (__builtin_constant_p(x) ? (x) : (x))

template <std::size_t I, class T>
constexpr decltype(auto) get(const T& val) noexcept {
    auto t = CONST_FOLD(reinterpret_cast<const
decltype(detail::as_tuple<T>())*>( std::addressof(val) ));
    return get<I>(*t);

Of course, this requires the user to always use `CONST_FOLD` when calling
as well. There might be a better way.


> --
> Best regards,
> Antony Polukhin
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at