C++ Logo

sg10

Advanced search

[SG10] Macro for P0084R2: Emplace Return Type

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Fri, 31 Mar 2017 11:57:15 +0100
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.

Received on 2017-03-31 12:57:39