google_hash 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. data/ChangeLog.txt +2 -0
  2. data/VERSION +1 -1
  3. data/ext/clean.bat +0 -0
  4. data/ext/clean.sh +4 -0
  5. data/ext/extconf.rb +4 -5
  6. data/ext/go.bat +0 -0
  7. data/ext/sparsehash-2.0.2/AUTHORS +2 -0
  8. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/COPYING +0 -0
  9. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/ChangeLog +60 -0
  10. data/ext/sparsehash-2.0.2/INSTALL +365 -0
  11. data/ext/sparsehash-2.0.2/Makefile +1336 -0
  12. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/Makefile.am +97 -40
  13. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/Makefile.in +538 -256
  14. data/ext/sparsehash-2.0.2/NEWS +188 -0
  15. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/README +4 -10
  16. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/README_windows.txt +3 -3
  17. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/TODO +0 -0
  18. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/aclocal.m4 +266 -166
  19. data/ext/sparsehash-2.0.2/allocator.patch +31 -0
  20. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/config.guess +235 -234
  21. data/ext/sparsehash-2.0.2/config.status +1238 -0
  22. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/config.sub +198 -64
  23. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/configure +1118 -1000
  24. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/configure.ac +4 -5
  25. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/depcomp +136 -36
  26. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/dense_hash_map.html +182 -67
  27. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/dense_hash_set.html +173 -74
  28. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/designstyle.css +0 -6
  29. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/implementation.html +0 -0
  30. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/index.html +4 -5
  31. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/performance.html +1 -1
  32. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/sparse_hash_map.html +190 -58
  33. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/sparse_hash_set.html +180 -65
  34. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/doc/sparsetable.html +1 -1
  35. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/experimental/Makefile +0 -0
  36. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/experimental/README +0 -0
  37. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/experimental/example.c +1 -0
  38. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/experimental/libchash.c +1 -0
  39. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/experimental/libchash.h +1 -0
  40. data/ext/sparsehash-2.0.2/install-sh +520 -0
  41. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/m4/acx_pthread.m4 +34 -0
  42. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/m4/google_namespace.m4 +0 -0
  43. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/m4/namespaces.m4 +0 -0
  44. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/m4/stl_hash.m4 +0 -0
  45. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/m4/stl_hash_fun.m4 +0 -0
  46. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/missing +60 -44
  47. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/deb.sh +0 -0
  48. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/deb/README +0 -0
  49. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/deb/changelog +42 -0
  50. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/deb/compat +0 -0
  51. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/deb/control +1 -1
  52. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/deb/copyright +5 -4
  53. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/deb/docs +0 -0
  54. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/deb/rules +0 -0
  55. data/ext/sparsehash-2.0.2/packages/deb/sparsehash.dirs +5 -0
  56. data/ext/sparsehash-2.0.2/packages/deb/sparsehash.install +6 -0
  57. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/rpm.sh +1 -1
  58. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/packages/rpm/rpm.spec +5 -3
  59. data/ext/{sparsehash-1.8.1/google-sparsehash.sln → sparsehash-2.0.2/sparsehash.sln} +0 -0
  60. data/ext/sparsehash-2.0.2/src/config.h +132 -0
  61. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/config.h.in +0 -3
  62. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/config.h.include +0 -1
  63. data/ext/sparsehash-2.0.2/src/google/dense_hash_map +34 -0
  64. data/ext/sparsehash-2.0.2/src/google/dense_hash_set +34 -0
  65. data/ext/sparsehash-2.0.2/src/google/sparse_hash_map +34 -0
  66. data/ext/sparsehash-2.0.2/src/google/sparse_hash_set +34 -0
  67. data/ext/sparsehash-2.0.2/src/google/sparsehash/densehashtable.h +34 -0
  68. data/ext/sparsehash-2.0.2/src/google/sparsehash/hashtable-common.h +34 -0
  69. data/ext/sparsehash-2.0.2/src/google/sparsehash/libc_allocator_with_realloc.h +34 -0
  70. data/ext/sparsehash-2.0.2/src/google/sparsehash/sparsehashtable.h +34 -0
  71. data/ext/sparsehash-2.0.2/src/google/sparsetable +34 -0
  72. data/ext/sparsehash-2.0.2/src/google/template_util.h +34 -0
  73. data/ext/sparsehash-2.0.2/src/google/type_traits.h +34 -0
  74. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/hash_test_interface.h +64 -37
  75. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/hashtable_test.cc +415 -141
  76. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/libc_allocator_with_realloc_test.cc +16 -23
  77. data/ext/sparsehash-2.0.2/src/simple_compat_test.cc +106 -0
  78. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/simple_test.cc +8 -5
  79. data/ext/{sparsehash-1.8.1/src/google → sparsehash-2.0.2/src/sparsehash}/dense_hash_map +80 -37
  80. data/ext/{sparsehash-1.8.1/src/google → sparsehash-2.0.2/src/sparsehash}/dense_hash_set +64 -34
  81. data/ext/{sparsehash-1.8.1/src/google/sparsehash → sparsehash-2.0.2/src/sparsehash/internal}/densehashtable.h +247 -173
  82. data/ext/sparsehash-2.0.2/src/sparsehash/internal/hashtable-common.h +381 -0
  83. data/ext/{sparsehash-1.8.1/src/google/sparsehash → sparsehash-2.0.2/src/sparsehash/internal}/libc_allocator_with_realloc.h +5 -7
  84. data/ext/{sparsehash-1.8.1/src/google/sparsehash → sparsehash-2.0.2/src/sparsehash/internal}/sparsehashtable.h +154 -93
  85. data/ext/{sparsehash-1.8.1/src/google → sparsehash-2.0.2/src/sparsehash}/sparse_hash_map +96 -36
  86. data/ext/{sparsehash-1.8.1/src/google → sparsehash-2.0.2/src/sparsehash}/sparse_hash_set +85 -32
  87. data/ext/{sparsehash-1.8.1/src/google → sparsehash-2.0.2/src/sparsehash}/sparsetable +520 -258
  88. data/ext/sparsehash-2.0.2/src/sparsehash/template_util.h +134 -0
  89. data/ext/{sparsehash-1.8.1/src/google → sparsehash-2.0.2/src/sparsehash}/type_traits.h +153 -35
  90. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/sparsetable_unittest.cc +108 -22
  91. data/ext/sparsehash-2.0.2/src/stamp-h1 +1 -0
  92. data/ext/sparsehash-2.0.2/src/template_util_unittest.cc +134 -0
  93. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/testutil.h +16 -1
  94. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/time_hash_map.cc +259 -94
  95. data/ext/sparsehash-2.0.2/src/type_traits_unittest.cc +636 -0
  96. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/windows/config.h +4 -4
  97. data/ext/sparsehash-2.0.2/src/windows/google/sparsehash/sparseconfig.h +49 -0
  98. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/windows/port.cc +1 -0
  99. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/src/windows/port.h +4 -13
  100. data/ext/sparsehash-2.0.2/src/windows/sparsehash/internal/sparseconfig.h +49 -0
  101. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/vsprojects/hashtable_test/hashtable_test.vcproj +11 -11
  102. data/ext/sparsehash-2.0.2/vsprojects/libc_allocator_with_realloc_test/libc_allocator_with_realloc_test.vcproj +161 -0
  103. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/vsprojects/simple_test/simple_test.vcproj +10 -10
  104. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/vsprojects/sparsetable_unittest/sparsetable_unittest.vcproj +4 -4
  105. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/vsprojects/time_hash_map/time_hash_map.vcproj +10 -10
  106. data/ext/{sparsehash-1.8.1 → sparsehash-2.0.2}/vsprojects/type_traits_unittest/type_traits_unittest.vcproj +3 -3
  107. data/ext/spec.bat +0 -0
  108. data/ext/template/google_hash.cpp.erb +6 -5
  109. metadata +106 -86
  110. data/ext/sparsehash-1.8.1/AUTHORS +0 -2
  111. data/ext/sparsehash-1.8.1/INSTALL +0 -236
  112. data/ext/sparsehash-1.8.1/NEWS +0 -71
  113. data/ext/sparsehash-1.8.1/compile +0 -99
  114. data/ext/sparsehash-1.8.1/install-sh +0 -323
  115. data/ext/sparsehash-1.8.1/m4/stl_namespace.m4 +0 -25
  116. data/ext/sparsehash-1.8.1/mkinstalldirs +0 -158
  117. data/ext/sparsehash-1.8.1/packages/deb/sparsehash.dirs +0 -2
  118. data/ext/sparsehash-1.8.1/packages/deb/sparsehash.install +0 -2
  119. data/ext/sparsehash-1.8.1/src/google/sparsehash/hashtable-common.h +0 -178
  120. data/ext/sparsehash-1.8.1/src/type_traits_unittest.cc +0 -502
  121. data/ext/sparsehash-1.8.1/src/windows/google/sparsehash/sparseconfig.h +0 -32
