os/ossrv/ossrv_pub/boost_apis/boost/graph/detail/bitset.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
//=======================================================================
sl@0
     2
// Copyright 2001 Jeremy G. Siek
sl@0
     3
// Authors: Jeremy G. Siek
sl@0
     4
//
sl@0
     5
// Distributed under the Boost Software License, Version 1.0. (See
sl@0
     6
// accompanying file LICENSE_1_0.txt or copy at
sl@0
     7
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
     8
//=======================================================================
sl@0
     9
sl@0
    10
/*
sl@0
    11
 * Copyright (c) 1998
sl@0
    12
 * Silicon Graphics Computer Systems, Inc.
sl@0
    13
 *
sl@0
    14
 * Permission to use, copy, modify, distribute and sell this software
sl@0
    15
 * and its documentation for any purpose is hereby granted without fee,
sl@0
    16
 * provided that the above copyright notice appear in all copies and
sl@0
    17
 * that both that copyright notice and this permission notice appear
sl@0
    18
 * in supporting documentation.  Silicon Graphics makes no
sl@0
    19
 * representations about the suitability of this software for any
sl@0
    20
 * purpose.  It is provided "as is" without express or implied warranty.
sl@0
    21
 */
sl@0
    22
sl@0
    23
#include <boost/config.hpp>
sl@0
    24
#include <memory>
sl@0
    25
#include <stdexcept>
sl@0
    26
#include <algorithm>
sl@0
    27
#include <string>
sl@0
    28
#include <boost/config.hpp>
sl@0
    29
#include <boost/pending/ct_if.hpp>
sl@0
    30
#include <boost/graph/detail/bitset_adaptor.hpp>
sl@0
    31
sl@0
    32
// This provides versions of std::bitset with both static and dynamic size.
sl@0
    33
sl@0
    34
// UNDER CONSTRUCTION
sl@0
    35
sl@0
    36
sl@0
    37
// replace this later
sl@0
    38
#include <cassert>
sl@0
    39
#define BOOST_ASSERT_THROW(expr, except) assert(expr)
sl@0
    40
sl@0
    41
namespace boost {
sl@0
    42
sl@0
    43
  namespace detail {
sl@0
    44
    // structure to aid in counting bits
sl@0
    45
    template<bool dummy = true>
sl@0
    46
    struct bit_count {
sl@0
    47
      static unsigned char value[256];
sl@0
    48
    };
sl@0
    49
sl@0
    50
    // Mapping from 8 bit unsigned integers to the index of the first bit
sl@0
    51
    template<bool dummy = true>
sl@0
    52
    struct first_bit_location {
sl@0
    53
      static unsigned char value[256];
sl@0
    54
    };
sl@0
    55
sl@0
    56
    template <typename WordType>  // this size is in bits
sl@0
    57
    struct word_traits {
sl@0
    58
      typedef WordType word_type;
sl@0
    59
      static const std::size_t word_size = CHAR_BIT * sizeof(word_type);
sl@0
    60
    };
sl@0
    61
    
sl@0
    62
    //=========================================================================
sl@0
    63
    template <class WordTraits, class SizeType, class Derived>
sl@0
    64
    class bitset_base
sl@0
    65
      : public bitset_adaptor< SizeType, 
sl@0
    66
                               bitset_base<WordTraits, SizeType, Derived> >
sl@0
    67
    {
sl@0
    68
      //    private:
sl@0
    69
    public:
sl@0
    70
      typedef SizeType size_type;
sl@0
    71
      typedef typename WordTraits::word_type word_type;
sl@0
    72
sl@0
    73
      static size_type s_which_word(size_type pos) {
sl@0
    74
        return pos / WordTraits::word_size;
sl@0
    75
      }
sl@0
    76
      static size_type s_which_byte(size_type pos) {
sl@0
    77
        return (pos % WordTraits::word_size) / CHAR_BIT;
sl@0
    78
      }
sl@0
    79
      static size_type s_which_bit(size_type pos) {
sl@0
    80
        return pos % WordTraits::word_size;
sl@0
    81
      }
sl@0
    82
      static word_type s_mask_bit(size_type pos) {
sl@0
    83
        return (static_cast<word_type>(1)) << s_which_bit(pos); 
sl@0
    84
      }
sl@0
    85
      word_type& m_get_word(size_type pos) {
sl@0
    86
        return data()[s_which_word(pos)]; 
sl@0
    87
      }
sl@0
    88
      word_type m_get_word(size_type pos) const {
sl@0
    89
        return data()[s_which_word(pos)]; 
sl@0
    90
      }
sl@0
    91
      word_type& m_hi_word() { return data()[num_words() - 1]; }
sl@0
    92
      word_type  m_hi_word() const { return data()[num_words() - 1]; }
sl@0
    93
sl@0
    94
      void m_sanitize_highest() {
sl@0
    95
        size_type extra_bits = size() % WordTraits::word_size;
sl@0
    96
        if (extra_bits)
sl@0
    97
          m_hi_word() &= ~((~static_cast<word_type>(0)) << extra_bits);
sl@0
    98
      }
sl@0
    99
    public:
sl@0
   100
sl@0
   101
      class reference {
sl@0
   102
        friend class bitset_base;
sl@0
   103
sl@0
   104
        word_type *m_word_ptr;
sl@0
   105
        size_type m_bit_pos;
sl@0
   106
sl@0
   107
        // left undefined
sl@0
   108
        reference();
sl@0
   109
sl@0
   110
        reference(bitset_base& b, size_type pos ) {
sl@0
   111
          m_word_ptr = &b.m_get_word(pos);
sl@0
   112
          m_bit_pos = s_which_bit(pos);
sl@0
   113
        }
sl@0
   114
sl@0
   115
      public:
sl@0
   116
        ~reference() {}
sl@0
   117
sl@0
   118
        // for b[i] = x;
sl@0
   119
        reference& operator=(bool x) {
sl@0
   120
          if ( x )
sl@0
   121
            *m_word_ptr |= s_mask_bit(m_bit_pos);
sl@0
   122
          else
sl@0
   123
            *m_word_ptr &= ~s_mask_bit(m_bit_pos);
sl@0
   124
sl@0
   125
          return *this;
sl@0
   126
        }
sl@0
   127
        // for b[i] = b[j];
sl@0
   128
        reference& operator=(const reference& j) {
sl@0
   129
          if ( (*(j.m_word_ptr) & s_mask_bit(j.m_bit_pos)) )
sl@0
   130
            *m_word_ptr |= s_mask_bit(m_bit_pos);
sl@0
   131
          else
sl@0
   132
            *m_word_ptr &= ~s_mask_bit(m_bit_pos);
sl@0
   133
sl@0
   134
          return *this;
sl@0
   135
        }
sl@0
   136
        // flips the bit
sl@0
   137
        bool operator~() const { 
sl@0
   138
          return (*(m_word_ptr) & s_mask_bit(m_bit_pos)) == 0; 
sl@0
   139
        }
sl@0
   140
        // for x = b[i];
sl@0
   141
        operator bool() const { 
sl@0
   142
          return (*(m_word_ptr) & s_mask_bit(m_bit_pos)) != 0; 
sl@0
   143
        }
sl@0
   144
        // for b[i].flip();
sl@0
   145
        reference& flip() {
sl@0
   146
          *m_word_ptr ^= s_mask_bit(m_bit_pos);
sl@0
   147
          return *this;
sl@0
   148
        }
sl@0
   149
      };
sl@0
   150
sl@0
   151
      void init_from_ulong(unsigned long val) {
sl@0
   152
        reset();
sl@0
   153
        const size_type n = (std::min)(sizeof(unsigned long) * CHAR_BIT,
sl@0
   154
                                     WordTraits::word_size * num_words());
sl@0
   155
        for(size_type i = 0; i < n; ++i, val >>= 1)
sl@0
   156
          if ( val & 0x1 )
sl@0
   157
            m_get_word(i) |= s_mask_bit(i);
sl@0
   158
      }
sl@0
   159
      
sl@0
   160
      // intersection: this = this & x
sl@0
   161
      Derived& operator&=(const Derived& x) {
sl@0
   162
        for (size_type i = 0; i < num_words(); ++i)
sl@0
   163
          data()[i] &= x.data()[i];
sl@0
   164
        return static_cast<Derived&>(*this);
sl@0
   165
      }
sl@0
   166
      // union: this = this | x
sl@0
   167
      Derived& operator|=(const Derived& x) {
sl@0
   168
        for (size_type i = 0; i < num_words(); ++i)
sl@0
   169
          data()[i] |= x.data()[i];
sl@0
   170
        return static_cast<Derived&>(*this);
sl@0
   171
      }
sl@0
   172
      // exclusive or: this = this ^ x
sl@0
   173
      Derived& operator^=(const Derived& x) {
sl@0
   174
        for (size_type i = 0; i < num_words(); ++i)
sl@0
   175
          data()[i] ^= x.data()[i];
sl@0
   176
        return static_cast<Derived&>(*this);
sl@0
   177
      }
sl@0
   178
      // left shift
sl@0
   179
      Derived& operator<<=(size_type pos);
sl@0
   180
sl@0
   181
      // right shift
sl@0
   182
      Derived& operator>>=(size_type pos);
sl@0
   183
sl@0
   184
      Derived& set() {
sl@0
   185
        for (size_type i = 0; i < num_words(); ++i)
sl@0
   186
          data()[i] = ~static_cast<word_type>(0);
sl@0
   187
        m_sanitize_highest();
sl@0
   188
        return static_cast<Derived&>(*this);
sl@0
   189
      }
sl@0
   190
sl@0
   191
      Derived& set(size_type pos, int val = true)
sl@0
   192
      {
sl@0
   193
        BOOST_ASSERT_THROW(pos < size(), std::out_of_range("boost::bitset::set(pos,value)"));
sl@0
   194
        if (val)
sl@0
   195
          m_get_word(pos) |= s_mask_bit(pos);
sl@0
   196
        else
sl@0
   197
          m_get_word(pos) &= ~s_mask_bit(pos);
sl@0
   198
        return static_cast<Derived&>(*this);
sl@0
   199
      }
sl@0
   200
      
sl@0
   201
      Derived& reset() {
sl@0
   202
        for (size_type i = 0; i < num_words(); ++i)
sl@0
   203
          data()[i] = 0;
sl@0
   204
        return static_cast<Derived&>(*this);
sl@0
   205
      }
sl@0
   206
sl@0
   207
      Derived& reset(size_type pos) {
sl@0
   208
        BOOST_ASSERT_THROW(pos < size(), std::out_of_range("boost::bitset::reset(pos)"));
sl@0
   209
        m_get_word(pos) &= ~s_mask_bit(pos);
sl@0
   210
        return static_cast<Derived&>(*this);
sl@0
   211
      }
sl@0
   212
sl@0
   213
      // compliment
sl@0
   214
      Derived operator~() const {
sl@0
   215
        return Derived(static_cast<const Derived&>(*this)).flip();
sl@0
   216
      }
sl@0
   217
      
sl@0
   218
      Derived& flip() {
sl@0
   219
        for (size_type i = 0; i < num_words(); ++i)
sl@0
   220
          data()[i] = ~data()[i];
sl@0
   221
        m_sanitize_highest();
sl@0
   222
        return static_cast<Derived&>(*this);
sl@0
   223
      }
sl@0
   224
      Derived& flip(size_type pos) {
sl@0
   225
        BOOST_ASSERT_THROW(pos < size(), std::out_of_range("boost::bitset::flip(pos)"));
sl@0
   226
        m_get_word(pos) ^= s_mask_bit(pos);
sl@0
   227
        return static_cast<Derived&>(*this);
sl@0
   228
      }
sl@0
   229
sl@0
   230
      // element access
sl@0
   231
      reference operator[](size_type pos) { return reference(*this, pos); }
sl@0
   232
      bool operator[](size_type pos) const { return test(pos); }
sl@0
   233
sl@0
   234
      unsigned long to_ulong() const;
sl@0
   235
sl@0
   236
      // to_string
sl@0
   237
sl@0
   238
      
sl@0
   239
      size_type count() const {
sl@0
   240
        size_type result = 0;
sl@0
   241
        const unsigned char* byte_ptr = (const unsigned char*)data();
sl@0
   242
        const unsigned char* end_ptr = 
sl@0
   243
          (const unsigned char*)(data() + num_words());
sl@0
   244
        while ( byte_ptr < end_ptr ) {
sl@0
   245
          result += bit_count<>::value[*byte_ptr];
sl@0
   246
          byte_ptr++;
sl@0
   247
        }
sl@0
   248
        return result;
sl@0
   249
      }   
sl@0
   250
      
sl@0
   251
      // size() must be provided by Derived class
sl@0
   252
sl@0
   253
      bool operator==(const Derived& x) const {
sl@0
   254
        return std::equal(data(), data() + num_words(), x.data());
sl@0
   255
      }
sl@0
   256
sl@0
   257
      bool operator!=(const Derived& x) const {
sl@0
   258
        return ! this->operator==(x);
sl@0
   259
      }
sl@0
   260
sl@0
   261
      bool test(size_type pos) const {
sl@0
   262
        BOOST_ASSERT_THROW(pos < size(), std::out_of_range("boost::bitset::test(pos)"));
sl@0
   263
        return (m_get_word(pos) & s_mask_bit(pos))
sl@0
   264
          != static_cast<word_type>(0);
sl@0
   265
      }
sl@0
   266
sl@0
   267
      bool any() const {
sl@0
   268
        for (size_type i = 0; i < num_words(); ++i) {
sl@0
   269
          if ( data()[i] != static_cast<word_type>(0) )
sl@0
   270
            return true;
sl@0
   271
        }
sl@0
   272
        return false;
sl@0
   273
      }
sl@0
   274
      bool none() const {
sl@0
   275
        return !any();
sl@0
   276
      }
sl@0
   277
sl@0
   278
      Derived operator<<(size_type pos) const
sl@0
   279
        { return Derived(static_cast<const Derived&>(*this)) <<= pos; }
sl@0
   280
sl@0
   281
      Derived operator>>(size_type pos) const
sl@0
   282
        { return Derived(static_cast<const Derived&>(*this)) >>= pos; }
sl@0
   283
sl@0
   284
      template <class CharT, class Traits, class Alloc>
sl@0
   285
      void m_copy_from_string(const basic_string<CharT,Traits,Alloc>& s,
sl@0
   286
                              size_type pos, size_type n)
sl@0
   287
      {
sl@0
   288
        reset();
sl@0
   289
        const size_type nbits = (std::min)(size(), (std::min)(n, s.size() - pos));
sl@0
   290
        for (size_type i = 0; i < nbits; ++i) {
sl@0
   291
          switch(s[pos + nbits - i - 1]) {
sl@0
   292
          case '0':
sl@0
   293
            break;
sl@0
   294
          case '1':
sl@0
   295
            this->set(i);
sl@0
   296
            break;
sl@0
   297
          default:
sl@0
   298
            throw std::invalid_argument
sl@0
   299
              ("boost::bitset_base::m_copy_from_string(s, pos, n)");
sl@0
   300
          }
sl@0
   301
        }
sl@0
   302
      }
sl@0
   303
sl@0
   304
      template <class CharT, class Traits, class Alloc>
sl@0
   305
      void m_copy_to_string(basic_string<CharT, Traits, Alloc>& s) const
sl@0
   306
      {
sl@0
   307
        s.assign(size(), '0');
sl@0
   308
        
sl@0
   309
        for (size_type i = 0; i < size(); ++i)
sl@0
   310
          if (test(i))
sl@0
   311
            s[size() - 1 - i] = '1';
sl@0
   312
      }
sl@0
   313
sl@0
   314
      //-----------------------------------------------------------------------
sl@0
   315
      // Stuff not in std::bitset
sl@0
   316
sl@0
   317
      // difference:  this = this - x
sl@0
   318
      Derived& operator-=(const Derived& x) {
sl@0
   319
        for (size_type i = 0; i < num_words(); ++i)
sl@0
   320
          data()[i] &= ~x.data()[i];
sl@0
   321
        return static_cast<Derived&>(*this);
sl@0
   322
      }
sl@0
   323
sl@0
   324
      // this wasn't working, why?
sl@0
   325
      int compare_3way(const Derived& x) const {
sl@0
   326
        return std::lexicographical_compare_3way
sl@0
   327
          (data(), data() + num_words(), x.data(), x.data() + x.num_words());
sl@0
   328
      }
sl@0
   329
sl@0
   330
      // less-than compare
sl@0
   331
      bool operator<(const Derived& x) const {
sl@0
   332
        return std::lexicographical_compare
sl@0
   333
          (data(), data() + num_words(), x.data(), x.data() + x.num_words());
sl@0
   334
      }
sl@0
   335
sl@0
   336
      // find the index of the first "on" bit
sl@0
   337
      size_type find_first() const;
sl@0
   338
sl@0
   339
      // find the index of the next "on" bit after prev
sl@0
   340
      size_type find_next(size_type prev) const;
sl@0
   341
sl@0
   342
      
sl@0
   343
      size_type _Find_first() const { return find_first(); }
sl@0
   344
sl@0
   345
      // find the index of the next "on" bit after prev
sl@0
   346
      size_type _Find_next(size_type prev) const { return find_next(prev); }
sl@0
   347
sl@0
   348
      //    private:
sl@0
   349
      word_type* data()
sl@0
   350
        { return static_cast<Derived*>(this)->data(); }
sl@0
   351
sl@0
   352
      const word_type* data() const 
sl@0
   353
        { return static_cast<const Derived*>(this)->data(); }
sl@0
   354
sl@0
   355
      size_type num_words() const 
sl@0
   356
        { return static_cast<const Derived*>(this)->num_words(); }
sl@0
   357
sl@0
   358
      size_type size() const 
sl@0
   359
        { return static_cast<const Derived*>(this)->size(); }
sl@0
   360
    };
sl@0
   361
sl@0
   362
    // 23.3.5.3 bitset operations:
sl@0
   363
    template <class W, class S, class D>
sl@0
   364
    inline D operator&(const bitset_base<W,S,D>& x,
sl@0
   365
                       const bitset_base<W,S,D>& y) {
sl@0
   366
      D result(static_cast<const D&>(x));
sl@0
   367
      result &= static_cast<const D&>(y);
sl@0
   368
      return result;
sl@0
   369
    }
sl@0
   370
sl@0
   371
    template <class W, class S, class D>
sl@0
   372
    inline D operator|(const bitset_base<W,S,D>& x,
sl@0
   373
                       const bitset_base<W,S,D>& y) {
sl@0
   374
      D result(static_cast<const D&>(x));
sl@0
   375
      result |= static_cast<const D&>(y);
sl@0
   376
      return result;
sl@0
   377
    }
sl@0
   378
sl@0
   379
    template <class W, class S, class D>
sl@0
   380
    inline D operator^(const bitset_base<W,S,D>& x,
sl@0
   381
                       const bitset_base<W,S,D>& y) {
sl@0
   382
      D result(static_cast<const D&>(x));
sl@0
   383
      result ^= static_cast<const D&>(y);
sl@0
   384
      return result;
sl@0
   385
    }
sl@0
   386
sl@0
   387
    // this one is an extension
sl@0
   388
    template <class W, class S, class D>
sl@0
   389
    inline D operator-(const bitset_base<W,S,D>& x,
sl@0
   390
                       const bitset_base<W,S,D>& y) {
sl@0
   391
      D result(static_cast<const D&>(x));
sl@0
   392
      result -= static_cast<const D&>(y);
sl@0
   393
      return result;
sl@0
   394
    }
sl@0
   395
sl@0
   396
    template <class W, class S, class D>
sl@0
   397
    inline int compare_3way(const bitset_base<W,S,D>& x,
sl@0
   398
                            const bitset_base<W,S,D>& y) {
sl@0
   399
      return std::lexicographical_compare_3way
sl@0
   400
        (x.data(), x.data() + x.num_words(), 
sl@0
   401
         y.data(), y.data() + y.num_words());
sl@0
   402
    }
sl@0
   403
sl@0
   404
sl@0
   405
    template <class W, class S, class D>
sl@0
   406
    std::istream&
sl@0
   407
    operator>>(std::istream& is, bitset_base<W,S,D>& x) {
sl@0
   408
      std::string tmp;
sl@0
   409
      tmp.reserve(x.size());
sl@0
   410
sl@0
   411
      // In new templatized iostreams, use istream::sentry
sl@0
   412
      if (is.flags() & ios::skipws) {
sl@0
   413
        char c;
sl@0
   414
        do
sl@0
   415
          is.get(c);
sl@0
   416
        while (is && isspace(c));
sl@0
   417
        if (is)
sl@0
   418
          is.putback(c);
sl@0
   419
      }
sl@0
   420
sl@0
   421
      for (S i = 0; i < x.size(); ++i) {
sl@0
   422
        char c;
sl@0
   423
        is.get(c);
sl@0
   424
sl@0
   425
        if (!is)
sl@0
   426
          break;
sl@0
   427
        else if (c != '0' && c != '1') {
sl@0
   428
          is.putback(c);
sl@0
   429
          break;
sl@0
   430
        }
sl@0
   431
        else
sl@0
   432
          //      tmp.push_back(c);
sl@0
   433
          tmp += c;
sl@0
   434
      }
sl@0
   435
sl@0
   436
      if (tmp.empty())
sl@0
   437
        is.clear(is.rdstate() | ios::failbit);
sl@0
   438
      else
sl@0
   439
        x.m_copy_from_string(tmp, static_cast<S>(0), x.size());
sl@0
   440
sl@0
   441
      return is;
sl@0
   442
    }
sl@0
   443
sl@0
   444
    template <class W, class S, class D>
sl@0
   445
    std::ostream& operator<<(std::ostream& os, 
sl@0
   446
                             const bitset_base<W,S,D>& x) {
sl@0
   447
      std::string tmp;
sl@0
   448
      x.m_copy_to_string(tmp);
sl@0
   449
      return os << tmp;
sl@0
   450
    }
sl@0
   451
sl@0
   452
    //=========================================================================
sl@0
   453
    template <typename WordType = unsigned long,
sl@0
   454
              typename SizeType = std::size_t,
sl@0
   455
              typename Allocator = std::allocator<WordType>
sl@0
   456
             >
sl@0
   457
    class dyn_size_bitset
sl@0
   458
      : public bitset_base<word_traits<WordType>, SizeType,
sl@0
   459
          dyn_size_bitset<WordType,SizeType,Allocator> >
sl@0
   460
    {
sl@0
   461
      typedef dyn_size_bitset self;
sl@0
   462
    public:
sl@0
   463
      typedef SizeType size_type;
sl@0
   464
    private:
sl@0
   465
      typedef word_traits<WordType> WordTraits;
sl@0
   466
      static const size_type word_size = WordTraits::word_size;
sl@0
   467
sl@0
   468
    public:
sl@0
   469
      dyn_size_bitset(unsigned long val, 
sl@0
   470
                      size_type n,
sl@0
   471
                      const Allocator& alloc = Allocator()) 
sl@0
   472
        : m_data(alloc.allocate((n + word_size - 1) / word_size)),
sl@0
   473
          m_size(n),
sl@0
   474
          m_num_words((n + word_size - 1) / word_size),
sl@0
   475
          m_alloc(alloc)
sl@0
   476
      {
sl@0
   477
        init_from_ulong(val);
sl@0
   478
      }
sl@0
   479
sl@0
   480
      dyn_size_bitset(size_type n,  // size of the set's "universe"
sl@0
   481
                      const Allocator& alloc = Allocator())
sl@0
   482
        : m_data(alloc.allocate((n + word_size - 1) / word_size)), 
sl@0
   483
          m_size(n), m_num_words((n + word_size - 1) / word_size),
sl@0
   484
          m_alloc(alloc)
sl@0
   485
      { }
sl@0
   486
sl@0
   487
      template<class CharT, class Traits, class Alloc>
sl@0
   488
      explicit dyn_size_bitset
sl@0
   489
        (const basic_string<CharT,Traits,Alloc>& s,
sl@0
   490
         std::size_t pos = 0,
sl@0
   491
         std::size_t n = std::size_t(basic_string<CharT,Traits,Alloc>::npos),
sl@0
   492
         const Allocator& alloc = Allocator())
sl@0
   493
        : m_data(alloc.allocate((n + word_size - 1) / word_size)), 
sl@0
   494
          m_size(n), m_num_words((n + word_size - 1) / word_size),
sl@0
   495
          m_alloc(alloc)
sl@0
   496
      {
sl@0
   497
        BOOST_ASSERT_THROW(pos < s.size(), std::out_of_range("dyn_size_bitset::dyn_size_bitset(s,pos,n,alloc)"));
sl@0
   498
        m_copy_from_string(s, pos, n);
sl@0
   499
      }
sl@0
   500
sl@0
   501
      template <typename InputIterator>
sl@0
   502
      explicit dyn_size_bitset
sl@0
   503
        (InputIterator first, InputIterator last,
sl@0
   504
         size_type n,  // size of the set's "universe"
sl@0
   505
         const Allocator& alloc = Allocator())
sl@0
   506
        : m_data(alloc.allocate((n + word_size - 1) / word_size)), 
sl@0
   507
          m_size(N), m_num_words((n + word_size - 1) / word_size),
sl@0
   508
          m_alloc(alloc)
sl@0
   509
      {
sl@0
   510
        while (first != last)
sl@0
   511
          this->set(*first++);
sl@0
   512
      }
sl@0
   513
sl@0
   514
      ~dyn_size_bitset() { 
sl@0
   515
        m_alloc.deallocate(m_data, m_num_words); 
sl@0
   516
      }
sl@0
   517
      
sl@0
   518
      size_type size() const { return m_size; }
sl@0
   519
sl@0
   520
      // protected:
sl@0
   521
      size_type num_words() const { return m_num_words; }
sl@0
   522
sl@0
   523
      word_type* data() { return m_data; }
sl@0
   524
      const word_type* data() const { return m_data; }
sl@0
   525
sl@0
   526
    protected:
sl@0
   527
      word_type* m_data;
sl@0
   528
      SizeType m_size;
sl@0
   529
      SizeType m_num_words;
sl@0
   530
      Allocator m_alloc;
sl@0
   531
    };
sl@0
   532
sl@0
   533
    //=========================================================================
sl@0
   534
    template <std::size_t N, typename WordType = unsigned long,
sl@0
   535
      typename SizeType = std::size_t>
sl@0
   536
    class bitset
sl@0
   537
      : public bitset_base<word_traits<WordType>, SizeType,
sl@0
   538
          bitset<N, WordType, SizeType> >
sl@0
   539
    {
sl@0
   540
      typedef bitset self;
sl@0
   541
      static const std::size_t word_size = word_traits<WordType>::word_size;
sl@0
   542
    public:
sl@0
   543
        // 23.3.5.1 constructors:
sl@0
   544
      bitset() {
sl@0
   545
#if defined(__GNUC__)
sl@0
   546
        for (size_type i = 0; i < num_words(); ++i)
sl@0
   547
          m_data[i] = static_cast<WordType>(0);
sl@0
   548
#endif
sl@0
   549
      }
sl@0
   550
sl@0
   551
      bitset(unsigned long val) {
sl@0
   552
        init_from_ulong(val);
sl@0
   553
      }
sl@0
   554
sl@0
   555
      template<class CharT, class Traits, class Alloc>
sl@0
   556
      explicit bitset
sl@0
   557
        (const basic_string<CharT,Traits,Alloc>& s,
sl@0
   558
         std::size_t pos = 0,
sl@0
   559
         std::size_t n = std::size_t(basic_string<CharT,Traits,Alloc>::npos))
sl@0
   560
      {
sl@0
   561
        BOOST_ASSERT_THROW
sl@0
   562
          (pos < s.size(), std::out_of_range("bitset::bitset(s,pos,n)"));
sl@0
   563
        m_copy_from_string(s, pos, n);
sl@0
   564
      }
sl@0
   565
sl@0
   566
      size_type size() const { return N; }
sl@0
   567
sl@0
   568
      // protected:
sl@0
   569
      size_type num_words() const { return (N + word_size - 1) / word_size; }
sl@0
   570
sl@0
   571
      word_type* data() { return m_data; }
sl@0
   572
      const word_type* data() const { return m_data; }
sl@0
   573
    protected:
sl@0
   574
      word_type m_data[(N + word_size - 1) / word_size];
sl@0
   575
    };
sl@0
   576
sl@0
   577
    //=========================================================================
sl@0
   578
    struct select_static_bitset {
sl@0
   579
      template <std::size_t N, typename WordT, typename SizeT, typename Alloc>
sl@0
   580
      struct bind_ {
sl@0
   581
        typedef bitset<N, WordT, SizeT> type;
sl@0
   582
      };
sl@0
   583
    };
sl@0
   584
    struct select_dyn_size_bitset {
sl@0
   585
      template <std::size_t N, typename WordT, typename SizeT, typename Alloc>
sl@0
   586
      struct bind_ {
sl@0
   587
        typedef dyn_size_bitset<WordT, SizeT, Alloc> type;
sl@0
   588
      };
sl@0
   589
    };
sl@0
   590
sl@0
   591
    template <std::size_t N = 0, // 0 means use dynamic
sl@0
   592
      typename WordType = unsigned long,
sl@0
   593
      typename Size_type = std::size_t, 
sl@0
   594
      typename Allocator = std::allocator<WordType>
sl@0
   595
             >
sl@0
   596
    class bitset_generator {
sl@0
   597
      typedef typename ct_if<N, select_dyn_size_bitset,
sl@0
   598
        select_static_bitset>::type selector;
sl@0
   599
    public:
sl@0
   600
      typedef typename selector
sl@0
   601
        ::template bind_<N, WordType, SizeType, Allocator>::type type;
sl@0
   602
    };
sl@0
   603
sl@0
   604
sl@0
   605
    //=========================================================================
sl@0
   606
    // bitset_base non-inline member function implementations
sl@0
   607
sl@0
   608
    template <class WordTraits, class SizeType, class Derived>
sl@0
   609
    Derived&
sl@0
   610
    bitset_base<WordTraits, SizeType, Derived>::
sl@0
   611
    operator<<=(size_type shift)
sl@0
   612
    {
sl@0
   613
      typedef typename WordTraits::word_type word_type;
sl@0
   614
      typedef SizeType size_type;
sl@0
   615
      if (shift != 0) {
sl@0
   616
        const size_type wshift = shift / WordTraits::word_size;
sl@0
   617
        const size_type offset = shift % WordTraits::word_size;
sl@0
   618
        const size_type sub_offset = WordTraits::word_size - offset;
sl@0
   619
        size_type n = num_words() - 1;
sl@0
   620
        for ( ; n > wshift; --n)
sl@0
   621
          data()[n] = (data()[n - wshift] << offset) |
sl@0
   622
            (data()[n - wshift - 1] >> sub_offset);
sl@0
   623
        if (n == wshift)
sl@0
   624
          data()[n] = data()[0] << offset;
sl@0
   625
        for (size_type n1 = 0; n1 < n; ++n1)
sl@0
   626
          data()[n1] = static_cast<word_type>(0);
sl@0
   627
      }
sl@0
   628
      m_sanitize_highest();
sl@0
   629
      return static_cast<Derived&>(*this);
sl@0
   630
    } // end operator<<=
sl@0
   631
sl@0
   632
sl@0
   633
    template <class WordTraits, class SizeType, class Derived>
sl@0
   634
    Derived&
sl@0
   635
    bitset_base<WordTraits, SizeType, Derived>::
sl@0
   636
    operator>>=(size_type shift)
sl@0
   637
    {
sl@0
   638
      typedef typename WordTraits::word_type word_type;
sl@0
   639
      typedef SizeType size_type;
sl@0
   640
      if (shift != 0) {
sl@0
   641
        const size_type wshift = shift / WordTraits::word_size;
sl@0
   642
        const size_type offset = shift % WordTraits::word_size;
sl@0
   643
        const size_type sub_offset = WordTraits::word_size - offset;
sl@0
   644
        const size_type limit = num_words() - wshift - 1;
sl@0
   645
        size_type n = 0;
sl@0
   646
        for ( ; n < limit; ++n)
sl@0
   647
          data()[n] = (data()[n + wshift] >> offset) |
sl@0
   648
            (data()[n + wshift + 1] << sub_offset);
sl@0
   649
        data()[limit] = data()[num_words()-1] >> offset;
sl@0
   650
        for (size_type n1 = limit + 1; n1 < num_words(); ++n1)
sl@0
   651
          data()[n1] = static_cast<word_type>(0);
sl@0
   652
      }
sl@0
   653
      m_sanitize_highest();
sl@0
   654
      return static_cast<Derived&>(*this);
sl@0
   655
    } // end operator>>=
sl@0
   656
sl@0
   657
sl@0
   658
    template <class WordTraits, class SizeType, class Derived>
sl@0
   659
    unsigned long bitset_base<WordTraits, SizeType, Derived>::
sl@0
   660
    to_ulong() const 
sl@0
   661
    {
sl@0
   662
      typedef typename WordTraits::word_type word_type;
sl@0
   663
      typedef SizeType size_type;
sl@0
   664
      const std::overflow_error
sl@0
   665
        overflow("boost::bit_set::operator unsigned long()");
sl@0
   666
sl@0
   667
      if (sizeof(word_type) >= sizeof(unsigned long)) {
sl@0
   668
        for (size_type i = 1; i < num_words(); ++i)
sl@0
   669
          BOOST_ASSERT_THROW(! data()[i], overflow);
sl@0
   670
        
sl@0
   671
        const word_type mask 
sl@0
   672
          = static_cast<word_type>(static_cast<unsigned long>(-1));
sl@0
   673
        BOOST_ASSERT_THROW(! (data()[0] & ~mask), overflow);
sl@0
   674
        
sl@0
   675
        return static_cast<unsigned long>(data()[0] & mask);
sl@0
   676
      }
sl@0
   677
      else { // sizeof(word_type) < sizeof(unsigned long).
sl@0
   678
        const size_type nwords =
sl@0
   679
          (sizeof(unsigned long) + sizeof(word_type) - 1) / sizeof(word_type);
sl@0
   680
sl@0
   681
        size_type min_nwords = nwords;
sl@0
   682
        if (num_words() > nwords) {
sl@0
   683
          for (size_type i = nwords; i < num_words(); ++i)
sl@0
   684
            BOOST_ASSERT_THROW(!data()[i], overflow);
sl@0
   685
        }
sl@0
   686
        else
sl@0
   687
          min_nwords = num_words();
sl@0
   688
sl@0
   689
        // If unsigned long is 8 bytes and word_type is 6 bytes, then
sl@0
   690
        // an unsigned long consists of all of one word plus 2 bytes
sl@0
   691
        // from another word.
sl@0
   692
        const size_type part = sizeof(unsigned long) % sizeof(word_type);
sl@0
   693
sl@0
   694
#if 0
sl@0
   695
        // bug in here?
sl@0
   696
        // >> to far?
sl@0
   697
        BOOST_ASSERT_THROW((part != 0 
sl@0
   698
                            && nwords <= num_words() 
sl@0
   699
                            && (data()[min_nwords - 1] >>
sl@0
   700
                                ((sizeof(word_type) - part) * CHAR_BIT)) != 0),
sl@0
   701
                           overflow);
sl@0
   702
#endif
sl@0
   703
sl@0
   704
        unsigned long result = 0;
sl@0
   705
        for (size_type i = 0; i < min_nwords; ++i) {
sl@0
   706
          result |= static_cast<unsigned long>(
sl@0
   707
             data()[i]) << (i * sizeof(word_type) * CHAR_BIT);
sl@0
   708
        }
sl@0
   709
        return result;
sl@0
   710
      }
sl@0
   711
    }// end operator unsigned long()
sl@0
   712
sl@0
   713
sl@0
   714
    template <class WordTraits, class SizeType, class Derived>
sl@0
   715
    SizeType bitset_base<WordTraits,SizeType,Derived>::
sl@0
   716
    find_first() const
sl@0
   717
    {
sl@0
   718
      SizeType not_found = size();
sl@0
   719
      for (size_type i = 0; i < num_words(); i++ ) {
sl@0
   720
        word_type thisword = data()[i];
sl@0
   721
        if ( thisword != static_cast<word_type>(0) ) {
sl@0
   722
          // find byte within word
sl@0
   723
          for ( std::size_t j = 0; j < sizeof(word_type); j++ ) {
sl@0
   724
            unsigned char this_byte
sl@0
   725
              = static_cast<unsigned char>(thisword & (~(unsigned char)0));
sl@0
   726
            if ( this_byte )
sl@0
   727
              return i * WordTraits::word_size + j * CHAR_BIT +
sl@0
   728
                first_bit_location<>::value[this_byte];
sl@0
   729
sl@0
   730
            thisword >>= CHAR_BIT;
sl@0
   731
          }
sl@0
   732
        }
sl@0
   733
      }
sl@0
   734
      // not found, so return an indication of failure.
sl@0
   735
      return not_found;
sl@0
   736
    }
sl@0
   737
sl@0
   738
    template <class WordTraits, class SizeType, class Derived>
sl@0
   739
    SizeType bitset_base<WordTraits, SizeType, Derived>::
sl@0
   740
    bitset_base<WordTraits,SizeType,Derived>::
sl@0
   741
    find_next(size_type prev) const
sl@0
   742
    {
sl@0
   743
      SizeType not_found = size();
sl@0
   744
      // make bound inclusive
sl@0
   745
      ++prev;
sl@0
   746
sl@0
   747
      // check out of bounds
sl@0
   748
      if ( prev >= num_words() * WordTraits::word_size )
sl@0
   749
        return not_found;
sl@0
   750
sl@0
   751
        // search first word
sl@0
   752
      size_type i = s_which_word(prev);
sl@0
   753
      word_type thisword = data()[i];
sl@0
   754
sl@0
   755
        // mask off bits below bound
sl@0
   756
      thisword &= (~static_cast<word_type>(0)) << s_which_bit(prev);
sl@0
   757
sl@0
   758
      if ( thisword != static_cast<word_type>(0) ) {
sl@0
   759
        // find byte within word
sl@0
   760
        // get first byte into place
sl@0
   761
        thisword >>= s_which_byte(prev) * CHAR_BIT;
sl@0
   762
        for ( size_type j = s_which_byte(prev); j < sizeof(word_type); j++ ) {
sl@0
   763
          unsigned char this_byte
sl@0
   764
            = static_cast<unsigned char>(thisword & (~(unsigned char)0));
sl@0
   765
          if ( this_byte )
sl@0
   766
            return i * WordTraits::word_size + j * CHAR_BIT +
sl@0
   767
              first_bit_location<>::value[this_byte];
sl@0
   768
sl@0
   769
          thisword >>= CHAR_BIT;
sl@0
   770
        }
sl@0
   771
      }
sl@0
   772
sl@0
   773
      // check subsequent words
sl@0
   774
      i++;
sl@0
   775
      for ( ; i < num_words(); i++ ) {
sl@0
   776
        word_type thisword = data()[i];
sl@0
   777
        if ( thisword != static_cast<word_type>(0) ) {
sl@0
   778
          // find byte within word
sl@0
   779
          for ( size_type j = 0; j < sizeof(word_type); j++ ) {
sl@0
   780
            unsigned char this_byte
sl@0
   781
              = static_cast<unsigned char>(thisword & (~(unsigned char)0));
sl@0
   782
            if ( this_byte )
sl@0
   783
              return i * WordTraits::word_size + j * CHAR_BIT +
sl@0
   784
                first_bit_location<>::value[this_byte];
sl@0
   785
sl@0
   786
            thisword >>= CHAR_BIT;
sl@0
   787
          }
sl@0
   788
        }
sl@0
   789
      }
sl@0
   790
sl@0
   791
      // not found, so return an indication of failure.
sl@0
   792
      return not_found;
sl@0
   793
    } // end find_next
sl@0
   794
sl@0
   795
sl@0
   796
    template <bool dummy>
sl@0
   797
    unsigned char bit_count<dummy>::value[] = {
sl@0
   798
      0, /*   0 */ 1, /*   1 */ 1, /*   2 */ 2, /*   3 */ 1, /*   4 */
sl@0
   799
      2, /*   5 */ 2, /*   6 */ 3, /*   7 */ 1, /*   8 */ 2, /*   9 */
sl@0
   800
      2, /*  10 */ 3, /*  11 */ 2, /*  12 */ 3, /*  13 */ 3, /*  14 */
sl@0
   801
      4, /*  15 */ 1, /*  16 */ 2, /*  17 */ 2, /*  18 */ 3, /*  19 */
sl@0
   802
      2, /*  20 */ 3, /*  21 */ 3, /*  22 */ 4, /*  23 */ 2, /*  24 */
sl@0
   803
      3, /*  25 */ 3, /*  26 */ 4, /*  27 */ 3, /*  28 */ 4, /*  29 */
sl@0
   804
      4, /*  30 */ 5, /*  31 */ 1, /*  32 */ 2, /*  33 */ 2, /*  34 */
sl@0
   805
      3, /*  35 */ 2, /*  36 */ 3, /*  37 */ 3, /*  38 */ 4, /*  39 */
sl@0
   806
      2, /*  40 */ 3, /*  41 */ 3, /*  42 */ 4, /*  43 */ 3, /*  44 */
sl@0
   807
      4, /*  45 */ 4, /*  46 */ 5, /*  47 */ 2, /*  48 */ 3, /*  49 */
sl@0
   808
      3, /*  50 */ 4, /*  51 */ 3, /*  52 */ 4, /*  53 */ 4, /*  54 */
sl@0
   809
      5, /*  55 */ 3, /*  56 */ 4, /*  57 */ 4, /*  58 */ 5, /*  59 */
sl@0
   810
      4, /*  60 */ 5, /*  61 */ 5, /*  62 */ 6, /*  63 */ 1, /*  64 */
sl@0
   811
      2, /*  65 */ 2, /*  66 */ 3, /*  67 */ 2, /*  68 */ 3, /*  69 */
sl@0
   812
      3, /*  70 */ 4, /*  71 */ 2, /*  72 */ 3, /*  73 */ 3, /*  74 */
sl@0
   813
      4, /*  75 */ 3, /*  76 */ 4, /*  77 */ 4, /*  78 */ 5, /*  79 */
sl@0
   814
      2, /*  80 */ 3, /*  81 */ 3, /*  82 */ 4, /*  83 */ 3, /*  84 */
sl@0
   815
      4, /*  85 */ 4, /*  86 */ 5, /*  87 */ 3, /*  88 */ 4, /*  89 */
sl@0
   816
      4, /*  90 */ 5, /*  91 */ 4, /*  92 */ 5, /*  93 */ 5, /*  94 */
sl@0
   817
      6, /*  95 */ 2, /*  96 */ 3, /*  97 */ 3, /*  98 */ 4, /*  99 */
sl@0
   818
      3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */
sl@0
   819
      4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */
sl@0
   820
      5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */
sl@0
   821
      5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */
sl@0
   822
      4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */
sl@0
   823
      6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */
sl@0
   824
      2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */
sl@0
   825
      4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */
sl@0
   826
      3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */
sl@0
   827
      3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */
sl@0
   828
      4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */
sl@0
   829
      5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */
sl@0
   830
      2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */
sl@0
   831
      4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */
sl@0
   832
      4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */
sl@0
   833
      6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */
sl@0
   834
      4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */
sl@0
   835
      5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */
sl@0
   836
      6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */
sl@0
   837
      4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */
sl@0
   838
      3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */
sl@0
   839
      5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */
sl@0
   840
      4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */
sl@0
   841
      6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */
sl@0
   842
      5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */
sl@0
   843
      4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */
sl@0
   844
      5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */
sl@0
   845
      6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */
sl@0
   846
      4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */
sl@0
   847
      6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */
sl@0
   848
      6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */
sl@0
   849
      8  /* 255 */
sl@0
   850
    }; // end _Bit_count
sl@0
   851
sl@0
   852
    template <bool dummy>
sl@0
   853
    unsigned char first_bit_location<dummy>::value[] = {
sl@0
   854
      0, /*   0 */ 0, /*   1 */ 1, /*   2 */ 0, /*   3 */ 2, /*   4 */
sl@0
   855
      0, /*   5 */ 1, /*   6 */ 0, /*   7 */ 3, /*   8 */ 0, /*   9 */
sl@0
   856
      1, /*  10 */ 0, /*  11 */ 2, /*  12 */ 0, /*  13 */ 1, /*  14 */
sl@0
   857
      0, /*  15 */ 4, /*  16 */ 0, /*  17 */ 1, /*  18 */ 0, /*  19 */
sl@0
   858
      2, /*  20 */ 0, /*  21 */ 1, /*  22 */ 0, /*  23 */ 3, /*  24 */
sl@0
   859
      0, /*  25 */ 1, /*  26 */ 0, /*  27 */ 2, /*  28 */ 0, /*  29 */
sl@0
   860
      1, /*  30 */ 0, /*  31 */ 5, /*  32 */ 0, /*  33 */ 1, /*  34 */
sl@0
   861
      0, /*  35 */ 2, /*  36 */ 0, /*  37 */ 1, /*  38 */ 0, /*  39 */
sl@0
   862
      3, /*  40 */ 0, /*  41 */ 1, /*  42 */ 0, /*  43 */ 2, /*  44 */
sl@0
   863
      0, /*  45 */ 1, /*  46 */ 0, /*  47 */ 4, /*  48 */ 0, /*  49 */
sl@0
   864
      1, /*  50 */ 0, /*  51 */ 2, /*  52 */ 0, /*  53 */ 1, /*  54 */
sl@0
   865
      0, /*  55 */ 3, /*  56 */ 0, /*  57 */ 1, /*  58 */ 0, /*  59 */
sl@0
   866
      2, /*  60 */ 0, /*  61 */ 1, /*  62 */ 0, /*  63 */ 6, /*  64 */
sl@0
   867
      0, /*  65 */ 1, /*  66 */ 0, /*  67 */ 2, /*  68 */ 0, /*  69 */
sl@0
   868
      1, /*  70 */ 0, /*  71 */ 3, /*  72 */ 0, /*  73 */ 1, /*  74 */
sl@0
   869
      0, /*  75 */ 2, /*  76 */ 0, /*  77 */ 1, /*  78 */ 0, /*  79 */
sl@0
   870
      4, /*  80 */ 0, /*  81 */ 1, /*  82 */ 0, /*  83 */ 2, /*  84 */
sl@0
   871
      0, /*  85 */ 1, /*  86 */ 0, /*  87 */ 3, /*  88 */ 0, /*  89 */
sl@0
   872
      1, /*  90 */ 0, /*  91 */ 2, /*  92 */ 0, /*  93 */ 1, /*  94 */
sl@0
   873
      0, /*  95 */ 5, /*  96 */ 0, /*  97 */ 1, /*  98 */ 0, /*  99 */
sl@0
   874
      2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */
sl@0
   875
      0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */
sl@0
   876
      1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */
sl@0
   877
      0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */
sl@0
   878
      3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */
sl@0
   879
      0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */
sl@0
   880
      1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */
sl@0
   881
      0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */
sl@0
   882
      2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */
sl@0
   883
      0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */
sl@0
   884
      1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */
sl@0
   885
      0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */
sl@0
   886
      5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */
sl@0
   887
      0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */
sl@0
   888
      1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */
sl@0
   889
      0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */
sl@0
   890
      2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */
sl@0
   891
      0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */
sl@0
   892
      1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */
sl@0
   893
      0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */
sl@0
   894
      3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */
sl@0
   895
      0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */
sl@0
   896
      1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */
sl@0
   897
      0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */
sl@0
   898
      2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */
sl@0
   899
      0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */
sl@0
   900
      1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */
sl@0
   901
      0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */
sl@0
   902
      4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */
sl@0
   903
      0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */
sl@0
   904
      1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */
sl@0
   905
      0, /* 255 */
sl@0
   906
    }; // end _First_one
sl@0
   907
sl@0
   908
  } // namespace detail
sl@0
   909
sl@0
   910
} // namespace boost