Boost logo

Boost :

From: nbecker_at_[hidden]
Date: 2001-12-05 15:39:06


While you're at it, I'd like to see constant. Something like:

//! A function that just returns a constant value.
template<typename out_t>
class Constant : public unary_function<out_t, out_t>{
  const out_t val;
public:
  Constant (out_t _val) :
    val (_val) {}

  //! This version takes any input and just ignores it
  template<typename T>
  out_t operator() (T x) const {
    return val;
  }

  //! This version takes no input
  out_t operator() () const {
    return val;
  }
};


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