Is it possible to assign the members of a pair without creating a temporary object?
#include <tuple>
using namespace std;
pair< bool, int > foo()
{
return make_pair( false, 3 );
}
int main()
{
int x;
bool y;
auto z = foo();
x = z.second;
y = z.first;
return 0;
}
In the above code, the object auto z
is needed to "hold" the pair before dissecting it, but its creation might be expensive in the actual code.
Aucun commentaire:
Enregistrer un commentaire