hash_info.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Copyright 2017 Daniel James.
  2. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. // Not a test, just a small program to write out configuration info
  5. #include <boost/container_hash/hash.hpp>
  6. #include <iostream>
  7. #include <algorithm>
  8. #if defined(BOOST_MSVC)
  9. struct msvc_version {
  10. unsigned version;
  11. char const* description;
  12. friend bool operator<(msvc_version const& v1, msvc_version const& v2) {
  13. return v1.version < v2.version;
  14. }
  15. };
  16. void write_compiler_info() {
  17. // From:
  18. // https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B
  19. // https://blogs.msdn.microsoft.com/vcblog/2017/11/15/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/
  20. msvc_version versions[] = {
  21. {0, "Old Visual C++"},
  22. {1000, "Visual C++ 4.x, VS4.0?"},
  23. {1100, "Visual C++ 5.0, VS97"},
  24. {1200, "Visual C++ 6.0, VS6.0"},
  25. {1300, "Visual C++ 7.0, VS.NET 2002"},
  26. {1310, "Visual C++ 7.1, VS.NET 2003"},
  27. {1400, "Visual C++ 8.0, VS2005"},
  28. {1500, "Visual C++ 9.0, VS2008"},
  29. {1600, "Visual C++ 10.0, VS2010"},
  30. {1700, "Visual C++ 11.0, VS2012"},
  31. {1800, "Visual C++ 12.0, VS2013"},
  32. {1900, "Visual C++ 14.00, VS2015"},
  33. {1910, "Visual C++ 14.10, VS2017 15.1/2"},
  34. {1911, "Visual C++ 14.11, VS2017 15.3/4"},
  35. {1912, "Visual C++ 14.12, VS2017 15.5"},
  36. {1913, "Visual C++ 14.13, VS2017 15.6"}
  37. };
  38. msvc_version msvc = { BOOST_MSVC, "" };
  39. msvc_version* v = std::upper_bound(versions,
  40. versions + sizeof(versions) / sizeof(*versions),
  41. msvc) - 1;
  42. unsigned difference = msvc.version - v->version;
  43. std::cout << v->description << std::endl;
  44. if (difference) {
  45. std::cout << "+" << difference << std::endl;
  46. }
  47. }
  48. #else
  49. void write_compiler_info() {
  50. }
  51. #endif
  52. int main() {
  53. write_compiler_info();
  54. #if defined(__cplusplus)
  55. std::cout << "__cplusplus: "
  56. << __cplusplus
  57. << std::endl;
  58. #endif
  59. std::cout << "BOOST_HASH_CXX17: "
  60. << BOOST_HASH_CXX17
  61. << std::endl;
  62. std::cout << "BOOST_HASH_HAS_STRING_VIEW: "
  63. << BOOST_HASH_HAS_STRING_VIEW
  64. << std::endl;
  65. std::cout << "BOOST_HASH_HAS_OPTIONAL: "
  66. << BOOST_HASH_HAS_OPTIONAL
  67. << std::endl;
  68. std::cout << "BOOST_HASH_HAS_VARIANT: "
  69. << BOOST_HASH_HAS_VARIANT
  70. << std::endl;
  71. #if defined(BOOST_NO_CXX11_HDR_TYPEINDEX)
  72. std::cout << "No <typeindex>" << std::endl;
  73. #else
  74. std::cout << "<typeindex>" << std::endl;
  75. #endif
  76. #if defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR)
  77. std::cout << "No <system_error>" << std::endl;
  78. #else
  79. std::cout << "<system_error>" << std::endl;
  80. #endif
  81. }