This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [v3 PATCH] Implement LWG 2857, {variant,optional,any}::emplace should return the constructed value.


On 16/03/17 00:43 +0200, Ville Voutilainen wrote:
On 16 March 2017 at 00:31, Jonathan Wakely <jwakely@redhat.com> wrote:
      emplace(_Args&&... __args)
      {
        __do_emplace<_Decay<_ValueType>>
          (std::forward<_Args>(__args)...);
+       return *(std::any_cast<_Decay<_ValueType>>(this));


Can we avoid the branch in any_cast to check the stored type?
We know it's the right type, because we just stored it.

While I would hope the compiler to be smart enough to realize some of
that (we are passing in
this), the other branches might not be so easy. But certainly, we can
axe every one of the extraneous
branches, like in the attached amendment.

And then we don't need the forward declarations of any and any_ast,
right?

OK for trunk like that, thanks.



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