#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 {
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];
}
{ 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 ();
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();
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
{ 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.