Skip to content

Commit

Permalink
Add some debug assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Artsishevsky <polter.rnd@gmail.com>
  • Loading branch information
polter-rnd committed Nov 3, 2024
1 parent 8af009e commit 783a810
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/util/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include <algorithm> // IWYU pragma: keep
#include <cassert>
#include <cstddef>
#include <memory>
#include <type_traits>
Expand Down Expand Up @@ -365,6 +366,7 @@ class MemoryBuffer : public Buffer<T> {
*/
auto operator=(MemoryBuffer&& other) noexcept -> MemoryBuffer&
{
assert(this != &other);
deallocate();
move_from(other);
return *this;
Expand Down
2 changes: 2 additions & 0 deletions include/util/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#pragma once

#include <cassert>
#include <type_traits>

namespace PlainCloud::Util::Types {
Expand Down Expand Up @@ -90,6 +91,7 @@ using UnderlyingCharType = typename UnderlyingChar<T>::Type;
template<typename Int>
constexpr auto to_unsigned(Int value) -> std::make_unsigned_t<Int>
{
assert(std::is_unsigned<Int>::value || value >= 0);
return static_cast<std::make_unsigned_t<Int>>(value);
}

Expand Down

0 comments on commit 783a810

Please sign in to comment.