Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. // example_fwd.hpp
  2. // Here necessary to forward declare the template class,
  3. // you don't want people to declare them in case you wish to add
  4. // another template symbol (with a default) later on
  5. class MyClass;
  6. template <class T> class MyClassT;
  7.  
  8. // example.hpp
  9. #include "project/example_fwd.hpp"
  10.  
  11. // Those can't really be skipped
  12. #include <string>
  13. #include <vector>
  14.  
  15. #include "project/pimpl.hpp"
  16.  
  17. // Those can be forward declared easily
  18. #include "project/foo_fwd.hpp"
  19.  
  20. namespace project { class Bar; }
  21.  
  22. namespace project
  23. {
  24. class MyClass
  25. {
  26. public:
  27. struct Color // Limiting scope of enum
  28. {
  29. enum type { Red, Orange, Green };
  30. };
  31. typedef Color::type Color_t;
  32.  
  33. public:
  34. MyClass(); // because of pimpl, I need to define the constructor
  35.  
  36. private:
  37. struct Impl;
  38. pimpl<Impl> mImpl; // I won't describe pimpl here :p
  39. };
  40.  
  41. template <class T> class MyClassT: public MyClass {};
  42. } // namespace project
  43.  
  44. // example_impl.hpp (not visible to clients)
  45. #include "project/example.hpp"
  46. #include "project/bar.hpp"
  47.  
  48. template <class T> void check(MyClass<T> const& c) { }
  49.  
  50. // example.cpp
  51. #include "example_impl.hpp"
  52.  
  53. // MyClass definition
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement