#include <boost/scope/defer.hpp>
BOOST_SCOPE_DEFER [&] {
close(fd);
Implementation here: https://github.com/boostorg/scope/blob/develop/include/boost...