Startup returns a unique_ptr instead of using a static
This commit is contained in:
@@ -3,11 +3,23 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace aocpp {
|
||||
|
||||
auto Startup(int argc, char ** argv) -> std::istream&;
|
||||
class ConditionalDeleter {
|
||||
bool should_delete_;
|
||||
|
||||
public:
|
||||
ConditionalDeleter(bool should_delete) : should_delete_ {should_delete} {}
|
||||
|
||||
template <typename T>
|
||||
auto operator()(T * pointer) -> void { if (should_delete_) { delete pointer; }}
|
||||
};
|
||||
|
||||
auto Startup(int argc, char ** argv) -> std::unique_ptr<std::istream, ConditionalDeleter>;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user