Commit 5b8ff617 authored by Max Kellermann's avatar Max Kellermann

fs/io/BufferedOutputStream: add WithBufferedOutputStream()

parent 56bded07
/* /*
* Copyright (C) 2014-2018 Max Kellermann <max.kellermann@gmail.com> * Copyright 2014-2019 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -88,4 +88,13 @@ private: ...@@ -88,4 +88,13 @@ private:
#endif #endif
}; };
template<typename F>
void
WithBufferedOutputStream(OutputStream &os, F &&f)
{
BufferedOutputStream bos(os);
f(bos);
bos.Flush();
}
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment