|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r52711 - trunk/boost/unordered/detail
From: daniel_james_at_[hidden]
Date: 2009-05-01 16:50:32
Author: danieljames
Date: 2009-05-01 16:50:32 EDT (Fri, 01 May 2009)
New Revision: 52711
URL: http://svn.boost.org/trac/boost/changeset/52711
Log:
Use a preprocessor sequence for the primes.
This feels like overkill but it seems to be the most reliable way to ensure
that the length is correct. I obviously can't be trusted to get it right, and
the template hack seems to prevent Boost.Range from working.
Text files modified:
trunk/boost/unordered/detail/hash_table.hpp | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
Modified: trunk/boost/unordered/detail/hash_table.hpp
==============================================================================
--- trunk/boost/unordered/detail/hash_table.hpp (original)
+++ trunk/boost/unordered/detail/hash_table.hpp 2009-05-01 16:50:32 EDT (Fri, 01 May 2009)
@@ -35,6 +35,8 @@
#include <boost/mpl/not.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/utility/swap.hpp>
+#include <boost/preprocessor/seq/size.hpp>
+#include <boost/preprocessor/seq/enum.hpp>
#include <boost/mpl/aux_/config/eti.hpp>
@@ -72,18 +74,25 @@
static std::ptrdiff_t const length;
};
+#define BOOST_UNORDERED_PRIMES \
+ (5ul)(11ul)(17ul)(29ul)(37ul)(53ul)(67ul)(79ul) \
+ (97ul)(131ul)(193ul)(257ul)(389ul)(521ul)(769ul) \
+ (1031ul)(1543ul)(2053ul)(3079ul)(6151ul)(12289ul)(24593ul) \
+ (49157ul)(98317ul)(196613ul)(393241ul)(786433ul) \
+ (1572869ul)(3145739ul)(6291469ul)(12582917ul)(25165843ul) \
+ (50331653ul)(100663319ul)(201326611ul)(402653189ul)(805306457ul) \
+ (1610612741ul)(3221225473ul)(4294967291ul)
+
template<typename T>
std::size_t const prime_list_template<T>::value[] = {
- 5ul, 11ul, 17ul, 29ul, 37ul, 53ul, 67ul, 79ul,
- 97ul, 131ul, 193ul, 257ul, 389ul, 521ul, 769ul,
- 1031ul, 1543ul, 2053ul, 3079ul, 6151ul, 12289ul, 24593ul,
- 49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
- 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul,
- 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
- 1610612741ul, 3221225473ul, 4294967291ul };
+ BOOST_PP_SEQ_ENUM(BOOST_UNORDERED_PRIMES)
+ };
template<typename T>
- std::ptrdiff_t const prime_list_template<T>::length = 40;
+ std::ptrdiff_t const prime_list_template<T>::length
+ = BOOST_PP_SEQ_SIZE(BOOST_UNORDERED_PRIMES);
+
+#undef BOOST_UNORDERED_PRIMES
typedef prime_list_template<std::size_t> prime_list;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk