mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 14:19:59 -05:00
ec33e3600c
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 6af2e59217a7e10ed507da564a1445b60ac2a095 (master).
Upstream Shortlog
-----------------
Hans Johnson (17):
81d1e737 STYLE: Use modern path naming
28b8e6c2 STYLE: Convert CMake-language commands to lower case
6ce3d69a DOC: Update documentation for modern add_subdirectory.
8a7fe7ac STYLE: Remove redundant void argument lists
1c3e193d COMP: Use nullptr instead of 0 or NULL
2a4c1252 STYLE: Replace integer literals which are cast to bool.
0fe7214d STYLE: Make prototype match definition names
3b30d0ff STYLE: Make prototype match definition names
691d5612 PERF: readability container size empty
7be4043f STYLE: Prefer c++11 'using' to 'typedef'
acc916ed COMP: Prefer const pointer when value does not change
4c7f64eb COMP: Prefer const member functions
d07092a0 STYLE: Use default member initialization
6d20e7c9 STYLE: Prefer = default to explicitly trivial implementations
91429382 PERF: emplace_back method results in potentially more efficient code
cc8fc323 STYLE: Use auto for variable type matches the type of the initializer
6621b069 STYLE: Use range-based loops from C++11
Julien Schueller (1):
a1a261ac CMake: Fix psapi lib name on case-sensitive fs
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
|
|
#include "kwsysPrivate.h"
|
|
#include KWSYS_HEADER(hash_map.hxx)
|
|
#include KWSYS_HEADER(hash_set.hxx)
|
|
|
|
// Work-around CMake dependency scanning limitation. This must
|
|
// duplicate the above list of headers.
|
|
#if 0
|
|
# include "hash_map.hxx.in"
|
|
# include "hash_set.hxx.in"
|
|
#endif
|
|
|
|
#include <iostream>
|
|
|
|
#if defined(_MSC_VER)
|
|
# pragma warning(disable : 4786)
|
|
#endif
|
|
|
|
#if defined(__sgi) && !defined(__GNUC__)
|
|
# pragma set woff 1468 /* inline function cannot be explicitly instantiated \
|
|
*/
|
|
#endif
|
|
|
|
template class kwsys::hash_map<const char*, int>;
|
|
template class kwsys::hash_set<int>;
|
|
|
|
static bool test_hash_map()
|
|
{
|
|
using mtype = kwsys::hash_map<const char*, int>;
|
|
mtype m;
|
|
const char* keys[] = { "hello", "world" };
|
|
m[keys[0]] = 1;
|
|
m.insert(mtype::value_type(keys[1], 2));
|
|
int sum = 0;
|
|
for (auto& mi : m) {
|
|
std::cout << "Found entry [" << mi.first << "," << mi.second << "]"
|
|
<< std::endl;
|
|
sum += mi.second;
|
|
}
|
|
return sum == 3;
|
|
}
|
|
|
|
static bool test_hash_set()
|
|
{
|
|
using stype = kwsys::hash_set<int>;
|
|
stype s;
|
|
s.insert(1);
|
|
s.insert(2);
|
|
int sum = 0;
|
|
for (int si : s) {
|
|
std::cout << "Found entry [" << si << "]" << std::endl;
|
|
sum += si;
|
|
}
|
|
return sum == 3;
|
|
}
|
|
|
|
int testHashSTL(int, char* [])
|
|
{
|
|
bool result = true;
|
|
result = test_hash_map() && result;
|
|
result = test_hash_set() && result;
|
|
return result ? 0 : 1;
|
|
}
|