Skip to content

Commit d0feb3d

Browse files
John WellbeloveJohn Wellbelove
authored andcommitted
Added and fixed noexcept attributes
Added ETL_NOEXCEPT_FROM to set noexcept attributes based on an object or function. # Conflicts: # include/etl/platform.h
1 parent b90bcaa commit d0feb3d

File tree

8 files changed

+143
-142
lines changed

8 files changed

+143
-142
lines changed

include/etl/array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ namespace etl
397397
/// Swaps the contents of this array and another.
398398
///\param other A reference to the other array.
399399
//*************************************************************************
400-
ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT
400+
ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT_FROM(ETL_OR_STD::swap(etl::declval<T&>(), etl::declval<T&>()))
401401
{
402402
using ETL_OR_STD::swap; // Allow ADL
403403

include/etl/array_view.h

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ namespace etl
123123
//*************************************************************************
124124
/// Default constructor.
125125
//*************************************************************************
126-
ETL_CONSTEXPR array_view()
126+
ETL_CONSTEXPR array_view() ETL_NOEXCEPT
127127
: mbegin(ETL_NULLPTR),
128128
mend(ETL_NULLPTR)
129129
{
@@ -238,7 +238,7 @@ namespace etl
238238
/// Construct from iterators
239239
//*************************************************************************
240240
template <typename TIterator>
241-
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_)
241+
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) ETL_NOEXCEPT
242242
: mbegin(etl::to_address(begin_)),
243243
mend(etl::to_address(begin_) + etl::distance(begin_, end_))
244244
{
@@ -249,7 +249,7 @@ namespace etl
249249
//*************************************************************************
250250
template <typename TIterator,
251251
typename TSize>
252-
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_)
252+
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_) ETL_NOEXCEPT
253253
: mbegin(etl::to_address(begin_)),
254254
mend(etl::to_address(begin_) + size_)
255255
{
@@ -259,7 +259,7 @@ namespace etl
259259
/// Construct from C array
260260
//*************************************************************************
261261
template<size_t Array_Size>
262-
ETL_CONSTEXPR array_view(T(&begin_)[Array_Size])
262+
ETL_CONSTEXPR array_view(T(&begin_)[Array_Size]) ETL_NOEXCEPT
263263
: mbegin(begin_),
264264
mend(begin_ + Array_Size)
265265
{
@@ -268,7 +268,7 @@ namespace etl
268268
//*************************************************************************
269269
/// Copy constructor
270270
//*************************************************************************
271-
ETL_CONSTEXPR array_view(const array_view& other)
271+
ETL_CONSTEXPR array_view(const array_view& other) ETL_NOEXCEPT
272272
: mbegin(other.mbegin),
273273
mend(other.mend)
274274
{
@@ -309,143 +309,143 @@ namespace etl
309309
//*************************************************************************
310310
/// Returns a pointer to the first element of the internal storage.
311311
//*************************************************************************
312-
pointer data()
312+
pointer data() ETL_NOEXCEPT
313313
{
314314
return mbegin;
315315
}
316316

317317
//*************************************************************************
318318
/// Returns a const pointer to the first element of the internal storage.
319319
//*************************************************************************
320-
const_pointer data() const
320+
const_pointer data() const ETL_NOEXCEPT
321321
{
322322
return mbegin;
323323
}
324324

325325
//*************************************************************************
326326
/// Returns an iterator to the beginning of the array.
327327
//*************************************************************************
328-
iterator begin()
328+
iterator begin() ETL_NOEXCEPT
329329
{
330330
return mbegin;
331331
}
332332

333333
//*************************************************************************
334334
/// Returns a const iterator to the beginning of the array.
335335
//*************************************************************************
336-
const_iterator begin() const
336+
const_iterator begin() const ETL_NOEXCEPT
337337
{
338338
return mbegin;
339339
}
340340

341341
//*************************************************************************
342342
/// Returns a const iterator to the beginning of the array.
343343
//*************************************************************************
344-
const_iterator cbegin() const
344+
const_iterator cbegin() const ETL_NOEXCEPT
345345
{
346346
return mbegin;
347347
}
348348

349349
//*************************************************************************
350350
/// Returns an iterator to the end of the array.
351351
//*************************************************************************
352-
iterator end()
352+
iterator end() ETL_NOEXCEPT
353353
{
354354
return mend;
355355
}
356356

357357
//*************************************************************************
358358
/// Returns a const iterator to the end of the array.
359359
//*************************************************************************
360-
const_iterator end() const
360+
const_iterator end() const ETL_NOEXCEPT
361361
{
362362
return mend;
363363
}
364364

365365
//*************************************************************************
366366
// Returns a const iterator to the end of the array.
367367
//*************************************************************************
368-
const_iterator cend() const
368+
const_iterator cend() const ETL_NOEXCEPT
369369
{
370370
return mend;
371371
}
372372

373373
//*************************************************************************
374374
// Returns an reverse iterator to the reverse beginning of the array.
375375
//*************************************************************************
376-
reverse_iterator rbegin()
376+
reverse_iterator rbegin() ETL_NOEXCEPT
377377
{
378378
return reverse_iterator(mend);
379379
}
380380

381381
//*************************************************************************
382382
/// Returns a const reverse iterator to the reverse beginning of the array.
383383
//*************************************************************************
384-
const_reverse_iterator rbegin() const
384+
const_reverse_iterator rbegin() const ETL_NOEXCEPT
385385
{
386386
return const_reverse_iterator(mend);
387387
}
388388

389389
//*************************************************************************
390390
/// Returns a const reverse iterator to the reverse beginning of the array.
391391
//*************************************************************************
392-
const_reverse_iterator crbegin() const
392+
const_reverse_iterator crbegin() const ETL_NOEXCEPT
393393
{
394394
return const_reverse_iterator(mend);
395395
}
396396

397397
//*************************************************************************
398398
/// Returns a reverse iterator to the end of the array.
399399
//*************************************************************************
400-
reverse_iterator rend()
400+
reverse_iterator rend() ETL_NOEXCEPT
401401
{
402402
return reverse_iterator(mbegin);
403403
}
404404

405405
//*************************************************************************
406406
/// Returns a const reverse iterator to the end of the array.
407407
//*************************************************************************
408-
const_reverse_iterator rend() const
408+
const_reverse_iterator rend() const ETL_NOEXCEPT
409409
{
410410
return const_reverse_iterator(mbegin);
411411
}
412412

413413
//*************************************************************************
414414
/// Returns a const reverse iterator to the end of the array.
415415
//*************************************************************************
416-
const_reverse_iterator crend() const
416+
const_reverse_iterator crend() const ETL_NOEXCEPT
417417
{
418418
return const_reverse_iterator(mbegin);
419419
}
420420

421421
//*************************************************************************
422422
/// Returns <b>true</b> if the array size is zero.
423423
//*************************************************************************
424-
ETL_CONSTEXPR bool empty() const
424+
ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
425425
{
426426
return (mbegin == mend);
427427
}
428428

429429
//*************************************************************************
430430
/// Returns the size of the array.
431431
//*************************************************************************
432-
ETL_CONSTEXPR size_t size() const
432+
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
433433
{
434434
return static_cast<size_t>(mend - mbegin);
435435
}
436436

437437
//*************************************************************************
438438
/// Returns the maximum possible size of the array.
439439
//*************************************************************************
440-
ETL_CONSTEXPR size_t max_size() const
440+
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
441441
{
442442
return size();
443443
}
444444

445445
//*************************************************************************
446446
/// Assign from a view.
447447
//*************************************************************************
448-
array_view& operator=(const array_view& other)
448+
array_view& operator=(const array_view& other) ETL_NOEXCEPT
449449
{
450450
mbegin = other.mbegin;
451451
mend = other.mend;
@@ -477,7 +477,7 @@ namespace etl
477477
//*************************************************************************
478478
/// Returns a reference to the indexed value.
479479
//*************************************************************************
480-
reference operator[](const size_t i)
480+
reference operator[](const size_t i) ETL_NOEXCEPT
481481
{
482482
return mbegin[i];
483483
}
@@ -486,7 +486,7 @@ namespace etl
486486
//*************************************************************************
487487
/// Returns a const reference to the indexed value.
488488
//*************************************************************************
489-
const_reference operator[](const size_t i) const
489+
const_reference operator[](const size_t i) const ETL_NOEXCEPT
490490
{
491491
return mbegin[i];
492492
}
@@ -516,7 +516,7 @@ namespace etl
516516
//*************************************************************************
517517
/// Swaps with another array_view.
518518
//*************************************************************************
519-
void swap(array_view& other)
519+
void swap(array_view& other) ETL_NOEXCEPT
520520
{
521521
using ETL_OR_STD::swap; // Allow ADL
522522

@@ -527,7 +527,7 @@ namespace etl
527527
//*************************************************************************
528528
/// Shrinks the view by moving its start forward.
529529
//*************************************************************************
530-
void remove_prefix(const size_type n)
530+
void remove_prefix(const size_type n) ETL_NOEXCEPT
531531
{
532532
if (n < size())
533533
mbegin += n;
@@ -538,7 +538,7 @@ namespace etl
538538
//*************************************************************************
539539
/// Shrinks the view by moving its end backward.
540540
//*************************************************************************
541-
void remove_suffix(const size_type n)
541+
void remove_suffix(const size_type n) ETL_NOEXCEPT
542542
{
543543
if (n < size())
544544
mend -= n;
@@ -647,7 +647,7 @@ namespace etl
647647
/// Swaps the values.
648648
//*************************************************************************
649649
template <typename T>
650-
void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs)
650+
void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs) ETL_NOEXCEPT
651651
{
652652
lhs.swap(rhs);
653653
}

0 commit comments

Comments
 (0)