You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.0 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. // Concrete class of double float numbers.
  2. #ifndef _CL_DFLOAT_CLASS_H
  3. #define _CL_DFLOAT_CLASS_H
  4. #include "cln/number.h"
  5. #include "cln/float_class.h"
  6. namespace cln {
  7. class cl_DF : public cl_F {
  8. public:
  9. // Default constructor.
  10. cl_DF ();
  11. // Assignment operators.
  12. cl_DF& operator= (const cl_DF&);
  13. // Optimization of method pointer_p().
  14. bool pointer_p() const
  15. { return true; }
  16. // Faster pointer_p() gives a faster copy constructor (but not destructor!!!).
  17. cl_DF (const cl_DF& x);
  18. // Constructors and assignment operators from C numeric types.
  19. cl_DF (const double);
  20. cl_DF& operator= (const double);
  21. // Other constructors.
  22. cl_DF (const char *);
  23. // Private constructor.
  24. cl_DF (cl_private_thing);
  25. cl_DF (struct cl_heap_dfloat *);
  26. // Private pointer manipulations.
  27. operator struct cl_heap_dfloat * () const;
  28. public: // Ability to place an object at a given address.
  29. void* operator new (size_t size) { return malloc_hook(size); }
  30. void* operator new (size_t size, void* ptr) { (void)size; return ptr; }
  31. void operator delete (void* ptr) { free_hook(ptr); }
  32. private:
  33. // Friend declarations. They are for the compiler. Just ignore them.
  34. };
  35. // Private constructors.
  36. inline cl_DF::cl_DF (cl_private_thing ptr) : cl_F (ptr) {}
  37. // The assignment operators:
  38. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_DF, cl_DF)
  39. // The default constructors.
  40. // Private pointer manipulations. Never throw away a `struct cl_heap_dfloat *'!
  41. inline cl_DF::operator struct cl_heap_dfloat * () const
  42. {
  43. struct cl_heap_dfloat * hpointer = (struct cl_heap_dfloat *) pointer;
  44. cl_inc_refcount(*this);
  45. return hpointer;
  46. }
  47. extern const cl_DF cl_DF_0;
  48. inline cl_DF::cl_DF ()
  49. : cl_F ((cl_private_thing) (struct cl_heap_dfloat *) cl_DF_0) {}
  50. CL_REQUIRE(cl_DF_globals)
  51. #if 0 // see cl_DF.h
  52. inline cl_DF::cl_DF (struct cl_heap_dfloat * ptr)
  53. : cl_F ((cl_private_thing) ptr) {}
  54. #endif
  55. // The copy constructors.
  56. CL_DEFINE_COPY_CONSTRUCTOR2(cl_DF,cl_F)
  57. // Constructors and assignment operators from C numeric types.
  58. CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_DF)
  59. } // namespace cln
  60. #endif /* _CL_DFLOAT_CLASS_H */