When I try the example of README. Here get a error:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\include\experimental/filesystem(30): fatal error C1189: #error: The <experimental/filesystem> header providing std::experimental::filesystem is deprecated by Microsoft and will be REMOVED. It is superseded by the C++17 header providing std::filesystem. You can define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING to acknowledge that you have received this warning.
all the code is :
#include <iostream>
#include <cppcoro/read_only_file.hpp>
#include <cppcoro/task.hpp>
cppcoro::task<int> count_lines(std::string path)
{
auto file = co_await cppcoro::read_only_file::open(path);
int lineCount = 0;
char buffer[1024];
size_t bytesRead;
std::uint64_t offset = 0;
do
{
bytesRead = co_await file.read(offset, buffer, sizeof(buffer));
lineCount += std::count(buffer, buffer + bytesRead, '\n');
offset += bytesRead;
} while (bytesRead > 0);
co_return lineCount;
}
cppcoro::task<> usage_example()
{
// Calling function creates a new task but doesn't start
// executing the coroutine yet.
cppcoro::task<int> countTask = count_lines("D:\\Documents\\docsets\\Boost.docset\\meta.json");
// ...
// Coroutine is only started when we later co_await the task.
int lineCount = co_await countTask;
std::cout << "line count = " << lineCount << std::endl;
}
int main() {
return 0;
}
When I try the example of README. Here get a error:
all the code is :