C++ 如何知道采用Lambda参数节的参数是什么?c++;

C++ 如何知道采用Lambda参数节的参数是什么?c++;,c++,visual-studio-2017,filestream,casablanca,cpprest-sdk,C++,Visual Studio 2017,Filestream,Casablanca,Cpprest Sdk,我试图理解下面的代码,但我被困在 [=](ostream outFile){} 这个参数只是声明了一个新的空变量/类?或者是否正在获取任何以前的ostream值 如果可能,请尽可能多地解释,因为我是兰博达斯的新手 #include "stdafx.h" #include <cpprest/http_client.h> #include <cpprest/filestream.h> using namespace utility; /

我试图理解下面的代码,但我被困在

[=](ostream outFile){}

这个参数只是声明了一个新的空变量/类?或者是否正在获取任何以前的ostream值

如果可能,请尽可能多地解释,因为我是兰博达斯的新手

#include "stdafx.h"
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>

using namespace utility;                    // Common utilities like string conversions
using namespace web;                        // Common features like URIs.
using namespace web::http;                  // Common HTTP functionality
using namespace web::http::client;          // HTTP client features
using namespace concurrency::streams;       // Asynchronous streams

int main(int argc, char* argv[])

    auto fileStream = std::make_shared<ostream>();

    // Open stream to output file.
    pplx::task<void> requestTask = fstream::open_ostream(U("results.txt"))
        .then([=](ostream outFile){
            *fileStream = outFile;

            // Create http_client to send the request.
            http_client client(U("https://localbitcoins.com"));

            // Build request URI and start the request.
            uri_builder builder(U("/api/payment_methods/"));

            //builder.append_query(U("q"), U("cpprestsdk github"));
            return client.request(methods::GET, builder.to_string());
        })

        // Handle response headers arriving.
        .then([=](http_response response){
            printf("Received response status code:%u\n", response.status_code());

            // Write response body into the file.
            return response.body().read_to_end(fileStream->streambuf());
        })

        // Close the file stream.
        .then([=](size_t){
            return fileStream->close();
        });

    // Wait for all the outstanding I/O to complete and handle any exceptions
    try
    {
        requestTask.wait();
    }
    catch (const std::exception &e)
    {
        printf("Error exception:%s\n", e.what());
    }

    return 0;
}
#包括“stdafx.h”
#包括
#包括
使用命名空间实用程序;//常见的实用程序,如字符串转换
使用命名空间web;//常见的功能,如URI。
使用命名空间web::http;//通用HTTP功能
使用命名空间web::http::client;//HTTP客户端功能
使用命名空间并发::streams;//异步流
int main(int argc,char*argv[])
auto fileStream=std::make_shared();
//打开流以输出文件。
pplx::task requestTask=fstream::open_ostream(U(“results.txt”))
.然后([=](ostream outFile){
*fileStream=outFile;
//创建http_客户端以发送请求。
http_客户端(U)https://localbitcoins.com"));
//生成请求URI并启动请求。
uri\U builder(U(“/api/payment\U methods/”);
//附加查询(U(“q”)、U(“cpprestsdk github”);
返回client.request(方法::GET,builder.to_string());
})
//处理到达的响应头。
。然后([=](http_响应){
printf(“收到的响应状态代码:%u\n”,response.status_code());
//将响应主体写入文件。
返回response.body();
})
//关闭文件流。
。然后([=](大小){
返回fileStream->close();
});
//等待所有未完成的I/O完成并处理任何异常
尝试
{
requestTask.wait();
}
捕获(const std::exception&e)
{
printf(“错误异常:%s\n”,例如what());
}
返回0;
}

由于参数是按值获取的,因此它正在创建一个新的
ostream
对象,该对象可能会从其他ostream进行移动初始化。听起来您可以使用