我以a的形式从函数返回三个项目std::tuple.
... myFunction()
{
...
return std::tuple< int, unsigned long long, unsigned int >{ errorCode, timeStamp, sizeOfBuffer };
}
Run Code Online (Sandbox Code Playgroud)
由于必须使用std::get或访问返回值std::tie,编译器是否针对未使用的值进行优化(g ++ 4.8)?
是的,它可以.http://goo.gl/UB7DNc
#include "stdio.h"
#include <tuple>
std::tuple<int, unsigned long long, unsigned int> myFunction()
{
return std::tuple<int, unsigned long long, unsigned int>{ 1, 2, 3 };
}
int f()
{
return std::get<0>(myFunction());
}
Run Code Online (Sandbox Code Playgroud)
变
myFunction():
movq %rdi, %rax
movl $3, (%rdi)
movq $2, 8(%rdi)
movl $1, 16(%rdi)
ret
f():
movl $1, %eax
ret
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
212 次 |
| 最近记录: |