|
|
|
|
@@ -4,9 +4,9 @@
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* Disclaimer: Probably very bad implementation of some features of the C++
|
|
|
|
|
* Standard Library. Not meant as a full-on stdlib implementation, only for
|
|
|
|
|
* usage in this project (Underlined by the fact, that in this case the
|
|
|
|
|
* Disclaimer: Very bad (partially at least) implementation of some features of
|
|
|
|
|
* the C++ Standard Library. Not meant as a full-on stdlib implementation, only
|
|
|
|
|
* for usage in this project (Underlined by the fact, that in this case the
|
|
|
|
|
* namespace std is actually const_fmt::std)
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@@ -36,31 +36,105 @@ using size_t = uint16_t;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
struct remove_reference {
|
|
|
|
|
using type = T;
|
|
|
|
|
};
|
|
|
|
|
template<typename T>
|
|
|
|
|
struct remove_reference<T &> {
|
|
|
|
|
using type = T;
|
|
|
|
|
};
|
|
|
|
|
template<typename T>
|
|
|
|
|
struct remove_reference<T &&> {
|
|
|
|
|
using type = T;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
using remove_reference_t = typename std::remove_reference<T>::type;
|
|
|
|
|
|
|
|
|
|
// clang-format on
|
|
|
|
|
// various
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constexpr inline bool is_constant_evaluated() noexcept {
|
|
|
|
|
return __builtin_is_constant_evaluated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct true_type {
|
|
|
|
|
constexpr static bool value = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct false_type {
|
|
|
|
|
constexpr static bool value = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// is_same
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename fist_t, typename second_t>
|
|
|
|
|
struct is_same : public false_type {};
|
|
|
|
|
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
struct is_same<type_t, type_t> : public true_type {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// is_one_of
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename...>
|
|
|
|
|
struct is_one_of;
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
struct is_one_of<type_t> {
|
|
|
|
|
constexpr static bool value = false;
|
|
|
|
|
};
|
|
|
|
|
template <typename type_t, typename first_t, typename... rest_t>
|
|
|
|
|
struct is_one_of<type_t, first_t, rest_t...> {
|
|
|
|
|
constexpr static bool value = std::is_same<type_t, first_t>::value ||
|
|
|
|
|
is_one_of<type_t, rest_t...>::value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// remove_x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
|
|
|
|
|
|
template <typename type_t> struct remove_cv { typedef type_t type; };
|
|
|
|
|
template <typename type_t> struct remove_cv<const type_t> { typedef type_t type; };
|
|
|
|
|
template <typename type_t> struct remove_cv<volatile type_t> { typedef type_t type; };
|
|
|
|
|
template <typename type_t> struct remove_cv<const volatile type_t> { typedef type_t type; };
|
|
|
|
|
|
|
|
|
|
template <typename type_t> struct remove_const { typedef type_t type; };
|
|
|
|
|
template <typename type_t> struct remove_const<const type_t> { typedef type_t type; };
|
|
|
|
|
|
|
|
|
|
template <typename type_t> struct remove_volatile { typedef type_t type; };
|
|
|
|
|
template <typename type_t> struct remove_volatile<volatile type_t> { typedef type_t type; };
|
|
|
|
|
|
|
|
|
|
template <typename type_t> struct remove_reference { using type = type_t; };
|
|
|
|
|
template <typename type_t> struct remove_reference<type_t &> { using type = type_t; };
|
|
|
|
|
template <typename type_t> struct remove_reference<type_t &&> { using type = type_t; };
|
|
|
|
|
|
|
|
|
|
template <typename type_t> using remove_reference_t = typename std::remove_reference<type_t>::type;
|
|
|
|
|
template <typename type_t> using remove_cv_t = typename std::remove_cv<type_t>::type;
|
|
|
|
|
template <typename type_t> using remove_const_t = typename std::remove_const<type_t>::type;
|
|
|
|
|
template <typename type_t> using remove_volatile_t = typename std::remove_volatile<type_t>::type;
|
|
|
|
|
|
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// is_integral
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
using is_integral =
|
|
|
|
|
is_one_of<remove_cv_t<type_t>, bool, char, signed char, unsigned char,
|
|
|
|
|
wchar_t, char16_t, char32_t, short, unsigned short, int,
|
|
|
|
|
unsigned int, long, unsigned long, long long, unsigned long long>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// is_signed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename _Tp>
|
|
|
|
|
using is_signed_integer = is_one_of<remove_cv_t<_Tp>, signed char, signed short,
|
|
|
|
|
signed int, signed long, signed long long>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// is_floating_point
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
using is_floating_point =
|
|
|
|
|
is_one_of<remove_cv_t<type_t>, float, double, long double>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// make_unsigned
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
|
|
|
|
|
|
@@ -75,6 +149,16 @@ template <> struct make_unsigned<signed long long> { using type = unsigned long
|
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// value definitions
|
|
|
|
|
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
inline constexpr bool is_integral_v = is_integral<type_t>::value;
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
inline constexpr bool is_signed_integer_v = is_signed_integer<type_t>::value;
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
inline constexpr bool is_floating_point_v = is_floating_point<type_t>::value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* concepts
|
|
|
|
|
@@ -82,17 +166,17 @@ template <> struct make_unsigned<signed long long> { using type = unsigned long
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//template <typename _Tp>
|
|
|
|
|
//concept integral = is_integral_v<_Tp>;
|
|
|
|
|
//
|
|
|
|
|
//template <typename _Tp>
|
|
|
|
|
//concept signed_integral = integral<_Tp> && is_signed_v<_Tp>;
|
|
|
|
|
//
|
|
|
|
|
//template <typename _Tp>
|
|
|
|
|
//concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;
|
|
|
|
|
//
|
|
|
|
|
//template <typename _Tp>
|
|
|
|
|
//concept floating_point = is_floating_point_v<_Tp>;
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
concept integral = is_integral_v<type_t>;
|
|
|
|
|
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
concept signed_integral = is_signed_integer_v<type_t>;
|
|
|
|
|
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
concept unsigned_integral = integral<type_t> && !signed_integral<type_t>;
|
|
|
|
|
|
|
|
|
|
template <typename type_t>
|
|
|
|
|
concept floating_point = is_floating_point_v<type_t>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
@@ -103,8 +187,11 @@ template <> struct make_unsigned<signed long long> { using type = unsigned long
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename input_t, typename output_t>
|
|
|
|
|
void copy(input_t* start, input_t* end, output_t* dest_start) {
|
|
|
|
|
memcpy(start, dest_start, end - start);
|
|
|
|
|
constexpr inline void copy(const input_t* start, const input_t* end,
|
|
|
|
|
output_t* dest_start) {
|
|
|
|
|
auto temp = start;
|
|
|
|
|
while (temp != end)
|
|
|
|
|
*(dest_start++) = *(temp++);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -121,7 +208,7 @@ std::remove_reference_t<T>&& move(T&& arg) noexcept {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
void swap(T& t1, T& t2) {
|
|
|
|
|
constexpr inline void swap(T& t1, T& t2) {
|
|
|
|
|
T temp = std::move(t1);
|
|
|
|
|
t1 = std::move(t2);
|
|
|
|
|
t2 = std::move(temp);
|
|
|
|
|
@@ -150,14 +237,11 @@ public:
|
|
|
|
|
static_assert(sizeof...(args) == t_size, "Invalid number of arguments");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr array() noexcept = default;
|
|
|
|
|
|
|
|
|
|
constexpr array(array&) = default;
|
|
|
|
|
|
|
|
|
|
constexpr array(array&&) = default;
|
|
|
|
|
|
|
|
|
|
constexpr array& operator=(array& other) = default;
|
|
|
|
|
constexpr array() noexcept = default;
|
|
|
|
|
constexpr array(const array&) = default;
|
|
|
|
|
constexpr array(array&&) = default;
|
|
|
|
|
|
|
|
|
|
constexpr array& operator=(const array& other) = default;
|
|
|
|
|
constexpr array& operator=(array&& other) = default;
|
|
|
|
|
|
|
|
|
|
constexpr void swap(array<data_t, t_size>& other) noexcept {
|
|
|
|
|
@@ -167,6 +251,9 @@ public:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr std::size_t size() const noexcept {
|
|
|
|
|
return t_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr data_t& operator[](std::size_t index) noexcept {
|
|
|
|
|
return m_data[index];
|
|
|
|
|
@@ -188,6 +275,14 @@ public:
|
|
|
|
|
return (&(m_data[t_size - 1]) + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr const_iterator begin() const noexcept {
|
|
|
|
|
return &(m_data[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr const_iterator end() const noexcept {
|
|
|
|
|
return (&(m_data[t_size - 1]) + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr const_iterator cbegin() const noexcept {
|
|
|
|
|
return &(m_data[0]);
|
|
|
|
|
}
|
|
|
|
|
|