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