util/IterableSplitString: add noexcept
This commit is contained in:
parent
0f4bf5569a
commit
aadd32c973
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2013-2022 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -27,8 +27,7 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ITERABLE_SPLIT_STRING_HXX
|
||||
#define ITERABLE_SPLIT_STRING_HXX
|
||||
#pragma once
|
||||
|
||||
#include "StringView.hxx"
|
||||
|
||||
@ -53,7 +52,7 @@ class BasicIterableSplitString {
|
||||
|
||||
public:
|
||||
constexpr BasicIterableSplitString(StringView _s,
|
||||
value_type _separator)
|
||||
value_type _separator) noexcept
|
||||
:s(_s), separator(_separator) {}
|
||||
|
||||
class Iterator final {
|
||||
@ -63,15 +62,17 @@ public:
|
||||
|
||||
value_type separator;
|
||||
|
||||
Iterator(StringView _s, value_type _separator)
|
||||
:rest(_s), separator(_separator) {
|
||||
constexpr Iterator(StringView _s,
|
||||
value_type _separator) noexcept
|
||||
:rest(_s), separator(_separator)
|
||||
{
|
||||
Next();
|
||||
}
|
||||
|
||||
constexpr Iterator(std::nullptr_t n)
|
||||
constexpr Iterator(std::nullptr_t n) noexcept
|
||||
:current(n), rest(n), separator(0) {}
|
||||
|
||||
void Next() {
|
||||
constexpr void Next() noexcept {
|
||||
if (rest == nullptr)
|
||||
current = nullptr;
|
||||
else {
|
||||
@ -91,24 +92,24 @@ public:
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
Iterator &operator++() {
|
||||
constexpr Iterator &operator++() noexcept{
|
||||
Next();
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bool operator==(Iterator other) const {
|
||||
constexpr bool operator==(Iterator other) const noexcept {
|
||||
return current.data == other.current.data;
|
||||
}
|
||||
|
||||
constexpr bool operator!=(Iterator other) const {
|
||||
constexpr bool operator!=(Iterator other) const noexcept {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
constexpr StringView operator*() const {
|
||||
constexpr StringView operator*() const noexcept {
|
||||
return current;
|
||||
}
|
||||
|
||||
constexpr const StringView *operator->() const {
|
||||
constexpr const StringView *operator->() const noexcept {
|
||||
return ¤t;
|
||||
}
|
||||
};
|
||||
@ -116,11 +117,11 @@ public:
|
||||
using iterator = Iterator;
|
||||
using const_iterator = Iterator;
|
||||
|
||||
const_iterator begin() const {
|
||||
constexpr const_iterator begin() const noexcept {
|
||||
return {s, separator};
|
||||
}
|
||||
|
||||
constexpr const_iterator end() const {
|
||||
constexpr const_iterator end() const noexcept {
|
||||
return {nullptr};
|
||||
}
|
||||
};
|
||||
@ -133,5 +134,3 @@ using TIterableSplitString = WIterableSplitString;
|
||||
#else
|
||||
using TIterableSplitString = IterableSplitString;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user