Skip to content

Commit

Permalink
add operator[] overload
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jul 19, 2011
1 parent f246e65 commit c22760a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/root/root.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


// Copyright (c) 1999-2010 by Digital Mars
// Copyright (c) 1999-2011 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
Expand All @@ -13,6 +13,9 @@

#include <stdlib.h>
#include <stdarg.h>
#ifdef DEBUG
#include <assert.h>
#endif

#if __DMC__
#pragma once
Expand Down Expand Up @@ -353,12 +356,20 @@ struct ArrayBase : Array
return (TYPE **)data;
}

void insert(unsigned index, TYPE *v)
TYPE*& operator[] (size_t index)
{
#ifdef DEBUG
assert(index < dim);
#endif
return ((TYPE **)data)[index];
}

void insert(size_t index, TYPE *v)
{
Array::insert(index, (void *)v);
}

void insert(unsigned index, ArrayBase *a)
void insert(size_t index, ArrayBase *a)
{
Array::insert(index, (Array *)a);
}
Expand Down

0 comments on commit c22760a

Please sign in to comment.