fs/io/BufferedOutputStream: add WithBufferedOutputStream()

This commit is contained in:
Max Kellermann 2019-02-19 12:37:53 +01:00
parent 56bded07b1
commit 5b8ff61799

View File

@ -1,5 +1,5 @@
/*
* 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
* modification, are permitted provided that the following conditions
@ -88,4 +88,13 @@ private:
#endif
};
template<typename F>
void
WithBufferedOutputStream(OutputStream &os, F &&f)
{
BufferedOutputStream bos(os);
f(bos);
bos.Flush();
}
#endif