Skip to content

Commit bbf1b1f

Browse files
committed
constexpr + noexcept in array
1 parent 9a5e091 commit bbf1b1f

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/common/classes/array.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ class InlineStorage : public AutoStorage
4343
explicit InlineStorage(MemoryPool& p) : AutoStorage(p) { }
4444
InlineStorage() : AutoStorage() { }
4545
protected:
46-
T* getStorage()
46+
T* getStorage() noexcept
4747
{
4848
return buffer;
4949
}
50-
FB_SIZE_T getStorageSize() const
50+
FB_SIZE_T getStorageSize() const noexcept
5151
{
5252
return Capacity;
5353
}
@@ -63,8 +63,8 @@ class EmptyStorage : public AutoStorage
6363
explicit EmptyStorage(MemoryPool& p) : AutoStorage(p) { }
6464
EmptyStorage() : AutoStorage() { }
6565
protected:
66-
T* getStorage() { return NULL; }
67-
FB_SIZE_T getStorageSize() const { return 0; }
66+
T* getStorage() noexcept { return NULL; }
67+
FB_SIZE_T getStorageSize() const noexcept { return 0; }
6868
};
6969

7070
// Dynamic array of simple types
@@ -175,7 +175,7 @@ class Array : protected Storage
175175
return data[index];
176176
}
177177

178-
void freeData()
178+
void freeData() noexcept
179179
{
180180
// CVC: Warning, after this call, "data" is an invalid pointer, be sure to reassign it
181181
// or make it equal to this->getStorage()
@@ -219,9 +219,9 @@ class Array : protected Storage
219219
return *(data + count - 1);
220220
}
221221

222-
const T* begin() const { return data; }
222+
const T* begin() const noexcept { return data; }
223223

224-
const T* end() const { return data + count; }
224+
const T* end() const noexcept { return data + count; }
225225

226226
T& front()
227227
{
@@ -235,9 +235,9 @@ class Array : protected Storage
235235
return *(data + count - 1);
236236
}
237237

238-
T* begin() { return data; }
238+
T* begin() noexcept { return data; }
239239

240-
T* end() { return data + count; }
240+
T* end() noexcept { return data + count; }
241241

242242
void insert(const size_type index, const T& item)
243243
{
@@ -388,11 +388,11 @@ class Array : protected Storage
388388

389389
size_type getCount() const noexcept { return count; }
390390

391-
bool isEmpty() const { return count == 0; }
391+
bool isEmpty() const noexcept { return count == 0; }
392392

393-
bool hasData() const { return count != 0; }
393+
bool hasData() const noexcept { return count != 0; }
394394

395-
size_type getCapacity() const { return capacity; }
395+
size_type getCapacity() const noexcept { return capacity; }
396396

397397
void push(const T& item)
398398
{
@@ -541,9 +541,8 @@ class Array : protected Storage
541541
}
542542
};
543543

544-
const static int FB_ARRAY_SORT_MANUAL = 0;
545-
const static int FB_ARRAY_SORT_WHEN_ADD = 1;
546-
// const static int FB_ARRAY_SORT_ON_FIND
544+
static inline constexpr int FB_ARRAY_SORT_MANUAL = 0;
545+
static inline constexpr int FB_ARRAY_SORT_WHEN_ADD = 1;
547546

548547
// Dynamic sorted array of simple objects
549548
template <typename Value,

0 commit comments

Comments
 (0)