Skip to content
This repository was archived by the owner on Jun 15, 2025. It is now read-only.

Commit cc65df9

Browse files
committed
Removed conditional noexcept
Both GCC 6 and VS complain about the throw statement because of the "noexcept" specifier, even if the code flow matches the condition. Removed it for now.
1 parent bb68ad0 commit cc65df9

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

include/spsl/compat.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#define SPSL_HAS_NOEXCEPT
1414
#define SPSL_HAS_DEFAULT_MOVE
1515
#define SPSL_HAS_CONSTEXPR_ARRAY
16-
#define SPSL_NOEXCEPT_IF(cond) noexcept(cond)
1716

1817
#ifdef _MSC_VER // Windows + Visual Studio
1918

@@ -27,8 +26,6 @@ typedef intptr_t ssize_t;
2726
#define constexpr const
2827
#undef SPSL_HAS_NOEXCEPT
2928
#undef SPSL_HAS_DEFAULT_MOVE
30-
#undef SPSL_NOEXCEPT_IF
31-
#define SPSL_NOEXCEPT_IF(x)
3229
#endif
3330

3431
// can't use constexpr values in array definitions...

include/spsl/storage_array.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class StorageArray
5353
size_type length() const { return m_length; }
5454
size_type size() const { return m_length; }
5555
bool empty() const { return m_length == 0; }
56-
void reserve(size_type new_cap = 0) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
56+
void reserve(size_type new_cap = 0)
5757
{
5858
if (new_cap > max_size() && ThrowOnTruncate)
5959
throw std::length_error("requested capacity exceeds maximum");
@@ -107,15 +107,15 @@ class StorageArray
107107
char_type& operator[](size_type pos) { return m_buffer[pos]; }
108108
const char_type& operator[](size_type pos) const { return m_buffer[pos]; }
109109

110-
void assign(const char_type* s, size_type n) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
110+
void assign(const char_type* s, size_type n)
111111
{
112112
size_type len = std::min(n, max_size());
113113
if (len != n && ThrowOnTruncate)
114114
throw std::length_error("string length exceeds maximum capacity");
115115

116116
assign_nothrow(s, len);
117117
}
118-
void assign(size_type count, char_type ch) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
118+
void assign(size_type count, char_type ch)
119119
{
120120
size_type len = std::min(count, max_size());
121121
if (len != count && ThrowOnTruncate)
@@ -127,7 +127,7 @@ class StorageArray
127127
}
128128

129129
template <typename InputIt>
130-
void assign(InputIt first, InputIt last) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
130+
void assign(InputIt first, InputIt last)
131131
{
132132
// is there enough space?
133133
const size_type n = std::distance(first, last);
@@ -148,7 +148,7 @@ class StorageArray
148148
m_buffer[0] = nul;
149149
m_length = 0;
150150
}
151-
void push_back(char_type c) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
151+
void push_back(char_type c)
152152
{
153153
if (capacity_left())
154154
{
@@ -219,7 +219,7 @@ class StorageArray
219219
}
220220

221221

222-
void append(size_type count, char_type ch) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
222+
void append(size_type count, char_type ch)
223223
{
224224
// is there enough space?
225225
size_type appendCount = std::min(count, capacity_left());
@@ -231,7 +231,7 @@ class StorageArray
231231
m_buffer[m_length] = nul;
232232
}
233233

234-
void append(const char_type* s, size_type n) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
234+
void append(const char_type* s, size_type n)
235235
{
236236
// is there enough space?
237237
const size_type appendCount = std::min(n, capacity_left());
@@ -244,7 +244,7 @@ class StorageArray
244244
}
245245

246246
template <typename InputIt>
247-
void append(InputIt first, InputIt last) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
247+
void append(InputIt first, InputIt last)
248248
{
249249
// is there enough space?
250250
const size_type n = std::distance(first, last);
@@ -259,7 +259,7 @@ class StorageArray
259259
m_buffer[m_length] = nul;
260260
}
261261

262-
void resize(size_type count, char_type ch) SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
262+
void resize(size_type count, char_type ch)
263263
{
264264
if (count < size())
265265
{
@@ -278,7 +278,6 @@ class StorageArray
278278
}
279279

280280
void replace(size_type pos, size_type count, const char_type* cstr, size_type count2)
281-
SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
282281
{
283282
// simple implementation (avoid a lot of memmove's): create a new string and swap
284283
// => This is ok because there is no heap allocation, making this actually fast.
@@ -302,7 +301,6 @@ class StorageArray
302301
}
303302

304303
void replace(size_type pos, size_type count, size_type count2, char_type ch)
305-
SPSL_NOEXCEPT_IF(!ThrowOnTruncate)
306304
{
307305
// => same implementation as above
308306
this_type tmp;

0 commit comments

Comments
 (0)