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

namespace boost {
  template <int width=1, class IntType=int>
  class pnseq_generator {
    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;

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

Boost list run by bdawes at, gregod at, cpdaniel at, john at