diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-09-03 11:05:27 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-09-03 11:05:27 +0000 |
commit | 8f71d7ed87007ace129f647b242a09d01773d3c5 (patch) | |
tree | 2c46ca9d89eb0ce5eea79ba1febb79e56efedb0f /library/cpp/yt/misc/unaligned-inl.h | |
parent | 78242bd5894abd6548e45731b464822da55a0796 (diff) | |
parent | 3da5a68ec3c329240e89bd0ed8c1c39e4359a693 (diff) | |
download | ydb-8f71d7ed87007ace129f647b242a09d01773d3c5.tar.gz |
Merge branch 'rightlib' into mergelibs-240903-1104
Diffstat (limited to 'library/cpp/yt/misc/unaligned-inl.h')
-rw-r--r-- | library/cpp/yt/misc/unaligned-inl.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/library/cpp/yt/misc/unaligned-inl.h b/library/cpp/yt/misc/unaligned-inl.h new file mode 100644 index 0000000000..68e1c9b499 --- /dev/null +++ b/library/cpp/yt/misc/unaligned-inl.h @@ -0,0 +1,31 @@ +#ifndef UNALIGNED_INL_H_ +#error "Direct inclusion of this file is not allowed, include unaligned.h" +// For the sake of sane code completion. +#include "unaligned.h" +#endif + +#include <cstring> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +template <class T> + requires std::is_trivial_v<T> +T UnalignedLoad(const T* ptr) +{ + T value; + std::memcpy(&value, ptr, sizeof(T)); + return value; +} + +template <class T> + requires std::is_trivial_v<T> +void UnalignedStore(T* ptr, const T& value) +{ + std::memcpy(ptr, &value, sizeof(T)); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT |