C++ std::tuple 作为函数返回值的一个简单用法C++17
看到很多std::tuple的资料,但用起来很不方便,不能像python那样随心所欲。看到一个新的方法, 直接用中括号解包记录一下,c++17编译通过
#include <tuple>
#include <iostream>
std::tuple<int, float> fun(float c)
{
float b = std::sin(c);
int a = (int)(b * 10);
return std::make_tuple(a, b);
}
int main()
{
auto [a, b] = fun(1.2);
std::cout<< a << " " << b << std::endl;
}