Om
copyable.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Copyable_
16 
17  #include "om/copyable.hpp"
18 
19 #else
20 
21  #ifndef Om_Macro_Precompilation_
22 
23  #include <cassert>
24  #include <stdexcept>
25 
26  #endif
27 
28 // MARK: - Om::Copyable
29 
30  #define Type_ \
31  Om::Copyable
32 
33 // MARK: public (non-static)
34 
35 inline Type_::~Copyable() {}
36 
37 inline std::auto_ptr<Type_> Type_::Copy() const {
38  assert(0);
39  throw std::logic_error("Pure virtual function called.");
40 }
41 
42  #undef Type_
43 
44 // MARK: - Om::
45 
46 template <typename TheCopyable>
47 inline std::auto_ptr<TheCopyable> Om::Copy(TheCopyable const & theCopyable) {
48  return std::auto_ptr<TheCopyable>(
49  static_cast<TheCopyable *>(
50  theCopyable.Copy().release()
51  )
52  );
53 }
54 
55 #endif
Om header file.
std::auto_ptr< TheCopyable > Copy(TheCopyable const &)