@@ -1,25 +0,0 @@
1
- # We check what namespace stl code like vector expects to be executed in
2
-
3
- AC_DEFUN([AC_CXX_STL_NAMESPACE],
4
- [AC_CACHE_CHECK(
5
- what namespace STL code is in,
6
- ac_cv_cxx_stl_namespace,
7
- [AC_REQUIRE([AC_CXX_NAMESPACES])
8
- AC_LANG_SAVE
9
- AC_LANG_CPLUSPLUS
10
- AC_TRY_COMPILE([#include <vector>],
11
- [vector<int> t; return 0;],
12
- ac_cv_cxx_stl_namespace=none)
13
- AC_TRY_COMPILE([#include <vector>],
14
- [std::vector<int> t; return 0;],
15
- ac_cv_cxx_stl_namespace=std)
16
- AC_LANG_RESTORE])
17
- if test "$ac_cv_cxx_stl_namespace" = none; then
18
- AC_DEFINE(STL_NAMESPACE,,
19
- [the namespace where STL code like vector<> is defined])
20
- fi
21
- if test "$ac_cv_cxx_stl_namespace" = std; then
22
- AC_DEFINE(STL_NAMESPACE,std,
23
- [the namespace where STL code like vector<> is defined])
24
- fi
25
- ])
@@ -1,158 +0,0 @@
1
- #! /bin/sh
2
- # mkinstalldirs --- make directory hierarchy
3
-
4
- scriptversion=2005-06-29.22
5
-
6
- # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
7
- # Created: 1993-05-16
8
- # Public domain.
9
- #
10
- # This file is maintained in Automake, please report
11
- # bugs to <bug-automake@gnu.org> or send patches to
12
- # <automake-patches@gnu.org>.
13
-
14
- errstatus=0
15
- dirmode=
16
-
17
- usage="\
18
- Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
19
-
20
- Create each directory DIR (with mode MODE, if specified), including all
21
- leading file name components.
22
-
23
- Report bugs to <bug-automake@gnu.org>."
24
-
25
- # process command line arguments
26
- while test $# -gt 0 ; do
27
- case $1 in
28
- -h | --help | --h*) # -h for help
29
- echo "$usage"
30
- exit $?
31
- ;;
32
- -m) # -m PERM arg
33
- shift
34
- test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
35
- dirmode=$1
36
- shift
37
- ;;
38
- --version)
39
- echo "$0 $scriptversion"
40
- exit $?
41
- ;;
42
- --) # stop option processing
43
- shift
44
- break
45
- ;;
46
- -*) # unknown option
47
- echo "$usage" 1>&2
48
- exit 1
49
- ;;
50
- *) # first non-opt arg
51
- break
52
- ;;
53
- esac
54
- done
55
-
56
- for file
57
- do
58
- if test -d "$file"; then
59
- shift
60
- else
61
- break
62
- fi
63
- done
64
-
65
- case $# in
66
- 0) exit 0 ;;
67
- esac
68
-
69
- # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
70
- # mkdir -p a/c at the same time, both will detect that a is missing,
71
- # one will create a, then the other will try to create a and die with
72
- # a "File exists" error. This is a problem when calling mkinstalldirs
73
- # from a parallel make. We use --version in the probe to restrict
74
- # ourselves to GNU mkdir, which is thread-safe.
75
- case $dirmode in
76
- '')
77
- if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
78
- echo "mkdir -p -- $*"
79
- exec mkdir -p -- "$@"
80
- else
81
- # On NextStep and OpenStep, the `mkdir' command does not
82
- # recognize any option. It will interpret all options as
83
- # directories to create, and then abort because `.' already
84
- # exists.
85
- test -d ./-p && rmdir ./-p
86
- test -d ./--version && rmdir ./--version
87
- fi
88
- ;;
89
- *)
90
- if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
91
- test ! -d ./--version; then
92
- echo "mkdir -m $dirmode -p -- $*"
93
- exec mkdir -m "$dirmode" -p -- "$@"
94
- else
95
- # Clean up after NextStep and OpenStep mkdir.
96
- for d in ./-m ./-p ./--version "./$dirmode";
97
- do
98
- test -d $d && rmdir $d
99
- done
100
- fi
101
- ;;
102
- esac
103
-
104
- for file
105
- do
106
- case $file in
107
- /*) pathcomp=/ ;;
108
- *) pathcomp= ;;
109
- esac
110
- oIFS=$IFS
111
- IFS=/
112
- set fnord $file
113
- shift
114
- IFS=$oIFS
115
-
116
- for d
117
- do
118
- test "x$d" = x && continue
119
-
120
- pathcomp=$pathcomp$d
121
- case $pathcomp in
122
- -*) pathcomp=./$pathcomp ;;
123
- esac
124
-
125
- if test ! -d "$pathcomp"; then
126
- echo "mkdir $pathcomp"
127
-
128
- mkdir "$pathcomp" || lasterr=$?
129
-
130
- if test ! -d "$pathcomp"; then
131
- errstatus=$lasterr
132
- else
133
- if test ! -z "$dirmode"; then
134
- echo "chmod $dirmode $pathcomp"
135
- lasterr=
136
- chmod "$dirmode" "$pathcomp" || lasterr=$?
137
-
138
- if test ! -z "$lasterr"; then
139
- errstatus=$lasterr
140
- fi
141
- fi
142
- fi
143
- fi
144
-
145
- pathcomp=$pathcomp/
146
- done
147
- done
148
-
149
- exit $errstatus
150
-
151
- # Local Variables:
152
- # mode: shell-script
153
- # sh-indentation: 2
154
- # eval: (add-hook 'write-file-hooks 'time-stamp)
155
- # time-stamp-start: "scriptversion="
156
- # time-stamp-format: "%:y-%02m-%02d.%02H"
157
- # time-stamp-end: "$"
158
- # End:
@@ -1,2 +0,0 @@
1
- usr/include
2
- usr/include/google
@@ -1,2 +0,0 @@
1
- usr/include/google/*
2
- debian/tmp/usr/include/google/*
@@ -1,178 +0,0 @@
1
- // Copyright (c) 2005, Google Inc.
2
- // All rights reserved.
3
- //
4
- // Redistribution and use in source and binary forms, with or without
5
- // modification, are permitted provided that the following conditions are
6
- // met:
7
- //
8
- // * Redistributions of source code must retain the above copyright
9
- // notice, this list of conditions and the following disclaimer.
10
- // * Redistributions in binary form must reproduce the above
11
- // copyright notice, this list of conditions and the following disclaimer
12
- // in the documentation and/or other materials provided with the
13
- // distribution.
14
- // * Neither the name of Google Inc. nor the names of its
15
- // contributors may be used to endorse or promote products derived from
16
- // this software without specific prior written permission.
17
- //
18
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
-
30
- // ---
31
- // Author: Giao Nguyen
32
-
33
- #ifndef UTIL_GTL_HASHTABLE_COMMON_H_
34
- #define UTIL_GTL_HASHTABLE_COMMON_H_
35
-
36
- #include <assert.h>
37
-
38
- // Settings contains parameters for growing and shrinking the table.
39
- // It also packages zero-size functor (ie. hasher).
40
-
41
- template<typename Key, typename HashFunc,
42
- typename SizeType, int HT_MIN_BUCKETS>
43
- class sh_hashtable_settings : public HashFunc {
44
- public:
45
- typedef Key key_type;
46
- typedef HashFunc hasher;
47
- typedef SizeType size_type;
48
-
49
- public:
50
- sh_hashtable_settings(const hasher& hf,
51
- const float ht_occupancy_flt,
52
- const float ht_empty_flt)
53
- : hasher(hf),
54
- enlarge_threshold_(0),
55
- shrink_threshold_(0),
56
- consider_shrink_(false),
57
- use_empty_(false),
58
- use_deleted_(false),
59
- num_ht_copies_(0) {
60
- set_enlarge_factor(ht_occupancy_flt);
61
- set_shrink_factor(ht_empty_flt);
62
- }
63
-
64
- size_type hash(const key_type& v) const {
65
- return hasher::operator()(v);
66
- }
67
-
68
- float enlarge_factor() const {
69
- return enlarge_factor_;
70
- }
71
- void set_enlarge_factor(float f) {
72
- enlarge_factor_ = f;
73
- }
74
- float shrink_factor() const {
75
- return shrink_factor_;
76
- }
77
- void set_shrink_factor(float f) {
78
- shrink_factor_ = f;
79
- }
80
-
81
- size_type enlarge_threshold() const {
82
- return enlarge_threshold_;
83
- }
84
- void set_enlarge_threshold(size_type t) {
85
- enlarge_threshold_ = t;
86
- }
87
- size_type shrink_threshold() const {
88
- return shrink_threshold_;
89
- }
90
- void set_shrink_threshold(size_type t) {
91
- shrink_threshold_ = t;
92
- }
93
-
94
- size_type enlarge_size(size_type x) const {
95
- return static_cast<size_type>(x * enlarge_factor_);
96
- }
97
- size_type shrink_size(size_type x) const {
98
- return static_cast<size_type>(x * shrink_factor_);
99
- }
100
-
101
- bool consider_shrink() const {
102
- return consider_shrink_;
103
- }
104
- void set_consider_shrink(bool t) {
105
- consider_shrink_ = t;
106
- }
107
-
108
- bool use_empty() const {
109
- return use_empty_;
110
- }
111
- void set_use_empty(bool t) {
112
- use_empty_ = t;
113
- }
114
-
115
- bool use_deleted() const {
116
- return use_deleted_;
117
- }
118
- void set_use_deleted(bool t) {
119
- use_deleted_ = t;
120
- }
121
-
122
- size_type num_ht_copies() const {
123
- return static_cast<size_type>(num_ht_copies_);
124
- }
125
- void inc_num_ht_copies() {
126
- ++num_ht_copies_;
127
- }
128
-
129
- // Reset the enlarge and shrink thresholds
130
- void reset_thresholds(int num_buckets) {
131
- set_enlarge_threshold(enlarge_size(num_buckets));
132
- set_shrink_threshold(shrink_size(num_buckets));
133
- // whatever caused us to reset already considered
134
- set_consider_shrink(false);
135
- }
136
-
137
- // Caller is resposible for calling reset_threshold right after
138
- // set_resizing_parameters.
139
- void set_resizing_parameters(float shrink, float grow) {
140
- assert(shrink >= 0.0);
141
- assert(grow <= 1.0);
142
- if (shrink > grow/2.0f)
143
- shrink = grow / 2.0f; // otherwise we thrash hashtable size
144
- set_shrink_factor(shrink);
145
- set_enlarge_factor(grow);
146
- }
147
-
148
- // This is the smallest size a hashtable can be without being too crowded
149
- // If you like, you can give a min #buckets as well as a min #elts
150
- size_type min_buckets(size_type num_elts, size_type min_buckets_wanted) {
151
- float enlarge = enlarge_factor();
152
- size_type sz = HT_MIN_BUCKETS; // min buckets allowed
153
- while ( sz < min_buckets_wanted ||
154
- num_elts >= static_cast<size_type>(sz * enlarge) ) {
155
- // This just prevents overflowing size_type, since sz can exceed
156
- // max_size() here.
157
- if (static_cast<size_type>(sz * 2) < sz) {
158
- throw std::length_error("resize overflow"); // protect against overflow
159
- }
160
- sz *= 2;
161
- }
162
- return sz;
163
- }
164
-
165
- private:
166
- size_type enlarge_threshold_; // table.size() * enlarge_factor
167
- size_type shrink_threshold_; // table.size() * shrink_factor
168
- float enlarge_factor_; // how full before resize
169
- float shrink_factor_; // how empty before resize
170
- // consider_shrink=true if we should try to shrink before next insert
171
- bool consider_shrink_;
172
- bool use_empty_; // used only by densehashtable, not sparsehashtable
173
- bool use_deleted_; // false until delkey has been set
174
- // num_ht_copies is a counter incremented every Copy/Move
175
- unsigned int num_ht_copies_;
176
- };
177
-
178
- #endif // UTIL_GTL_HASHTABLE_COMMON_H_
@@ -1,502 +0,0 @@
1
- // Copyright (c) 2006, Google Inc.
2
- // All rights reserved.
3
- //
4
- // Redistribution and use in source and binary forms, with or without
5
- // modification, are permitted provided that the following conditions are
6
- // met:
7
- //
8
- // * Redistributions of source code must retain the above copyright
9
- // notice, this list of conditions and the following disclaimer.
10
- // * Redistributions in binary form must reproduce the above
11
- // copyright notice, this list of conditions and the following disclaimer
12
- // in the documentation and/or other materials provided with the
13
- // distribution.
14
- // * Neither the name of Google Inc. nor the names of its
15
- // contributors may be used to endorse or promote products derived from
16
- // this software without specific prior written permission.
17
- //
18
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
-
30
- // ----
31
- // Author: Matt Austern
32
-
33
- #include "config.h"
34
- #include <stdlib.h> // for exit()
35
- #include <stdio.h>
36
- #include <string>
37
- #include <vector>
38
- #include <google/type_traits.h>
39
-
40
- using STL_NAMESPACE::string;
41
- using STL_NAMESPACE::vector;
42
- using STL_NAMESPACE::pair;
43
-
44
- #define ASSERT_TRUE(cond) do { \
45
- if ( !(cond) ) { \
46
- printf("Test failed: " #cond "\n"); \
47
- exit(1); \
48
- } \
49
- } while (0)
50
-
51
- #define ASSERT_FALSE(cond) ASSERT_TRUE(!(cond))
52
-
53
-
54
- // A user-defined POD type.
55
- struct A {
56
- int n_;
57
- };
58
-
59
- // A user-defined non-POD type with a trivial copy constructor.
60
- class B {
61
- public:
62
- explicit B(int n) : n_(n) { }
63
- private:
64
- int n_;
65
- };
66
-
67
- // Another user-defined non-POD type with a trivial copy constructor.
68
- // We will explicitly declare C to have a trivial copy constructor
69
- // by specializing has_trivial_copy.
70
- class C {
71
- public:
72
- explicit C(int n) : n_(n) { }
73
- private:
74
- int n_;
75
- };
76
-
77
- _START_GOOGLE_NAMESPACE_
78
- template<> struct has_trivial_copy<C> : true_type { };
79
- _END_GOOGLE_NAMESPACE_
80
-
81
- // Another user-defined non-POD type with a trivial assignment operator.
82
- // We will explicitly declare C to have a trivial assignment operator
83
- // by specializing has_trivial_assign.
84
- class D {
85
- public:
86
- explicit D(int n) : n_(n) { }
87
- private:
88
- int n_;
89
- };
90
-
91
- _START_GOOGLE_NAMESPACE_
92
- template<> struct has_trivial_assign<D> : true_type { };
93
- _END_GOOGLE_NAMESPACE_
94
-
95
- // Another user-defined non-POD type with a trivial constructor.
96
- // We will explicitly declare E to have a trivial constructor
97
- // by specializing has_trivial_constructor.
98
- class E {
99
- public:
100
- int n_;
101
- };
102
-
103
- _START_GOOGLE_NAMESPACE_
104
- template<> struct has_trivial_constructor<E> : true_type { };
105
- _END_GOOGLE_NAMESPACE_
106
-
107
- // Another user-defined non-POD type with a trivial destructor.
108
- // We will explicitly declare E to have a trivial destructor
109
- // by specializing has_trivial_destructor.
110
- class F {
111
- public:
112
- explicit F(int n) : n_(n) { }
113
- private:
114
- int n_;
115
- };
116
-
117
- _START_GOOGLE_NAMESPACE_
118
- template<> struct has_trivial_destructor<F> : true_type { };
119
- _END_GOOGLE_NAMESPACE_
120
-
121
-
122
- namespace {
123
-
124
- // type_equals_ is a template type comparator, similar to Loki IsSameType.
125
- // type_equals_<A, B>::value is true iff "A" is the same type as "B".
126
- template<typename A, typename B>
127
- struct type_equals_ : public GOOGLE_NAMESPACE::false_type {
128
- };
129
-
130
- template<typename A>
131
- struct type_equals_<A, A> : public GOOGLE_NAMESPACE::true_type {
132
- };
133
-
134
- // A base class and a derived class that inherits from it, used for
135
- // testing conversion type traits.
136
- class Base {
137
- public:
138
- virtual ~Base() { }
139
- };
140
-
141
- class Derived : public Base {
142
- };
143
-
144
- // This assertion produces errors like "error: invalid use of
145
- // undefined type 'struct <unnamed>::AssertTypesEq<const int, int>'"
146
- // when it fails.
147
- template<typename T, typename U> struct AssertTypesEq;
148
- template<typename T> struct AssertTypesEq<T, T> {};
149
- #define COMPILE_ASSERT_TYPES_EQ(T, U) AssertTypesEq<T, U>()
150
-
151
- class TypeTraitsTest {
152
- public:
153
- static void TestIsInteger() {
154
- // Verify that is_integral is true for all integer types.
155
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<bool>::value);
156
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<char>::value);
157
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<unsigned char>::value);
158
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<signed char>::value);
159
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<wchar_t>::value);
160
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<int>::value);
161
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<unsigned int>::value);
162
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<short>::value);
163
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<unsigned short>::value);
164
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<long>::value);
165
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_integral<unsigned long>::value);
166
-
167
- // Verify that is_integral is false for a few non-integer types.
168
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_integral<void>::value);
169
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_integral<float>::value);
170
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_integral<string>::value);
171
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_integral<int*>::value);
172
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_integral<A>::value);
173
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_integral<pair<int, int> >::value));
174
- }
175
-
176
- static void TestIsFloating() {
177
- // Verify that is_floating_point is true for all floating-point types.
178
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_floating_point<float>::value);
179
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_floating_point<double>::value);
180
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_floating_point<long double>::value);
181
-
182
- // Verify that is_floating_point is false for a few non-float types.
183
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_floating_point<void>::value);
184
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_floating_point<long>::value);
185
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_floating_point<string>::value);
186
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_floating_point<float*>::value);
187
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_floating_point<A>::value);
188
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_floating_point<pair<int, int> >::value));
189
- }
190
-
191
- static void TestIsReference() {
192
- // Verifies that is_reference is true for all reference types.
193
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_reference<float&>::value);
194
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_reference<const int&>::value);
195
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_reference<const int*&>::value);
196
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_reference<int (&)(bool)>::value);
197
-
198
- // Verifies that is_reference is false for all non-reference types.
199
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_reference<float>::value);
200
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_reference<const int*>::value);
201
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_reference<int()>::value);
202
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_reference<void(*)(const char&)>::value);
203
- }
204
-
205
- static void TestIsPod() {
206
- // Verify that arithmetic types and pointers are marked as PODs.
207
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<bool>::value);
208
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<char>::value);
209
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<unsigned char>::value);
210
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<signed char>::value);
211
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<wchar_t>::value);
212
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<int>::value);
213
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<unsigned int>::value);
214
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<short>::value);
215
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<unsigned short>::value);
216
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<long>::value);
217
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<unsigned long>::value);
218
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<float>::value);
219
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<double>::value);
220
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<long double>::value);
221
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<string*>::value);
222
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<A*>::value);
223
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<const B*>::value);
224
- ASSERT_TRUE(GOOGLE_NAMESPACE::is_pod<C**>::value);
225
-
226
- // Verify that some non-POD types are not marked as PODs.
227
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_pod<void>::value);
228
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_pod<string>::value);
229
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_pod<pair<int, int> >::value));
230
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_pod<A>::value);
231
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_pod<B>::value);
232
- ASSERT_FALSE(GOOGLE_NAMESPACE::is_pod<C>::value);
233
- }
234
-
235
- static void TestHasTrivialCopy() {
236
- // Verify that arithmetic types and pointers have trivial copy
237
- // constructors.
238
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<bool>::value);
239
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<char>::value);
240
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<unsigned char>::value);
241
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<signed char>::value);
242
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<wchar_t>::value);
243
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<int>::value);
244
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<unsigned int>::value);
245
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<short>::value);
246
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<unsigned short>::value);
247
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<long>::value);
248
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<unsigned long>::value);
249
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<float>::value);
250
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<double>::value);
251
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<long double>::value);
252
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<string*>::value);
253
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<A*>::value);
254
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<const B*>::value);
255
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<C**>::value);
256
-
257
- // Verify that pairs and arrays of such types have trivial
258
- // copy constructors.
259
- typedef int int10[10];
260
- ASSERT_TRUE((GOOGLE_NAMESPACE::has_trivial_copy<pair<int, char*> >::value));
261
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<int10>::value);
262
-
263
- // Verify that types without trivial copy constructors are
264
- // correctly marked as such.
265
- ASSERT_FALSE(GOOGLE_NAMESPACE::has_trivial_copy<string>::value);
266
- ASSERT_FALSE(GOOGLE_NAMESPACE::has_trivial_copy<vector<int> >::value);
267
-
268
- // Verify that pairs of types without trivial copy constructors
269
- // are not marked as trivial.
270
- ASSERT_FALSE((GOOGLE_NAMESPACE::has_trivial_copy<pair<int, string> >::value));
271
- ASSERT_FALSE((GOOGLE_NAMESPACE::has_trivial_copy<pair<string, int> >::value));
272
-
273
- // Verify that C, which we have declared to have a trivial
274
- // copy constructor, is correctly marked as such.
275
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_copy<C>::value);
276
- }
277
-
278
- static void TestHasTrivialConstructor() {
279
- // Verify that arithmetic types and pointers have trivial constructors.
280
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<bool>::value);
281
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<char>::value);
282
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<unsigned char>::value);
283
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<signed char>::value);
284
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<wchar_t>::value);
285
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<int>::value);
286
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<unsigned int>::value);
287
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<short>::value);
288
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<unsigned short>::value);
289
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<long>::value);
290
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<unsigned long>::value);
291
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<float>::value);
292
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<double>::value);
293
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<long double>::value);
294
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<string*>::value);
295
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<A*>::value);
296
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<const B*>::value);
297
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<C**>::value);
298
-
299
- // Verify that pairs and arrays of such types have trivial
300
- // constructors.
301
- typedef int int10[10];
302
- ASSERT_TRUE((GOOGLE_NAMESPACE::has_trivial_constructor<pair<int, char*> >::value));
303
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<int10>::value);
304
-
305
- // Verify that pairs of types without trivial constructors
306
- // are not marked as trivial.
307
- ASSERT_FALSE((GOOGLE_NAMESPACE::has_trivial_constructor<pair<int, string> >::value));
308
- ASSERT_FALSE((GOOGLE_NAMESPACE::has_trivial_constructor<pair<string, int> >::value));
309
-
310
- // Verify that types without trivial constructors are
311
- // correctly marked as such.
312
- ASSERT_FALSE(GOOGLE_NAMESPACE::has_trivial_constructor<string>::value);
313
- ASSERT_FALSE(GOOGLE_NAMESPACE::has_trivial_constructor<vector<int> >::value);
314
-
315
- // Verify that E, which we have declared to have a trivial
316
- // constructor, is correctly marked as such.
317
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_constructor<E>::value);
318
- }
319
-
320
- static void TestHasTrivialAssign() {
321
- // Verify that arithmetic types and pointers have trivial assignment
322
- // operators.
323
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<bool>::value);
324
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<char>::value);
325
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<unsigned char>::value);
326
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<signed char>::value);
327
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<wchar_t>::value);
328
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<int>::value);
329
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<unsigned int>::value);
330
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<short>::value);
331
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<unsigned short>::value);
332
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<long>::value);
333
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<unsigned long>::value);
334
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<float>::value);
335
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<double>::value);
336
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<long double>::value);
337
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<string*>::value);
338
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<A*>::value);
339
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<const B*>::value);
340
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<C**>::value);
341
-
342
- // Verify that pairs and arrays of such types have trivial
343
- // assignment operators.
344
- typedef int int10[10];
345
- ASSERT_TRUE((GOOGLE_NAMESPACE::has_trivial_assign<pair<int, char*> >::value));
346
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<int10>::value);
347
-
348
- // Verify that pairs of types without trivial assignment operators
349
- // are not marked as trivial.
350
- ASSERT_FALSE((GOOGLE_NAMESPACE::has_trivial_assign<pair<int, string> >::value));
351
- ASSERT_FALSE((GOOGLE_NAMESPACE::has_trivial_assign<pair<string, int> >::value));
352
-
353
- // Verify that types without trivial assignment operators are
354
- // correctly marked as such.
355
- ASSERT_FALSE(GOOGLE_NAMESPACE::has_trivial_assign<string>::value);
356
- ASSERT_FALSE(GOOGLE_NAMESPACE::has_trivial_assign<vector<int> >::value);
357
-
358
- // Verify that D, which we have declared to have a trivial
359
- // assignment operator, is correctly marked as such.
360
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_assign<D>::value);
361
- }
362
-
363
- static void TestHasTrivialDestructor() {
364
- // Verify that arithmetic types and pointers have trivial destructors.
365
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<bool>::value);
366
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<char>::value);
367
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<unsigned char>::value);
368
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<signed char>::value);
369
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<wchar_t>::value);
370
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<int>::value);
371
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<unsigned int>::value);
372
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<short>::value);
373
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<unsigned short>::value);
374
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<long>::value);
375
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<unsigned long>::value);
376
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<float>::value);
377
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<double>::value);
378
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<long double>::value);
379
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<string*>::value);
380
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<A*>::value);
381
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<const B*>::value);
382
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<C**>::value);
383
-
384
- // Verify that pairs and arrays of such types have trivial
385
- // destructors.
386
- typedef int int10[10];
387
- ASSERT_TRUE((GOOGLE_NAMESPACE::has_trivial_destructor<pair<int, char*> >::value));
388
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<int10>::value);
389
-
390
- // Verify that pairs of types without trivial destructors
391
- // are not marked as trivial.
392
- ASSERT_FALSE((GOOGLE_NAMESPACE::has_trivial_destructor<pair<int, string> >::value));
393
- ASSERT_FALSE((GOOGLE_NAMESPACE::has_trivial_destructor<pair<string, int> >::value));
394
-
395
- // Verify that types without trivial destructors are
396
- // correctly marked as such.
397
- ASSERT_FALSE(GOOGLE_NAMESPACE::has_trivial_destructor<string>::value);
398
- ASSERT_FALSE(GOOGLE_NAMESPACE::has_trivial_destructor<vector<int> >::value);
399
-
400
- // Verify that F, which we have declared to have a trivial
401
- // destructor, is correctly marked as such.
402
- ASSERT_TRUE(GOOGLE_NAMESPACE::has_trivial_destructor<F>::value);
403
- }
404
-
405
- // Tests remove_pointer.
406
- static void TestRemovePointer() {
407
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_pointer<int>::type);
408
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_pointer<int*>::type);
409
- COMPILE_ASSERT_TYPES_EQ(const int, GOOGLE_NAMESPACE::remove_pointer<const int*>::type);
410
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_pointer<int* const>::type);
411
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_pointer<int* volatile>::type);
412
- }
413
-
414
- static void TestRemoveConst() {
415
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_const<int>::type);
416
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_const<const int>::type);
417
- COMPILE_ASSERT_TYPES_EQ(int *, GOOGLE_NAMESPACE::remove_const<int * const>::type);
418
- // TR1 examples.
419
- COMPILE_ASSERT_TYPES_EQ(const int *, GOOGLE_NAMESPACE::remove_const<const int *>::type);
420
- COMPILE_ASSERT_TYPES_EQ(volatile int,
421
- GOOGLE_NAMESPACE::remove_const<const volatile int>::type);
422
- }
423
-
424
- static void TestRemoveVolatile() {
425
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_volatile<int>::type);
426
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_volatile<volatile int>::type);
427
- COMPILE_ASSERT_TYPES_EQ(int *, GOOGLE_NAMESPACE::remove_volatile<int * volatile>::type);
428
- // TR1 examples.
429
- COMPILE_ASSERT_TYPES_EQ(volatile int *,
430
- GOOGLE_NAMESPACE::remove_volatile<volatile int *>::type);
431
- COMPILE_ASSERT_TYPES_EQ(const int,
432
- GOOGLE_NAMESPACE::remove_volatile<const volatile int>::type);
433
- }
434
-
435
- static void TestRemoveReference() {
436
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_reference<int>::type);
437
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_reference<int&>::type);
438
- COMPILE_ASSERT_TYPES_EQ(const int, GOOGLE_NAMESPACE::remove_reference<const int&>::type);
439
- COMPILE_ASSERT_TYPES_EQ(int*, GOOGLE_NAMESPACE::remove_reference<int * &>::type);
440
- }
441
-
442
- static void TestRemoveCV() {
443
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_cv<int>::type);
444
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_cv<volatile int>::type);
445
- COMPILE_ASSERT_TYPES_EQ(int, GOOGLE_NAMESPACE::remove_cv<const int>::type);
446
- COMPILE_ASSERT_TYPES_EQ(int *, GOOGLE_NAMESPACE::remove_cv<int * const volatile>::type);
447
- // TR1 examples.
448
- COMPILE_ASSERT_TYPES_EQ(const volatile int *,
449
- GOOGLE_NAMESPACE::remove_cv<const volatile int *>::type);
450
- COMPILE_ASSERT_TYPES_EQ(int,
451
- GOOGLE_NAMESPACE::remove_cv<const volatile int>::type);
452
- }
453
-
454
- static void TestIsSame() {
455
- typedef int int32;
456
- typedef long int64;
457
-
458
- ASSERT_TRUE((GOOGLE_NAMESPACE::is_same<int32, int32>::value));
459
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<int32, int64>::value));
460
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<int64, int32>::value));
461
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<int, const int>::value));
462
-
463
- ASSERT_TRUE((GOOGLE_NAMESPACE::is_same<void, void>::value));
464
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<void, int>::value));
465
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<int, void>::value));
466
-
467
- ASSERT_TRUE((GOOGLE_NAMESPACE::is_same<int*, int*>::value));
468
- ASSERT_TRUE((GOOGLE_NAMESPACE::is_same<void*, void*>::value));
469
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<int*, void*>::value));
470
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<void*, int*>::value));
471
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<void*, const void*>::value));
472
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<void*, void* const>::value));
473
-
474
- ASSERT_TRUE((GOOGLE_NAMESPACE::is_same<Base*, Base*>::value));
475
- ASSERT_TRUE((GOOGLE_NAMESPACE::is_same<Derived*, Derived*>::value));
476
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<Base*, Derived*>::value));
477
- ASSERT_FALSE((GOOGLE_NAMESPACE::is_same<Derived*, Base*>::value));
478
- }
479
-
480
- }; // end class TypeTraitsTest
481
-
482
- } // end anonymous namespace
483
-
484
-
485
- int main(int /*argc*/, char ** /*argv*/) {
486
- TypeTraitsTest::TestIsInteger();
487
- TypeTraitsTest::TestIsFloating();
488
- TypeTraitsTest::TestIsReference();
489
- TypeTraitsTest::TestIsPod();
490
- TypeTraitsTest::TestHasTrivialCopy();
491
- TypeTraitsTest::TestHasTrivialConstructor();
492
- TypeTraitsTest::TestHasTrivialAssign();
493
- TypeTraitsTest::TestHasTrivialDestructor();
494
- TypeTraitsTest::TestRemovePointer();
495
- TypeTraitsTest::TestRemoveConst();
496
- TypeTraitsTest::TestRemoveVolatile();
497
- TypeTraitsTest::TestRemoveReference();
498
- TypeTraitsTest::TestRemoveCV();
499
- TypeTraitsTest::TestIsSame();
500
- printf("PASS\n");
501
- return 0;
502
- }