StdInc.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 <QtWidgets>
  13. #include <QStringList>
  14. #include <QSet>
  15. #include <QVector>
  16. #include <QList>
  17. #include <QString>
  18. #include <QFile>
  19. #include "../vcmiqt/convpathqstring.h"
  20. VCMI_LIB_USING_NAMESPACE
  21. using NumericPointer = typename std::conditional_t<sizeof(void *) == sizeof(unsigned long long),
  22. unsigned long long, unsigned int>;
  23. template<class Type>
  24. NumericPointer data_cast(Type * _pointer)
  25. {
  26. static_assert(sizeof(Type *) == sizeof(NumericPointer),
  27. "Cannot compile for that architecture, see NumericPointer definition");
  28. return reinterpret_cast<NumericPointer>(_pointer);
  29. }
  30. template<class Type>
  31. Type * data_cast(NumericPointer _numeric)
  32. {
  33. static_assert(sizeof(Type *) == sizeof(NumericPointer),
  34. "Cannot compile for that architecture, see NumericPointer definition");
  35. return reinterpret_cast<Type *>(_numeric);
  36. }