[SG10] Macro for P0084R2: Emplace Return Type

James Dennett jdennett at google.com
Fri Mar 31 20:31:09 CEST 2017


On Fri, Mar 31, 2017 at 3:57 AM, Jonathan Wakely <cxx at kayari.org> wrote:

> Do we need a macro for this? I can't think of a sensible example where
> it would help.
>
> #if __cpp_lib_emplace_return_type
> auto& x = container.emplace_back(arg1, arg2);
> #else
> container.emplace_back(arg1, arg2);
> auto& x = container.back();
> #endif
>
> If you want to work with compilers that don't implement the feature
> you have to write the second form anyway and you might as well just do
> that unconditionally. There's no efficiency benefit to the new form,
> it's just mildly simpler to write. But writing both forms isn't
> simpler.
>

I concur with your reasoning; a macro for this is not useful.  (One more
thing checks out too: users are not permitted to take the address of
emplace_back anyway, so knowing its return type doesn't help with that, and
it's discoverable with decltype anyway for cases where both forms could
compile.)

There's no sense in doing conditional compilation here, and we shouldn't
enable it.

-- James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.open-std.org/pipermail/features/attachments/20170331/caae4616/attachment.html 


More information about the Features mailing list