fork download
  1. #ifndef BOUNDED_H_INCLUDED_
  2. #define BOUNDED_H_INCLUDED_
  3.  
  4. template <class T, T lower, T upper>
  5. class bounded {
  6. T val;
  7.  
  8. T check(T v) {
  9. if (upper < v)
  10. return upper;
  11. else if (lower <= v)
  12. return v;
  13. else
  14. return lower;
  15. }
  16.  
  17. public:
  18. bounded(bounded const &o) : val(o.val) {}
  19.  
  20. bounded &operator=(T v) {
  21. val = check(v);
  22. return *this;
  23. }
  24.  
  25. bounded(T const &v=T()) {
  26. val = check(v);
  27. }
  28.  
  29. operator T() { return val; }
  30. };
  31.  
  32. #endif
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
stdout
Standard output is empty