Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
file_utils.h
Go to the documentation of this file.
1 #ifndef gamgee__file_utils__guard
2 #define gamgee__file_utils__guard
3 
4 #include <memory>
5 #include <fstream>
6 #include <string>
7 
8 namespace gamgee {
9 namespace utils {
10 
15  void operator()(std::ifstream* p) const {
16  if ( p != nullptr ) {
17  p->close();
18  delete p;
19  }
20  }
21 };
22 
27 std::shared_ptr<std::ifstream> make_shared_ifstream(std::ifstream* ifstream_ptr);
28 
33 std::shared_ptr<std::ifstream> make_shared_ifstream(std::string filename);
34 
35 }
36 }
37 
38 #endif /* gamgee__file_utils__guard */
std::shared_ptr< std::ifstream > make_shared_ifstream(std::ifstream *ifstream_ptr)
wraps a pre-allocated ifstream in a shared_ptr with correct deleter
Definition: file_utils.cpp:12
a functor object to delete an ifstream
Definition: file_utils.h:14
void operator()(std::ifstream *p) const
Definition: file_utils.h:15
Definition: exceptions.h:9