On Mon, Sep 9, 2019 at 9:37 PM Richard Smith <richard@metafoo.co.uk> wrote:
Good point. Determining whether you can mark functions as constexpr seems like a reasonable motivation for at least try/catch and changing the active union member. Probably also for virtual function calls. How many feature test macros do we want? (Clang already implemented all of these, so we'll start advertising them all in the same release and don't need separate macros; I don't know about other implementations.)

This is good question to answer. In the nodiscard conversation, Wakely suggested having a specific nodiscard_reason macro even if we are already bumping the nodiscard value (http://www.open-std.org/pipermail/features/2019-August/000628.html), because it's more convenient for users.

In this case, would having granular macros help? I guess we'd write:

#if __cpp_constexpr_union_assign
constexpr
#endif
optional& operator=(nullopt_t) noexcept;

and is going to be more user friendly than

#if __cpp_constexpr > whatwasthatnumberagain
constexpr
#endif

and both probably easier to understand than

#if __cpp_constexpr > whatever
#define CONSTEXPR_UNION_TRY_POLY constexpr
#else
#define CONSTEXPR_UNION_TRY_POLY
#endif

CONSTEXPR_UNION_TRY_POLY optional& operator=(nullopt_t) noexcept;

although there's probably some clever preprocessor way of writing

CONSTEXPR(thatvalue) optional& operator=(nullopt_t) noexcept;

which wouldn't be so bad?

Barry