Remove constexpr from functions that assert
Assert gets in the way of constexpr. Removes constexpr from some
functions that have assert checks.
Bug: 246
Change-Id: I0c1d8f0db8ced91b8663bb0bb81f23fcbcf56e06
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/16162
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Armando Montanez <amontanez@google.com>
diff --git a/pw_kvs/public/pw_kvs/flash_memory.h b/pw_kvs/public/pw_kvs/flash_memory.h
index 6abf14a..83341ed 100644
--- a/pw_kvs/public/pw_kvs/flash_memory.h
+++ b/pw_kvs/public/pw_kvs/flash_memory.h
@@ -34,12 +34,14 @@
public:
// The flash address is in the range of: 0 to FlashSize.
typedef uint32_t Address;
- constexpr FlashMemory(size_t sector_size,
- size_t sector_count,
- size_t alignment,
- uint32_t start_address = 0,
- uint32_t sector_start = 0,
- std::byte erased_memory_content = std::byte{0xFF})
+
+ // TODO(pwbug/246): This can be constexpr when tokenized asserts are fixed.
+ FlashMemory(size_t sector_size,
+ size_t sector_count,
+ size_t alignment,
+ uint32_t start_address = 0,
+ uint32_t sector_start = 0,
+ std::byte erased_memory_content = std::byte{0xFF})
: sector_size_(sector_size),
flash_sector_count_(sector_count),
alignment_(alignment),
@@ -161,7 +163,8 @@
FlashPartition::Address address_;
};
- constexpr FlashPartition(
+ // TODO(pwbug/246): This can be constexpr when tokenized asserts are fixed.
+ FlashPartition(
FlashMemory* flash,
uint32_t start_sector_index,
uint32_t sector_count,
@@ -184,7 +187,8 @@
}
// Creates a FlashPartition that uses the entire flash with its alignment.
- constexpr FlashPartition(FlashMemory* flash)
+ // TODO(pwbug/246): This can be constexpr when tokenized asserts are fixed.
+ FlashPartition(FlashMemory* flash)
: FlashPartition(
flash, 0, flash->sector_count(), flash->alignment_bytes()) {}
diff --git a/pw_result/public/pw_result/result.h b/pw_result/public/pw_result/result.h
index 2cf8d48..60bcc05 100644
--- a/pw_result/public/pw_result/result.h
+++ b/pw_result/public/pw_result/result.h
@@ -33,12 +33,10 @@
constexpr Result(std::in_place_t, Args&&... args)
: value_(std::forward<Args>(args)...), status_(Status::OK) {}
- constexpr Result(Status status) : status_(status) {
- PW_CHECK(status_ != Status::OK);
- }
- constexpr Result(Status::Code code) : status_(code) {
- PW_CHECK(status_ != Status::OK);
- }
+ // TODO(pwbug/246): This can be constexpr when tokenized asserts are fixed.
+ Result(Status status) : status_(status) { PW_CHECK(status_ != Status::OK); }
+ // TODO(pwbug/246): This can be constexpr when tokenized asserts are fixed.
+ Result(Status::Code code) : status_(code) { PW_CHECK(status_ != Status::OK); }
constexpr Result(const Result&) = default;
constexpr Result& operator=(const Result&) = default;
@@ -49,17 +47,20 @@
constexpr Status status() const { return status_; }
constexpr bool ok() const { return status_.ok(); }
- constexpr T& value() & {
+ // TODO(pwbug/246): This can be constexpr when tokenized asserts are fixed.
+ T& value() & {
PW_CHECK_OK(status_);
return value_;
}
- constexpr const T& value() const& {
+ // TODO(pwbug/246): This can be constexpr when tokenized asserts are fixed.
+ const T& value() const& {
PW_CHECK_OK(status_);
return value_;
}
- constexpr T&& value() && {
+ // TODO(pwbug/246): This can be constexpr when tokenized asserts are fixed.
+ T&& value() && {
PW_CHECK_OK(status_);
return std::move(value_);
}