This is a follow-up question to my previous questions "Which parts of the C++14 Standard Library could be and which parts will be made constexpr
?" and "Guidelines to do constexpr
operator-overloading?"
In the runtime world, a nice idiom to overload operator<
for a struct of several data members, is to use std::tie
to convert a struct into a std::tuple
and piggy-back on its operator<
which does the Right Thing™ (lexicographic comparison on the various members).
In C++14, many parts of std::tuple
are made constexpr
, in particular make_tuple
, std::get
and the earlier mentioned operator<
. However, it appears that the seemingly related std::tie
is not marked constexpr
. This is rather annoying because it makes defining user-defined literal types that can be compared at compile-time more verbose than necessary.
Question: are there any technical reasons for which std::tie
is not marked constexpr
for C++14?
UPDATE: LWG issue 2301, implemented in libc++ and libstdc++ bug 65978
UPDATE2: fixed by @JonathanWakely a little over 3 hours after submitting the libstdc++ bug report!
In any case where it would utilize constexpr
ness, make_tuple
should behave exactly the same as tie
except that notionally tie
would add an extra level of unneeded indirection from the references. Thus there's no need for tie
to be constexpr
since make_tuple
would serve that purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With