mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Refactor filesystem & stl code
This commit is contained in:
@ -42,12 +42,31 @@ namespace std
|
||||
return d_last;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void swap(T &a, T &b)
|
||||
template <typename InputIt, typename OutputIt, typename UnaryOperation>
|
||||
OutputIt transform(InputIt first, InputIt last, OutputIt result, UnaryOperation op)
|
||||
{
|
||||
T temp = move(a);
|
||||
a = move(b);
|
||||
b = move(temp);
|
||||
while (first != last)
|
||||
{
|
||||
*result = op(*first);
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void swap(T &a, T &b) noexcept(std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value)
|
||||
{
|
||||
T temp = std::move(a);
|
||||
a = std::move(b);
|
||||
b = std::move(temp);
|
||||
}
|
||||
|
||||
template <class T2, std::size_t N>
|
||||
void swap(T2 (&a)[N], T2 (&b)[N]) noexcept(std::is_nothrow_swappable_v<T2>)
|
||||
{
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
std::swap(a[i], b[i]);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -193,4 +212,116 @@ namespace std
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
template <class InputIt1, class InputIt2>
|
||||
constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2)
|
||||
{
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (!(*first1 == *first2))
|
||||
return false;
|
||||
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
|
||||
bool equal(ExecutionPolicy &&policy, ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2)
|
||||
{
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (!(*first1 == *first2))
|
||||
return false;
|
||||
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class InputIt1, class InputIt2, class BinaryPred>
|
||||
constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPred p)
|
||||
{
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (!p(*first1, *first2))
|
||||
return false;
|
||||
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class BinaryPred>
|
||||
bool equal(ExecutionPolicy &&policy, ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, BinaryPred p)
|
||||
{
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (!p(*first1, *first2))
|
||||
return false;
|
||||
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class InputIt1, class InputIt2>
|
||||
constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
|
||||
{
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (!(*first1 == *first2))
|
||||
return false;
|
||||
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
|
||||
bool equal(ExecutionPolicy &&policy, ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2)
|
||||
{
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (!(*first1 == *first2))
|
||||
return false;
|
||||
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class InputIt1, class InputIt2, class BinaryPred>
|
||||
constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPred p)
|
||||
{
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (!p(*first1, *first2))
|
||||
return false;
|
||||
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class BinaryPred>
|
||||
bool equal(ExecutionPolicy &&policy, ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2, BinaryPred p)
|
||||
{
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (!p(*first1, *first2))
|
||||
return false;
|
||||
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user