StdInc.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * StdInc.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../Global.h"
  12. #include <boost/crc.hpp>
  13. #include <boost/date_time/posix_time/posix_time_types.hpp> //no i/o just types
  14. #include <boost/random/linear_congruential.hpp>
  15. #include <boost/random/mersenne_twister.hpp>
  16. #include <boost/random/variate_generator.hpp>
  17. #include <boost/system/system_error.hpp>
  18. template<class T, class F>
  19. inline const T * dynamic_ptr_cast(const F * ptr)
  20. {
  21. #ifndef __APPLE__
  22. return dynamic_cast<const T *>(ptr);
  23. #else
  24. if(!strcmp(typeid(*ptr).name(), typeid(T).name()))
  25. {
  26. return static_cast<const T *>(ptr);
  27. }
  28. return nullptr;
  29. #endif
  30. }
  31. template<class T, class F>
  32. inline T * dynamic_ptr_cast(F * ptr)
  33. {
  34. #ifndef __APPLE__
  35. return dynamic_cast<T *>(ptr);
  36. #else
  37. if(!strcmp(typeid(*ptr).name(), typeid(T).name()))
  38. {
  39. return static_cast<T *>(ptr);
  40. }
  41. return nullptr;
  42. #endif
  43. }