aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/algorithm.hpp38
-rw-r--r--src/util/algorithm_impl.hpp67
-rw-r--r--src/util/ranges.hpp47
-rw-r--r--src/util/ranges_impl.hpp59
4 files changed, 0 insertions, 211 deletions
diff --git a/src/util/algorithm.hpp b/src/util/algorithm.hpp
deleted file mode 100644
index 60c68e2..0000000
--- a/src/util/algorithm.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-
-#include "util/concepts.hpp"
-
-#include <concepts>
-
-template <typename ContainerType, typename Value>
-requires Container<ContainerType>
-constexpr auto container_find(const ContainerType &container, const Value &value) noexcept
- -> typename ContainerType::const_iterator;
-
-template <typename ContainerType, typename Predicate>
-requires Container<ContainerType> &&
- std::predicate<Predicate, typename ContainerType::value_type>
-constexpr auto
-container_find(const ContainerType &container, Predicate predicate) noexcept ->
- typename ContainerType::const_iterator;
-
-template <typename ContainerType, typename Value>
-requires Container<ContainerType>
-constexpr auto container_has(const ContainerType &container, const Value &value) noexcept
- -> bool;
-
-template <typename ContainerType, typename Predicate>
-requires Container<ContainerType> && HasPushBack<ContainerType> &&
- std::predicate<Predicate, typename ContainerType::value_type>
-constexpr auto
-container_filter(const ContainerType &container, Predicate predicate) noexcept
- -> ContainerType;
-
-template <typename ContainerType, typename Predicate>
-requires Container<ContainerType> &&
- std::predicate<Predicate, typename ContainerType::value_type>
-constexpr auto
-container_filter(const ContainerType &container, Predicate predicate) noexcept
- -> ContainerType;
-
-#include "algorithm_impl.hpp"
diff --git a/src/util/algorithm_impl.hpp b/src/util/algorithm_impl.hpp
deleted file mode 100644
index d7c5e3b..0000000
--- a/src/util/algorithm_impl.hpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#pragma once
-
-#include "algorithm.hpp"
-
-#include <algorithm>
-
-template <typename ContainerType, typename Value>
-requires Container<ContainerType>
-constexpr auto container_find(const ContainerType &container, const Value &value) noexcept
- -> typename ContainerType::const_iterator
-{
- return std::find(container.begin(), container.end(), value);
-}
-
-template <typename ContainerType, typename Predicate>
-requires Container<ContainerType> &&
- std::predicate<Predicate, typename ContainerType::value_type>
-constexpr auto
-container_find(const ContainerType &container, Predicate predicate) noexcept ->
- typename ContainerType::const_iterator
-{
- return std::find_if(container.begin(), container.end(), predicate);
-}
-
-template <typename ContainerType, typename Value>
-requires Container<ContainerType>
-constexpr auto container_has(const ContainerType &container, const Value &value) noexcept
- -> bool
-{
- return container_find(container, value) != container.end();
-}
-
-template <typename ContainerType, typename Predicate>
-requires Container<ContainerType> && HasPushBack<ContainerType> &&
- std::predicate<Predicate, typename ContainerType::value_type>
-constexpr auto
-container_filter(const ContainerType &container, Predicate predicate) noexcept
- -> ContainerType
-{
- ContainerType filtered_container;
-
- std::copy_if(
- std::begin(container),
- std::end(container),
- std::back_inserter(filtered_container),
- predicate);
-
- return filtered_container;
-}
-
-template <typename ContainerType, typename Predicate>
-requires Container<ContainerType> &&
- std::predicate<Predicate, typename ContainerType::value_type>
-constexpr auto
-container_filter(const ContainerType &container, Predicate predicate) noexcept
- -> ContainerType
-{
- ContainerType filtered_container;
-
- std::copy_if(
- std::begin(container),
- std::end(container),
- std::inserter(filtered_container, filtered_container.begin()),
- predicate);
-
- return filtered_container;
-}
diff --git a/src/util/ranges.hpp b/src/util/ranges.hpp
deleted file mode 100644
index c47c7b5..0000000
--- a/src/util/ranges.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#pragma once
-
-#include <concepts>
-#include <iterator>
-
-template <std::weakly_incrementable Value>
-class IotaViewIterator
-{
-public:
- constexpr explicit IotaViewIterator(Value value) noexcept;
-
- constexpr auto operator++() noexcept -> const IotaViewIterator &;
- constexpr auto operator++(int) noexcept -> IotaViewIterator;
-
- constexpr auto operator*() const noexcept -> Value;
-
- constexpr auto operator==(const IotaViewIterator &rhs) const noexcept -> bool;
- constexpr auto operator!=(const IotaViewIterator &rhs) const noexcept -> bool;
-
-private:
- Value _value;
-};
-
-/**
- * A range factory that generates a sequence of elements by repeatedly incrementing an
- * initial value.
- *
- * This class was created because C++20 ranges is a complete shitshow in Clang.
- * https://github.com/llvm/llvm-project/issues/52696
- */
-template <std::weakly_incrementable Value, std::semiregular Bound>
-requires std::equality_comparable_with<Value, Bound> && std::copyable<Value>
-class IotaView
-{
-public:
- constexpr IotaView(Value value, Bound bound) noexcept;
-
- [[nodiscard]] constexpr auto begin() const noexcept -> IotaViewIterator<Value>;
-
- [[nodiscard]] constexpr auto end() const noexcept -> IotaViewIterator<Value>;
-
-private:
- Value _value;
- Bound _bound;
-};
-
-#include "ranges_impl.hpp"
diff --git a/src/util/ranges_impl.hpp b/src/util/ranges_impl.hpp
deleted file mode 100644
index 1f1a577..0000000
--- a/src/util/ranges_impl.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#pragma once
-
-#include "ranges.hpp"
-
-// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
-#define IOTA_VIEW_ITERATOR(return_type) \
- template <std::weakly_incrementable Value> \
- constexpr return_type IotaViewIterator<Value>
-
-IOTA_VIEW_ITERATOR()::IotaViewIterator(Value value) noexcept : _value(value) {}
-
-IOTA_VIEW_ITERATOR(auto)::operator++() noexcept -> const IotaViewIterator &
-{
- ++_value;
-
- return *this;
-}
-
-IOTA_VIEW_ITERATOR(auto)::operator++(int) noexcept -> IotaViewIterator
-{
- auto copy = *this;
-
- ++(*this);
-
- return copy;
-}
-
-IOTA_VIEW_ITERATOR(auto)::operator*() const noexcept -> Value
-{
- return _value;
-}
-
-IOTA_VIEW_ITERATOR(auto)::operator==(const IotaViewIterator &rhs) const noexcept -> bool
-{
- return _value == rhs._value;
-}
-
-IOTA_VIEW_ITERATOR(auto)::operator!=(const IotaViewIterator &rhs) const noexcept -> bool
-{
- return !(*this == rhs);
-}
-
-// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
-#define IOTA_VIEW(return_type) \
- template <std::weakly_incrementable Value, std::semiregular Bound> \
- requires std::equality_comparable_with<Value, Bound> && std::copyable<Value> \
- constexpr return_type IotaView<Value, Bound>
-
-IOTA_VIEW()::IotaView(Value value, Bound bound) noexcept : _value(value), _bound(bound) {}
-
-IOTA_VIEW(auto)::begin() const noexcept -> IotaViewIterator<Value>
-{
- return IotaViewIterator(_value);
-}
-
-IOTA_VIEW(auto)::end() const noexcept -> IotaViewIterator<Value>
-{
- return IotaViewIterator(_bound);
-}