Skip to content

Commit 461cd19

Browse files
committed
remove BOOST_ASSERT from record_ref
1 parent 46094f5 commit 461cd19

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

include/jogasaki/api/record.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class record {
100100
}
101101

102102
protected:
103-
virtual void write_to(std::ostream& os) const noexcept = 0;
103+
virtual void write_to(std::ostream& os) const = 0;
104104
};
105105

106106
}

src/jogasaki/accessor/record_ref.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@
1616
#include "record_ref.h"
1717

1818
#include <jogasaki/constants.h>
19+
#include <jogasaki/utils/assert.h>
1920

2021
namespace jogasaki::accessor {
2122

2223

23-
bool record_ref::is_null(record_ref::offset_type nullity_offset) const noexcept {
24-
BOOST_ASSERT(nullity_offset / bits_per_byte < size_); //NOLINT
24+
bool record_ref::is_null(record_ref::offset_type nullity_offset) const {
25+
assert_with_exception(nullity_offset / bits_per_byte < size_, nullity_offset, size_);
2526
offset_type byte_offset = nullity_offset / bits_per_byte;
2627
offset_type offset_in_byte = nullity_offset % bits_per_byte;
2728
unsigned char bitmask = 1U << offset_in_byte;
2829
auto p = static_cast<unsigned char*>(data_) + byte_offset; //NOLINT
2930
return (*p & bitmask) != 0;
3031
}
3132

32-
void record_ref::set_null(record_ref::offset_type nullity_offset, bool nullity) noexcept {
33-
BOOST_ASSERT(nullity_offset / bits_per_byte < size_); //NOLINT
33+
void record_ref::set_null(record_ref::offset_type nullity_offset, bool nullity) {
34+
assert_with_exception(nullity_offset / bits_per_byte < size_, nullity_offset, size_);
3435
offset_type byte_offset = nullity_offset / bits_per_byte;
3536
offset_type offset_in_byte = nullity_offset % bits_per_byte;
3637
unsigned char bitmask = 1U << offset_in_byte;

src/jogasaki/accessor/record_ref.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
#include <cstring>
2020
#include <optional>
2121
#include <type_traits>
22-
#include <boost/assert.hpp>
23-
2422
#include <takatori/util/assertion.h>
2523

2624
#include <jogasaki/constants.h>
25+
#include <jogasaki/utils/assert.h>
2726

2827
namespace jogasaki::accessor {
2928

@@ -63,7 +62,7 @@ class record_ref {
6362
* @warning this function is meaningful only when the field is nullable.
6463
* For non-nullable field, the return value should not be used and ignored.
6564
*/
66-
[[nodiscard]] bool is_null(offset_type nullity_offset) const noexcept;
65+
[[nodiscard]] bool is_null(offset_type nullity_offset) const;
6766

6867
/**
6968
* @brief set nullity
@@ -75,7 +74,7 @@ class record_ref {
7574
* set beforehand, and this function sets nullity = true, then the value is ignored and the field
7675
* is handled as null.
7776
*/
78-
void set_null(offset_type nullity_offset, bool nullity = true) noexcept;
77+
void set_null(offset_type nullity_offset, bool nullity = true);
7978

8079
/**
8180
* @brief field value setter
@@ -87,7 +86,7 @@ class record_ref {
8786
*/
8887
template<typename T>
8988
void set_value(offset_type value_offset, T x) {
90-
BOOST_ASSERT(value_offset < size_); //NOLINT
89+
assert_with_exception(value_offset < size_, value_offset, size_);
9190
static_assert(std::is_trivially_copy_constructible_v<T>);
9291
std::memcpy( static_cast<char*>(data_) + value_offset, &x, sizeof(T)); //NOLINT
9392
}
@@ -103,7 +102,7 @@ class record_ref {
103102
*/
104103
template<typename T>
105104
[[nodiscard]] T get_value(offset_type value_offset) const {
106-
BOOST_ASSERT(value_offset < size_); //NOLINT
105+
assert_with_exception(value_offset < size_, value_offset, size_);
107106
static_assert(std::is_trivially_copy_constructible_v<T>);
108107
T data{};
109108
std::memcpy(&data, static_cast<char*>(data_) + value_offset, sizeof(T)); //NOLINT
@@ -121,7 +120,7 @@ class record_ref {
121120
*/
122121
template<typename T>
123122
[[nodiscard]] T const& get_reference(offset_type value_offset) const {
124-
BOOST_ASSERT(value_offset < size_); //NOLINT
123+
assert_with_exception(value_offset < size_, value_offset, size_);
125124
static_assert(std::is_trivially_copy_constructible_v<T>);
126125
return *reinterpret_cast<T const*>(static_cast<char*>(data_) + value_offset); //NOLINT
127126
}
@@ -135,8 +134,8 @@ class record_ref {
135134
*/
136135
template<typename T>
137136
[[nodiscard]] std::optional<T> get_if(offset_type nullity_offset, offset_type value_offset) const {
138-
BOOST_ASSERT(nullity_offset / bits_per_byte < size_); //NOLINT
139-
BOOST_ASSERT(value_offset < size_); //NOLINT
137+
assert_with_exception(nullity_offset / bits_per_byte < size_, nullity_offset, size_);
138+
assert_with_exception(value_offset < size_, value_offset, size_);
140139
if(is_null(nullity_offset)) {
141140
return {};
142141
}

src/jogasaki/api/impl/record.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void record::ref(accessor::record_ref r) noexcept {
9999
ref_ = r;
100100
}
101101

102-
void record::write_to(std::ostream& os) const noexcept {
102+
void record::write_to(std::ostream& os) const {
103103
os << ref_ << *meta_;
104104
}
105105

src/jogasaki/api/impl/record.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class record : public api::record {
9999

100100
[[nodiscard]] accessor::record_ref ref() const noexcept;
101101

102-
void write_to(std::ostream& os) const noexcept override;
102+
void write_to(std::ostream& os) const override;
103103

104104
private:
105105
accessor::record_ref ref_{};

src/jogasaki/executor/hash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class hash {
4646
* @param record the record to calculate the hash
4747
* @return hash of the record
4848
*/
49-
[[nodiscard]] hash_value operator()(accessor::record_ref const& record) const noexcept {
49+
[[nodiscard]] hash_value operator()(accessor::record_ref const& record) const {
5050
static const std::size_t p = 18446744073709551557ULL; // arbitrary prime in uint64_t
5151
hash_value h{};
5252
for(std::size_t i = 0, n = meta_->field_count(); i < n; ++i) {
@@ -61,7 +61,7 @@ class hash {
6161
* @param ptr the pointer to record data to calculate the hash
6262
* @return hash of the record
6363
*/
64-
[[nodiscard]] hash_value operator()(void* ptr) const noexcept {
64+
[[nodiscard]] hash_value operator()(void* ptr) const {
6565
return operator()(accessor::record_ref(ptr, meta_->record_size()));
6666
}
6767

0 commit comments

Comments
 (0)