added allocator
This commit is contained in:
parent
02f42a0c3b
commit
4af2f6cedd
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Created by Patrick Maschek on 22.01.2024.
|
||||
//
|
||||
|
||||
#ifndef UDIFF_ALLOCATOR_H_
|
||||
#define UDIFF_ALLOCATOR_H_
|
||||
|
||||
#include <exception>
|
||||
#include <cstddef>
|
||||
|
||||
namespace cc {
|
||||
|
||||
template<typename T>
|
||||
class allocator {
|
||||
public:
|
||||
using value_type = T;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
[[nodiscard]] virtual constexpr T* allocate(size_type size) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
virtual constexpr void deallocate(T*, size_type) {}
|
||||
|
||||
[[nodiscard]] size_type max_size() { return 0; }
|
||||
};
|
||||
|
||||
using statically_allocated = allocator<void>;
|
||||
}
|
||||
|
||||
#endif //UDIFF_ALLOCATOR_H_
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#include <concepts>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include "allocator.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ namespace cc {
|
|||
constexpr _const_const_list_iterator operator--(int) & noexcept override { auto tmp = *this; _Base::_curr == _Base::_curr->_prev; return tmp; }
|
||||
};
|
||||
|
||||
template<typename N>
|
||||
template<typename N, typename Alloc = statically_allocated>
|
||||
requires std::derived_from<N, const_list_node>
|
||||
class const_list {
|
||||
|
||||
|
|
@ -214,35 +215,35 @@ namespace cc {
|
|||
template<std::input_iterator InputIt>
|
||||
const_list(InputIt, InputIt) -> const_list<typename std::iterator_traits<InputIt>::value_type>;
|
||||
|
||||
template<typename N1, typename N2>
|
||||
constexpr bool operator==(const const_list<N1>& lhs,
|
||||
const const_list<N2>& rhs)
|
||||
template<typename N1, typename N2, typename Alloc1, typename Alloc2>
|
||||
constexpr bool operator==(const const_list<N1, Alloc1>& lhs,
|
||||
const const_list<N2, Alloc2>& rhs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<typename N1, typename N2>
|
||||
constexpr auto operator<=>(const const_list<N1>& lhs,
|
||||
const const_list<N2>& rhs)
|
||||
template<typename N1, typename N2, typename Alloc1, typename Alloc2>
|
||||
constexpr auto operator<=>(const const_list<N1, Alloc1>& lhs,
|
||||
const const_list<N2, Alloc2>& rhs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<typename N>
|
||||
constexpr void swap(const const_list<N>& lhs,
|
||||
const const_list<N>& rhs)
|
||||
template<typename N, typename Alloc>
|
||||
constexpr void swap(const const_list<N, Alloc>& lhs,
|
||||
const const_list<N, Alloc>& rhs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<typename N>
|
||||
constexpr const_list<N>::size_type erase(const_list<N>& c, const N& value)
|
||||
template<typename N, typename Alloc>
|
||||
constexpr const_list<N>::size_type erase(const_list<N, Alloc>& c, const N& value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<typename N, typename Pred>
|
||||
constexpr const_list<N>::size_type erase(const_list<N>& c, Pred pred)
|
||||
template<typename N, typename Alloc, typename Pred>
|
||||
constexpr const_list<N>::size_type erase(const_list<N, Alloc>& c, Pred pred)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue