Boost logo

Boost :

From: Neal D. Becker (nbecker_at_[hidden])
Date: 2004-01-14 07:34:27


Jeremy Maitin-Shepard wrote:

> You can avoid the problem by typedefing cache_type inside of
> operator() to Engine::result_type, and also declaring mask inside of
> operator().

Thanks for the suggestion, but it doesn't seem to work. I guess the problem
is the scope of the typedef is just operator(). Here is what happens
(gcc-3.3.2):

namespace boost {
  template <int width=1, class IntType=int>
  class pnseq_generator {
  public:
    typedef IntType result_type;
    typedef IntType input_type;

    explicit pnseq_generator() : count (0) {}

    template<class Engine>
    int operator() (Engine& eng) {
      typedef typename Engine::result_type cache_type;
      static const cache_type mask = ~(unsigned(-1) << width);

      if (count <= width-1) {
        cache = eng();
        count = std::min (std::numeric_limits<typename
Engine::result_type>::digits, std::numeric_limits<cache_type>::digits);
      }
      result_type bits = cache & mask;
      cache >>= width;
      count -= width;
      return bits;
    }

  private:
    int count;
    cache_type cache;
  };
}
../src/float/pnseq_generator.H:37: error: 'cache_type' is used as a type,
but
   is not defined as a type.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk