2022-11-16 10:28:39 +00:00
|
|
|
|
// ======= Copyright nillerusr, 2022 =======
|
|
|
|
|
|
|
|
|
|
// Helper аunctions for setting/сopying memory ( specially for non-POD types )
|
|
|
|
|
// FUCK STL
|
|
|
|
|
|
|
|
|
|
#ifndef MEMHELPERS_H
|
|
|
|
|
#define MEMHELPERS_H
|
|
|
|
|
|
|
|
|
|
namespace memutils
|
|
|
|
|
{
|
|
|
|
|
template<typename T>
|
|
|
|
|
inline void copy( T *dest, const T *src, size_t n )
|
|
|
|
|
{
|
2023-02-10 19:45:36 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
--n;
|
|
|
|
|
*(dest+n) = *(src+n);
|
|
|
|
|
} while( n );
|
2022-11-16 10:28:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
2023-02-10 19:45:36 +00:00
|
|
|
|
inline void set( T *dest, T value, size_t n )
|
2022-11-16 10:28:39 +00:00
|
|
|
|
{
|
2023-02-10 19:45:36 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
--n;
|
|
|
|
|
*(dest+n) = value;
|
|
|
|
|
} while( n );
|
2022-11-16 10:28:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif //MEMHELPERS_H
|