Compare commits

...

7 Commits

3 changed files with 448 additions and 19 deletions

46
include/CompileOptional.h Normal file
View File

@ -0,0 +1,46 @@
//
// Created by Patrick Maschek on 22.01.2024.
//
#ifndef CONST_CONTAINER_COMPILEOPTIONAL_H_
#define CONST_CONTAINER_COMPILEOPTIONAL_H_
#include <type_traits>
#include <initializer_list>
namespace cc {
template<typename T, bool Cond = false>
class CompileOptional {};
template<typename T>
class CompileOptional<T, false> {
public:
using defined = std::false_type;
using value_type = T;
constexpr CompileOptional() = default;
constexpr CompileOptional(const value_type& value) {}
template<typename ...Args>
constexpr CompileOptional(Args... args) {}
};
template<typename T>
class CompileOptional<T, true> {
public:
using defined = std::true_type;
using value_type = T;
constexpr CompileOptional() = default;
constexpr CompileOptional(const value_type& value) : _value(value) {}
constexpr CompileOptional(value_type&& value) : _value(value) {}
template<typename ...Args>
constexpr CompileOptional(Args... args) : _value( { std::forward<Args>(args)... } ) {}
constexpr operator T&() { return _value; }
private:
T _value;
};
}
#endif //CONST_CONTAINER_COMPILEOPTIONAL_H_

30
include/allocator.h Normal file
View File

@ -0,0 +1,30 @@
//
// 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_base {
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) = 0;
virtual constexpr void deallocate(T*, size_type) = 0;
[[nodiscard]] size_type max_size() = 0;
};
using statically_allocated = void;
}
#endif //UDIFF_ALLOCATOR_H_

View File

@ -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,39 +215,391 @@ 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)
{
return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
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)
{
return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
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)
{
lhs.swap(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, Alloc>::size_type erase(const_list<N, Alloc>& c, const N& value)
{
c.remove(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, Alloc>::size_type erase(const_list<N, Alloc>& c, Pred pred)
{
c.remove_if(pred);
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr
const_list<N, Alloc>::const_list(const_list::size_type count) noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr
const_list<N, Alloc>::const_list(const_list::size_type count, const value_type &value) noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<std::input_iterator InputIt>
constexpr const_list<N, Alloc>::const_list(InputIt first, InputIt last)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr
const_list<N, Alloc>::const_list(const const_list &other) noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr
const_list<N, Alloc>::const_list(const_list &&other) noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr
const_list<N, Alloc>::const_list(std::initializer_list<value_type> init) noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list<N, Alloc>::~const_list()
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list &
const_list<N, Alloc>::operator=(const const_list &other)
{
return <#initializer#>;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list &
const_list<N, Alloc>::operator=(const_list &&other)
{
return <#initializer#>;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list &
const_list<N, Alloc>::operator=(std::initializer_list<N> init)
{
return <#initializer#>;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::assign(const_list::size_type count, const value_type &value) noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<std::input_iterator InputIt>
constexpr void const_list<N, Alloc>::assign(InputIt first, InputIt last)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::assign(std::initializer_list<value_type> values)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>void const_list<N, Alloc>::clear() noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list::iterator
const_list<N, Alloc>::insert(const_list::const_iterator pos, const value_type &value)
{
return cc::const_list::iterator();
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list::iterator
const_list<N, Alloc>::insert(const_list::const_iterator pos, value_type &&value)
{
return cc::const_list::iterator();
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list::iterator
const_list<N, Alloc>::insert(const_list::const_iterator pos, const_list::size_type count, const value_type &value)
{
return cc::const_list::iterator();
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<std::input_iterator InputIt>
constexpr const_list::iterator
const_list<N, Alloc>::insert(const_list::const_iterator pos, InputIt first, InputIt last)
{
return cc::const_list::iterator();
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list::iterator
const_list<N, Alloc>::insert(const_list::const_iterator pos, std::initializer_list<value_type> values)
{
return cc::const_list::iterator();
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<typename... Args>
constexpr const_list::iterator const_list<N, Alloc>::emplace(const_list::const_iterator pos, Args &&... args)
{
return cc::const_list::iterator();
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list::iterator
const_list<N, Alloc>::erase(const_list::const_iterator pos)
{
return cc::const_list::iterator();
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list::iterator
const_list<N, Alloc>::erase(const_list::const_iterator first, const_list::const_iterator last)
{
return cc::const_list::iterator();
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::push_back(const value_type &value)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void const_list<N, Alloc>::push_back(value_type &&value)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<typename... Args>
constexpr reference const_list<N, Alloc>::emplace_back(Args &&... args)
{
return <#initializer#>;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void const_list<N, Alloc>::pop_back()
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::push_front(const value_type &value)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void const_list<N, Alloc>::push_front(value_type &&value)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<typename... Args>
constexpr reference const_list<N, Alloc>::emplace_front(Args &&... args)
{
return <#initializer#>;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void const_list<N, Alloc>::pop_front()
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::resize(const_list::size_type count)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::resize(const_list::size_type count, const value_type &value)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void const_list<N, Alloc>::swap(const_list &other) noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void const_list<N, Alloc>::merge(const_list &other)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void const_list<N, Alloc>::merge(const_list &&other)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<typename Compare>
constexpr void const_list<N, Alloc>::merge(const_list &other, Compare comp)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<typename Compare>
constexpr void const_list<N, Alloc>::merge(const_list &&other, Compare comp)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::splice(const_list::const_iterator pos, const_list &other)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::splice(const_list::const_iterator pos, const_list &&other)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::splice(const_list::const_iterator pos, const_list &other, const_list::const_iterator it)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::splice(const_list::const_iterator pos, const_list &&other, const_list::const_iterator it)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::splice(const_list::const_iterator pos, const_list &other, const_list::const_iterator first,
const_list::const_iterator last)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void
const_list<N, Alloc>::splice(const_list::const_iterator pos, const_list &&other, const_list::const_iterator first,
const_list::const_iterator last)
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr const_list::size_type
const_list<N, Alloc>::remove(const value_type &value)
{
return 0;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<typename UnaryPredicate>
const_list::size_type const_list<N, Alloc>::remove_if(UnaryPredicate p)
{
return 0;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>void const_list<N, Alloc>::reverse() noexcept
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>const_list::size_type const_list<N, Alloc>::unique()
{
return 0;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<typename BinaryPredicate>
constexpr const_list::size_type const_list<N, Alloc>::unique(BinaryPredicate p)
{
return 0;
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>constexpr void const_list<N, Alloc>::sort()
{
}
template<typename N, typename Alloc>
requires std::derived_from<N, const_list_node>
template<typename Compare>
void const_list<N, Alloc>::sort(Compare comp)
{
}
} // cc
#endif //UDIFF_CONST_LIST_H_