]> www.ginac.de Git - cln.git/blobdiff - include/cln/SV.h
Finalize CLN 1.3.7 release.
[cln.git] / include / cln / SV.h
index 87845f18b0a8164fc938529c122782602f4cc466..e4e785ee1e8c80d0023b9a1d77c492c93b856eff 100644 (file)
@@ -5,8 +5,9 @@
 
 #include "cln/object.h"
 #include "cln/V.h"
-#include "cln/abort.h"
-#include <stdlib.h>
+#include "cln/exception.h"
+#include <cstdlib>
+#include <cstddef>
 
 namespace cln {
 
@@ -40,24 +41,24 @@ template <class T> class cl_SV_inner;
 template <class T>
 class cl_SV_inner {
 protected:
-       uintL len; // number of elements
+       std::size_t len; // number of elements
 private:
 //     T data[]; // the elements
        T * data() { return (T *) (this+1); }
        const T * data() const { return (const T *) (this+1); }
 public:
-       uintL length () const { return len; } // number of elements
+       std::size_t size() const { return len; } // number of elements
        const T & operator[] (unsigned long index) const
        {
                #ifndef CL_SV_NO_RANGECHECKS
-               if (!(index < length())) cl_abort();
+               if (!(index < size())) throw runtime_exception();
                #endif
                return data()[index];
        }
        T & operator[] (unsigned long index)
        {
                #ifndef CL_SV_NO_RANGECHECKS
-               if (!(index < length())) cl_abort();
+               if (!(index < size())) throw runtime_exception();
                #endif
                return data()[index];
        }
@@ -74,9 +75,29 @@ public:
        { return operator[]((unsigned long)index); }
        T & operator[] (int index)
        { return operator[]((unsigned long)index); }
+       #if long_bitsize < pointer_bitsize
+       const T & operator[] (unsigned long long index) const
+       {
+               #ifndef CL_SV_NO_RANGECHECKS
+               if (!(index < size())) throw runtime_exception();
+               #endif
+               return data()[index];
+       }
+       T & operator[] (unsigned long long index)
+       {
+               #ifndef CL_SV_NO_RANGECHECKS
+               if (!(index < size())) throw runtime_exception();
+               #endif
+               return data()[index];
+       }
+       const T & operator[] (long long index) const
+       { return operator[]((unsigned long long)index); }
+       T & operator[] (long long index)
+       { return operator[]((unsigned long long)index); }
+       #endif
 public: /* ugh */
        // Constructor.
-       cl_SV_inner (uintL l) : len (l) {}
+       cl_SV_inner (std::size_t l) : len (l) {}
 public:
        // Destructor.
        ~cl_SV_inner ();
@@ -95,7 +116,7 @@ private:
 template <class T>
 inline cl_SV_inner<T>::~cl_SV_inner ()
 {
-       uintL i = len;
+       std::size_t i = len;
        while (i > 0) {
                i--;
                data()[i].~T();
@@ -115,9 +136,9 @@ template <class T, class BASE>
 struct cl_SV : public BASE {
 public:
        // Length.
-       uintL length () const
+       std::size_t size() const
        {
-               return ((const cl_heap_SV<T> *) this->pointer)->v.length();
+               return ((const cl_heap_SV<T> *) this->pointer)->v.size();
        }
        // Reference. Forbid modification of `const cl_SV&' arguments.
        const T & operator[] (unsigned long index) const
@@ -141,6 +162,20 @@ public:
        { return operator[]((unsigned long)index); }
        T & operator[] (int index)
        { return operator[]((unsigned long)index); }
+       #if long_bitsize < pointer_bitsize
+       const T & operator[] (unsigned long long index) const
+       {
+               return ((const cl_heap_SV<T> *) this->pointer)->v[index];
+       }
+       T & operator[] (unsigned long long index)
+       {
+               return ((cl_heap_SV<T> *) this->pointer)->v[index];
+       }
+       const T & operator[] (long long index) const
+       { return operator[]((unsigned long long)index); }
+       T & operator[] (long long index)
+       { return operator[]((unsigned long long)index); }
+       #endif
        // Constructors.
        cl_SV (const cl_SV&);
        // Assignment operators.