Compare commits
10 Commits
ea722ec5bf
...
feature/sm
| Author | SHA1 | Date | |
|---|---|---|---|
| 045363c733 | |||
| 4d05a9a8fa | |||
| ee1153c393 | |||
| b29695e148 | |||
| 86930fd8b0 | |||
| 7796be7cd4 | |||
| 73a50cae0f | |||
| 91398ef23d | |||
| b5ecd73b18 | |||
| 826f3a54b3 |
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Disclaimer: Probably very bad implementation of some features of the C++
|
* Disclaimer: Very bad (partially at least) implementation of some features of
|
||||||
* Standard Library. Not meant as a full-on stdlib implementation, only for
|
* the C++ Standard Library. Not meant as a full-on stdlib implementation, only
|
||||||
* usage in this project (Underlined by the fact, that in this case the
|
* for usage in this project (Underlined by the fact, that in this case the
|
||||||
* namespace std is actually const_fmt::std)
|
* namespace std is actually const_fmt::std)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -36,31 +36,105 @@ using size_t = uint16_t;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// clang-format off
|
// various
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
constexpr inline bool is_constant_evaluated() noexcept {
|
constexpr inline bool is_constant_evaluated() noexcept {
|
||||||
return __builtin_is_constant_evaluated();
|
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
|
// clang-format off
|
||||||
|
|
||||||
@@ -75,6 +149,16 @@ template <> struct make_unsigned<signed long long> { using type = unsigned long
|
|||||||
// clang-format on
|
// 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
|
* concepts
|
||||||
@@ -82,17 +166,17 @@ template <> struct make_unsigned<signed long long> { using type = unsigned long
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//template <typename _Tp>
|
template <typename type_t>
|
||||||
//concept integral = is_integral_v<_Tp>;
|
concept integral = is_integral_v<type_t>;
|
||||||
//
|
|
||||||
//template <typename _Tp>
|
template <typename type_t>
|
||||||
//concept signed_integral = integral<_Tp> && is_signed_v<_Tp>;
|
concept signed_integral = is_signed_integer_v<type_t>;
|
||||||
//
|
|
||||||
//template <typename _Tp>
|
template <typename type_t>
|
||||||
//concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;
|
concept unsigned_integral = integral<type_t> && !signed_integral<type_t>;
|
||||||
//
|
|
||||||
//template <typename _Tp>
|
template <typename type_t>
|
||||||
//concept floating_point = is_floating_point_v<_Tp>;
|
concept floating_point = is_floating_point_v<type_t>;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -103,8 +187,10 @@ template <> struct make_unsigned<signed long long> { using type = unsigned long
|
|||||||
|
|
||||||
|
|
||||||
template <typename input_t, typename output_t>
|
template <typename input_t, typename output_t>
|
||||||
void copy(input_t* start, input_t* end, output_t* dest_start) {
|
constexpr inline void copy(const input_t* start, const input_t* end, output_t* dest_start) {
|
||||||
memcpy(start, dest_start, end - start);
|
auto temp = start;
|
||||||
|
while (temp != end)
|
||||||
|
*(dest_start++) = *(temp++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,7 +207,7 @@ std::remove_reference_t<T>&& move(T&& arg) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void swap(T& t1, T& t2) {
|
constexpr inline void swap(T& t1, T& t2) {
|
||||||
T temp = std::move(t1);
|
T temp = std::move(t1);
|
||||||
t1 = std::move(t2);
|
t1 = std::move(t2);
|
||||||
t2 = std::move(temp);
|
t2 = std::move(temp);
|
||||||
@@ -151,13 +237,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr array() noexcept = default;
|
constexpr array() noexcept = default;
|
||||||
|
constexpr array(const array&) = default;
|
||||||
constexpr array(array&) = default;
|
|
||||||
|
|
||||||
constexpr array(array&&) = default;
|
constexpr array(array&&) = default;
|
||||||
|
|
||||||
constexpr array& operator=(array& other) = default;
|
constexpr array& operator=(const array& other) = default;
|
||||||
|
|
||||||
constexpr array& operator=(array&& other) = default;
|
constexpr array& operator=(array&& other) = default;
|
||||||
|
|
||||||
constexpr void swap(array<data_t, t_size>& other) noexcept {
|
constexpr void swap(array<data_t, t_size>& other) noexcept {
|
||||||
@@ -188,6 +271,14 @@ public:
|
|||||||
return (&(m_data[t_size - 1]) + 1);
|
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 {
|
constexpr const_iterator cbegin() const noexcept {
|
||||||
return &(m_data[0]);
|
return &(m_data[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user