[libcxx-commits] [libcxx] [libc++] Make sure that __desugars_to isn't tripped up by reference_wrapper and cv-refs (PR #132092)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 24 10:55:47 PDT 2025
================
@@ -52,6 +52,24 @@ struct __totally_ordered_less_tag {};
template <class _CanonicalTag, class _Operation, class... _Args>
inline const bool __desugars_to_v = false;
+// For the purpose of determining whether something desugars to something else,
----------------
ldionne wrote:
I suspect that this is entirely theoretical at the moment, since I don't think we use volatile-qualified predicates anywhere. At least we don't desugar any such predicates that are not stateless, which is where `volatile` could conceivably make a difference.
I feel that `__desugars_to` operates at the level of "is this operation mathematically the same as that other operation", not "is this operation exactly the same as that other operation". This distinction is actually important because otherwise we might not want to also strip ref qualifiers from predicates. For the same reason, I don't think we can ever specialize `__desugars_to` on a predicate that is not stateless, making the `volatile` qualification issue somewhat moot.
Do you have something concrete in mind like an example of an algorithm that could be passed a `volatile` predicate and where that could be interpreted as "don't optimize this"?
In the meantime, I think stripping `volatile` is mostly for consistency and of low value, so I don't mind removing it, but I'd like to either understand a good reason for not doing it, or do it for consistency.
https://github.com/llvm/llvm-project/pull/132092
More information about the libcxx-commits
mailing list