This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: constexpr operator==(variant, variant)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]