mirror of
				https://github.com/Zygo/bees.git
				synced 2025-11-03 19:50:34 +01:00 
			
		
		
		
	crucible: add cleanup class
Store a function (or closure) in an instance and invoke the function from the destructor. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
		
							
								
								
									
										18
									
								
								include/crucible/cleanup.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								include/crucible/cleanup.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
#ifndef CRUCIBLE_CLEANUP_H
 | 
			
		||||
#define CRUCIBLE_CLEANUP_H
 | 
			
		||||
 | 
			
		||||
#include <functional>
 | 
			
		||||
 | 
			
		||||
namespace crucible {
 | 
			
		||||
	using namespace std;
 | 
			
		||||
 | 
			
		||||
	class Cleanup {
 | 
			
		||||
		function<void()> m_cleaner;
 | 
			
		||||
	public:
 | 
			
		||||
		Cleanup(function<void()> func);
 | 
			
		||||
		~Cleanup();
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // CRUCIBLE_CLEANUP_H
 | 
			
		||||
		Reference in New Issue
	
	Block a user