constexpr operator==(variant, variant)
Tim Shen
timshen@google.com
Tue Nov 22 22:00:00 GMT 2016
On Tue, Nov 22, 2016 at 5:38 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 22/11/16 00:03 -0800, Tim Shen wrote:
> We should at least report a missed-optimization bug.
Done. See PR 78484.
>
> My preference would be to make the function constexpr, with reduced
> performance. I don't know how critical the performance of comparing
> variants is, and we're not claiming our C++17 features are optimial
> yet anyway.
>
There are more problems:
1) If the user uses -O0, the code that is generated doesn't not take
constant time to run.
2) maybe it's fine to leave O(n) behavior for operator==(), but we
have the same issue with constexpr visit(). visit() is required "For
sizeof...(Variants) <= 1, the invocation of the callable object is
implemented in constant time". I can't actually find a way to
implement both a constexpr visit, and takes constant time if it's at
runtime.
--
Regards,
Tim Shen
More information about the Libstdc++
mailing list