Boost logo

Boost :

From: Gero Peterhoff (g.peterhoff_at_[hidden])
Date: 2021-11-12 20:46:44

> Interesting point. In principle, BOOST_DESCRIBE_STRUCT and
> BOOST_DESCRIBE_CLASS should support unions, and a separate
> macro shouldn't be needed. So the static_assert on is_class is
> probably too strict and needs to be relaxed.
> However, I suspect that most code supporting described classes
> won't work correctly when passed a union. The examples in the
> documentation don't, so they would need to be updated with a
> check for is_class.

Just. Currently it is probably better to make a strict distinction.

> It's not clear why this needs to be std::get; adding overloads to namespace
> std is undefined behavior. It might be better off as a helper function in some
> namespace of your own.
> And a helper function of your own wouldn't need to be defined via a macro,
> it can be templated on C.
> template<std::size_t Index, class C>
> inline constexpr auto& get(C& arg) noexcept
> {
> using members = boost::describe::describe_members<C,
> boost::describe::mod_any_access>;
> static_assert(Index < boost::mp11::mp_size<members>());
> return arg.*boost::mp11::mp_at_c<members, Index>().pointer;
> }

You don't have to instantiate get in std. That's why I did it as a macro.

>> Do you have an idea how to implement __builtin_constant_p for all
>> compilers?
> I can't think of a way.

I have found . But doesn't work :-(
But that should be with the upcoming reflections
to be possible?


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