Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions include/fast_io_dsal/impl/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,17 @@ class list
return const_reverse_iterator({__builtin_addressof(imp)});
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]] inline constexpr bool empty() const noexcept
{
return imp.next == __builtin_addressof(imp);
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]] inline constexpr bool is_empty() const noexcept
{
return imp.next == __builtin_addressof(imp);
Expand Down Expand Up @@ -908,9 +914,9 @@ class list

inline constexpr list(list &&other) noexcept
: imp(other.imp)
#if 0
#if 0
, allochdl(std::move(other.allochdl))
#endif
#endif
{
auto prev = static_cast<::fast_io::containers::details::list_node_common *>(imp.prev);
auto next = static_cast<::fast_io::containers::details::list_node_common *>(imp.next);
Expand All @@ -924,9 +930,9 @@ class list
{
this->destroy();
imp = other.imp;
#if 0
#if 0
allochdl = ::std::move(other.allochdl);
#endif
#endif
auto prev = static_cast<::fast_io::containers::details::list_node_common *>(imp.prev);
auto next = static_cast<::fast_io::containers::details::list_node_common *>(imp.next);
next->prev = prev->next = __builtin_addressof(imp);
Expand Down
13 changes: 13 additions & 0 deletions include/fast_io_dsal/impl/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class queue
return container.back_unchecked();
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr bool empty() const noexcept
{
if constexpr (requires() {
Expand All @@ -83,18 +87,27 @@ class queue
}
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr bool is_empty() const noexcept
{
return container.is_empty();
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr size_type size() const noexcept
requires(requires() {
container.size();
})
{
return container.size();
}

inline constexpr void push(value_type const &value)
{
container.push_back(value);
Expand Down
13 changes: 13 additions & 0 deletions include/fast_io_dsal/impl/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class stack
}
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr bool empty() const noexcept
{
if constexpr (requires() {
Expand All @@ -101,18 +105,27 @@ class stack
}
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr bool is_empty() const noexcept
{
return container.is_empty();
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr size_type size() const noexcept
requires(requires() {
container.size();
})
{
return container.size();
}

inline constexpr void push(value_type const &value)
{
if constexpr (requires() {
Expand Down
15 changes: 14 additions & 1 deletion include/fast_io_dsal/impl/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,33 @@ class basic_string FAST_IO_TRIVIALLY_RELOCATABLE_IF_ELIGIBLE
return imp.begin_ptr;
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr bool is_empty() const noexcept
{
return imp.begin_ptr == imp.curr_ptr;
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr bool empty() const noexcept
{
return imp.begin_ptr == imp.curr_ptr;
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]]
inline constexpr size_type size() const noexcept
{
return static_cast<size_type>(imp.curr_ptr - imp.begin_ptr);
}

inline constexpr size_type size_bytes() const noexcept
{
return static_cast<size_type>(imp.curr_ptr - imp.begin_ptr) * sizeof(value_type);
Expand Down Expand Up @@ -524,7 +537,7 @@ class basic_string FAST_IO_TRIVIALLY_RELOCATABLE_IF_ELIGIBLE
this->assign_impl(other.imp.begin_ptr, static_cast<::std::size_t>(other.imp.curr_ptr - other.imp.begin_ptr));
return *this;
}
inline constexpr basic_string& operator=(string_view_type const &other) noexcept
inline constexpr basic_string &operator=(string_view_type const &other) noexcept
{
this->assign(other);
return *this;
Expand Down
9 changes: 9 additions & 0 deletions include/fast_io_dsal/impl/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,25 @@ class basic_string_view
const_pointer ptr{};
size_type n{};

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]] inline constexpr bool is_empty() const noexcept
{
return !n;
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]] inline constexpr bool empty() const noexcept
{
return !n;
}

#if __has_cpp_attribute(__gnu__::__pure__)
[[__gnu__::__pure__]]
#endif
[[nodiscard]] inline constexpr size_type size() const noexcept
{
return n;
Expand Down