Skip to content

WriteCallback should take a string_view as argument instead of a std::string to avoid a copy #1074

Closed
@fdgStilla

Description

@fdgStilla

Is your feature request related to a problem?

My client application download huge files from a server using Download(std::ofstream& file).
But I realized that no error was raised when the writing fails (in my case the disk was full).
So I switched to Download(const WriteCallback& write) to manage the iostream myself (using this method ) but I noticed that the data is copied to a string for each callback, so it was not equivalent to the previous code.

Possible Solution

I suggest to use a std::string_view as argument instead of a std::string in the WriteCallback.

Alternatives

No response

Additional Context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions