utility::Cleanup: Replace "Nop"

A default constructor suffices where "Nop" was used, so it was removed.
This commit is contained in:
Stephen Seo 2024-03-20 19:18:37 +09:00
parent d5d722022c
commit d29d2434ab
3 changed files with 8 additions and 10 deletions

View file

@ -456,8 +456,8 @@ image::Bl dither::blue_noise(int width, int height, int threads,
// create compute pipeline. // create compute pipeline.
VkPipelineLayout compute_pipeline_layout; VkPipelineLayout compute_pipeline_layout;
VkPipeline compute_pipeline; VkPipeline compute_pipeline;
utility::Cleanup cleanup_pipeline_layout(utility::Cleanup::Nop{}); utility::Cleanup cleanup_pipeline_layout{};
utility::Cleanup cleanup_pipeline(utility::Cleanup::Nop{}); utility::Cleanup cleanup_pipeline{};
{ {
VkShaderModuleCreateInfo shader_module_create_info{}; VkShaderModuleCreateInfo shader_module_create_info{};
shader_module_create_info.sType = shader_module_create_info.sType =
@ -549,8 +549,8 @@ image::Bl dither::blue_noise(int width, int height, int threads,
VkBuffer precomputed_buf; VkBuffer precomputed_buf;
VkDeviceMemory precomputed_buf_mem; VkDeviceMemory precomputed_buf_mem;
utility::Cleanup cleanup_precomputed_buf(utility::Cleanup::Nop{}); utility::Cleanup cleanup_precomputed_buf{};
utility::Cleanup cleanup_precomputed_buf_mem(utility::Cleanup::Nop{}); utility::Cleanup cleanup_precomputed_buf_mem{};
{ {
VkBuffer staging_buffer; VkBuffer staging_buffer;
VkDeviceMemory staging_buffer_mem; VkDeviceMemory staging_buffer_mem;
@ -647,8 +647,8 @@ image::Bl dither::blue_noise(int width, int height, int threads,
VkBuffer other_buf; VkBuffer other_buf;
VkDeviceMemory other_buf_mem; VkDeviceMemory other_buf_mem;
utility::Cleanup cleanup_other_buf(utility::Cleanup::Nop{}); utility::Cleanup cleanup_other_buf{};
utility::Cleanup cleanup_other_buf_mem(utility::Cleanup::Nop{}); utility::Cleanup cleanup_other_buf_mem{};
{ {
VkBuffer staging_buffer; VkBuffer staging_buffer;
VkDeviceMemory staging_buffer_mem; VkDeviceMemory staging_buffer_mem;

View file

@ -3,7 +3,7 @@
utility::Cleanup::Cleanup(std::function<void(void *)> fn, void *ptr) utility::Cleanup::Cleanup(std::function<void(void *)> fn, void *ptr)
: fn(fn), ptr(ptr) {} : fn(fn), ptr(ptr) {}
utility::Cleanup::Cleanup(Nop) : fn(), ptr(nullptr) {} utility::Cleanup::Cleanup() : fn(), ptr(nullptr) {}
utility::Cleanup::~Cleanup() { utility::Cleanup::~Cleanup() {
if (this->fn.has_value()) { if (this->fn.has_value()) {

View file

@ -33,10 +33,8 @@ inline float dist(int a, int b, int width) {
class Cleanup { class Cleanup {
public: public:
struct Nop {}; Cleanup();
Cleanup(std::function<void(void *)> fn, void *ptr); Cleanup(std::function<void(void *)> fn, void *ptr);
Cleanup(Nop nop);
~Cleanup(); ~Cleanup();
// allow move // allow move