Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-05-21 16:43:41


Author: danieljames
Date: 2008-05-21 16:43:40 EDT (Wed, 21 May 2008)
New Revision: 45620
URL: http://svn.boost.org/trac/boost/changeset/45620

Log:
Some compilers don't like the use of sizeof with a static template member
array, so I'm hardcoding the prime number list length. Pity.

Text files modified:
   trunk/boost/unordered/detail/hash_table.hpp | 8 ++++++--
   1 files changed, 6 insertions(+), 2 deletions(-)

Modified: trunk/boost/unordered/detail/hash_table.hpp
==============================================================================
--- trunk/boost/unordered/detail/hash_table.hpp (original)
+++ trunk/boost/unordered/detail/hash_table.hpp 2008-05-21 16:43:40 EDT (Wed, 21 May 2008)
@@ -81,6 +81,7 @@
         template<typename T> struct prime_list_template
         {
             static std::size_t const value[];
+ static std::ptrdiff_t const length;
         };
 
         template<typename T>
@@ -92,13 +93,16 @@
             50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
             1610612741ul, 3221225473ul, 4294967291ul };
 
+ template<typename T>
+ std::ptrdiff_t const prime_list_template<T>::length = 28;
+
         typedef prime_list_template<std::size_t> prime_list;
 
         // no throw
         inline std::size_t next_prime(std::size_t n) {
             std::size_t const* const prime_list_begin = prime_list::value;
             std::size_t const* const prime_list_end = prime_list_begin +
- sizeof(prime_list::value) / sizeof(*prime_list::value);
+ prime_list::length;
             std::size_t const* bound =
                 std::lower_bound(prime_list_begin, prime_list_end, n);
             if(bound == prime_list_end)
@@ -110,7 +114,7 @@
         inline std::size_t prev_prime(std::size_t n) {
             std::size_t const* const prime_list_begin = prime_list::value;
             std::size_t const* const prime_list_end = prime_list_begin +
- sizeof(prime_list::value) / sizeof(*prime_list::value);
+ prime_list::length;
             std::size_t const* bound =
                 std::upper_bound(prime_list_begin,prime_list_end, n);
             if(bound != prime_list_begin)


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