d6236499   
   From: jklowden@speakeasy.net   
      
   On Mon, 6 Feb 2012 15:59:30 -0800 (PST)   
   TomaszMikolajczyk wrote:   
      
   > template   
   > class Range   
   > {   
   > public:   
   > /// PRECONDITION: min <= max.   
   > Range(const T& min, const T& max) : _min(min), _max(max)   
   > {   
   > assert(min <= max);   
   > }   
   >   
   > template   
   > Range() : _min(min), _max(max)   
   > {   
   > static_assert(min <= max, "invalid range");   
   > }   
   >   
   > const T& getMin() const { return _min; }   
   > const T& getMax() const { return _max; }   
   > private:   
   > T _min, _max;   
   > };   
      
   Does this get you where you're going instead?   
      
   template   
   class Range   
   {   
   public:   
    Range();   
    ....   
   };   
      
   That allows min/max to be set at runtime or compile time in a   
   conventional way.   
      
   Note that T cannot be just any type. It can be integral or a pointer,   
   but not e.g. float.   
      
   --jkl   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|