Skip to content

Commit c4a6095

Browse files
committed
More noexcept usage
1 parent a10be3f commit c4a6095

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

include/libhat/access.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace hat {
99

1010
template<typename MemberType, typename Base>
11-
auto& member_at(Base* ptr, std::integral auto offset) {
11+
auto& member_at(Base* ptr, std::integral auto offset) noexcept {
1212
using Ret = hat::constness_as_t<MemberType, Base>;
1313
return *reinterpret_cast<Ret*>(reinterpret_cast<std::uintptr_t>(ptr) + offset);
1414
}

include/libhat/defines.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <intrin.h>
1717

1818
namespace hat::detail {
19-
inline unsigned long bsf(unsigned long num) {
19+
inline unsigned long bsf(unsigned long num) noexcept {
2020
unsigned long offset;
2121
_BitScanForward(&offset, num);
2222
return offset;
@@ -59,7 +59,7 @@
5959
#else
6060
#include <cstdlib>
6161
namespace hat::detail {
62-
[[noreturn]] inline void unreachable_impl() {
62+
[[noreturn]] inline void unreachable_impl() noexcept {
6363
std::abort();
6464
}
6565
}

include/libhat/fixed_string.hpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,83 +26,83 @@ namespace hat {
2626
std::copy_n(str, N, value);
2727
}
2828

29-
[[nodiscard]] constexpr iterator begin() {
29+
[[nodiscard]] constexpr iterator begin() noexcept {
3030
return this->c_str();
3131
}
3232

33-
[[nodiscard]] constexpr iterator end() {
33+
[[nodiscard]] constexpr iterator end() noexcept {
3434
return this->begin() + this->size();
3535
}
3636

37-
[[nodiscard]] constexpr const_iterator begin() const {
37+
[[nodiscard]] constexpr const_iterator begin() const noexcept {
3838
return this->c_str();
3939
}
4040

41-
[[nodiscard]] constexpr const_iterator end() const {
41+
[[nodiscard]] constexpr const_iterator end() const noexcept {
4242
return this->begin() + this->size();
4343
}
4444

45-
[[nodiscard]] constexpr const_iterator cbegin() const {
45+
[[nodiscard]] constexpr const_iterator cbegin() const noexcept {
4646
return this->begin();
4747
}
4848

49-
[[nodiscard]] constexpr const_iterator cend() const {
49+
[[nodiscard]] constexpr const_iterator cend() const noexcept {
5050
return this->end();
5151
}
5252

53-
[[nodiscard]] constexpr reference operator[](size_t pos) {
53+
[[nodiscard]] constexpr reference operator[](size_t pos) noexcept {
5454
return this->value[pos];
5555
}
5656

57-
[[nodiscard]] constexpr reference at(size_t pos) {
57+
[[nodiscard]] constexpr reference at(size_t pos) noexcept {
5858
return this->value[pos];
5959
}
6060

61-
[[nodiscard]] constexpr const_reference operator[](size_t pos) const {
61+
[[nodiscard]] constexpr const_reference operator[](size_t pos) const noexcept {
6262
return this->value[pos];
6363
}
6464

65-
[[nodiscard]] constexpr const_reference at(size_t pos) const {
65+
[[nodiscard]] constexpr const_reference at(size_t pos) const noexcept {
6666
return this->value[pos];
6767
}
6868

69-
[[nodiscard]] constexpr reference front() {
69+
[[nodiscard]] constexpr reference front() noexcept {
7070
return this->value[0];
7171
}
7272

73-
[[nodiscard]] constexpr reference back() {
73+
[[nodiscard]] constexpr reference back() noexcept {
7474
return this->value[size() - 1];
7575
}
7676

77-
[[nodiscard]] constexpr const_reference front() const {
77+
[[nodiscard]] constexpr const_reference front() const noexcept {
7878
return this->value[0];
7979
}
8080

81-
[[nodiscard]] constexpr const_reference back() const {
81+
[[nodiscard]] constexpr const_reference back() const noexcept {
8282
return this->value[size() - 1];
8383
}
8484

85-
[[nodiscard]] constexpr pointer c_str() {
85+
[[nodiscard]] constexpr pointer c_str() noexcept {
8686
return static_cast<Char*>(this->value);
8787
}
8888

89-
[[nodiscard]] constexpr const_pointer c_str() const {
89+
[[nodiscard]] constexpr const_pointer c_str() const noexcept {
9090
return static_cast<const Char*>(this->value);
9191
}
9292

93-
[[nodiscard]] constexpr pointer data() {
93+
[[nodiscard]] constexpr pointer data() noexcept {
9494
return this->c_str();
9595
}
9696

97-
[[nodiscard]] constexpr const_pointer data() const {
97+
[[nodiscard]] constexpr const_pointer data() const noexcept {
9898
return this->c_str();
9999
}
100100

101-
[[nodiscard]] constexpr size_t size() const {
101+
[[nodiscard]] constexpr size_t size() const noexcept {
102102
return N;
103103
}
104104

105-
[[nodiscard]] constexpr bool empty() const {
105+
[[nodiscard]] constexpr bool empty() const noexcept {
106106
return this->size() == 0;
107107
}
108108

include/libhat/memory_protector.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ namespace hat {
1212
Execute = 0b100
1313
};
1414

15-
constexpr protection operator|(protection lhs, protection rhs) {
15+
constexpr protection operator|(protection lhs, protection rhs) noexcept {
1616
using U = std::underlying_type_t<protection>;
1717
return static_cast<protection>(static_cast<U>(lhs) | static_cast<U>(rhs));
1818
}
1919

20-
constexpr protection operator&(protection lhs, protection rhs) {
20+
constexpr protection operator&(protection lhs, protection rhs) noexcept {
2121
using U = std::underlying_type_t<protection>;
2222
return static_cast<protection>(static_cast<U>(lhs) & static_cast<U>(rhs));
2323
}
@@ -39,12 +39,12 @@ namespace hat {
3939
oldProtection(o.oldProtection),
4040
set(std::exchange(o.set, false)) {}
4141

42-
memory_protector& operator=(memory_protector&& o) noexcept = delete;
42+
memory_protector& operator=(memory_protector&& o) = delete;
4343
memory_protector(const memory_protector&) = delete;
4444
memory_protector& operator=(const memory_protector&) = delete;
4545

4646
/// Returns true if the memory protect operation was successful
47-
[[nodiscard]] bool is_set() const {
47+
[[nodiscard]] bool is_set() const noexcept {
4848
return this->set;
4949
}
5050

include/libhat/process.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace hat::process {
2121

2222
/// Returns the memory region for a named section
2323
[[nodiscard]] std::span<std::byte> get_section_data(std::string_view name) const;
24+
2425
private:
2526
explicit module(const uintptr_t baseAddress)
2627
: baseAddress(baseAddress) {}

0 commit comments

Comments
 (0)