You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2021/03/10 03:53:07 UTC

[datasketches-cpp] 01/02: moved templates to common place

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch unify_serialization
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git

commit 9aefce4ec7bed2eeed614300065cc9376485dedc
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Tue Mar 9 14:16:57 2021 -0800

    moved templates to common place
---
 common/include/common_defs.hpp     | 14 ++++++++++++++
 req/include/req_compactor_impl.hpp | 13 -------------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/common/include/common_defs.hpp b/common/include/common_defs.hpp
index ffb3f19..b4dceea 100644
--- a/common/include/common_defs.hpp
+++ b/common/include/common_defs.hpp
@@ -23,6 +23,7 @@
 #include <cstdint>
 #include <string>
 #include <memory>
+#include <iostream>
 
 namespace datasketches {
 
@@ -46,6 +47,19 @@ constexpr uint8_t lg_size_from_count(uint32_t n, double load_factor) {
   return log2(n) + ((n > static_cast<uint32_t>((1 << (log2(n) + 1)) * load_factor)) ? 2 : 1);
 }
 
+// stream helpers for integral types
+template<typename T>
+static inline T read(std::istream& is) {
+  T value;
+  is.read(reinterpret_cast<char*>(&value), sizeof(T));
+  return value;
+}
+
+template<typename T>
+static inline void write(std::ostream& os, T value) {
+  os.write(reinterpret_cast<const char*>(&value), sizeof(T));
+}
+
 } // namespace
 
 #endif // _COMMON_DEFS_HPP_
diff --git a/req/include/req_compactor_impl.hpp b/req/include/req_compactor_impl.hpp
index 63a7dcf..3d5cce0 100755
--- a/req/include/req_compactor_impl.hpp
+++ b/req/include/req_compactor_impl.hpp
@@ -309,19 +309,6 @@ void req_compactor<T, C, A>::promote_evens_or_odds(InIter from, InIter to, bool
   }
 }
 
-// helpers for integral types
-template<typename T>
-static inline T read(std::istream& is) {
-  T value;
-  is.read(reinterpret_cast<char*>(&value), sizeof(T));
-  return value;
-}
-
-template<typename T>
-static inline void write(std::ostream& os, T value) {
-  os.write(reinterpret_cast<const char*>(&value), sizeof(T));
-}
-
 // implementation for fixed-size arithmetic types (integral and floating point)
 template<typename T, typename C, typename A>
 template<typename S, typename TT, typename std::enable_if<std::is_arithmetic<TT>::value, int>::type>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org