[ 
https://issues.apache.org/jira/browse/ARROW-2309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16400596#comment-16400596
 ] 

ASF GitHub Bot commented on ARROW-2309:
---------------------------------------

wesm closed pull request #1748: ARROW-2309: [C++] Use std::make_unsigned
URL: https://github.com/apache/arrow/pull/1748
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/cpp/src/arrow/util/bit-util.h b/cpp/src/arrow/util/bit-util.h
index aed3a0184..6649d45d3 100644
--- a/cpp/src/arrow/util/bit-util.h
+++ b/cpp/src/arrow/util/bit-util.h
@@ -55,6 +55,7 @@
 #include <cstdint>
 #include <limits>
 #include <memory>
+#include <type_traits>
 #include <vector>
 
 #include "arrow/util/macros.h"
@@ -68,34 +69,12 @@
 
 namespace arrow {
 
-// TODO(wesm): The source from Impala was depending on boost::make_unsigned
-//
-// We add a partial stub implementation here
-
 namespace detail {
 
-template <typename T>
-struct make_unsigned {};
-
-template <>
-struct make_unsigned<int8_t> {
-  typedef uint8_t type;
-};
-
-template <>
-struct make_unsigned<int16_t> {
-  typedef uint16_t type;
-};
-
-template <>
-struct make_unsigned<int32_t> {
-  typedef uint32_t type;
-};
-
-template <>
-struct make_unsigned<int64_t> {
-  typedef uint64_t type;
-};
+template <typename Integer>
+typename std::make_unsigned<Integer>::type as_unsigned(Integer x) {
+  return static_cast<typename std::make_unsigned<Integer>::type>(x);
+}
 
 }  // namespace detail
 
@@ -268,7 +247,7 @@ static inline int Popcount(uint64_t x) {
 template <typename T>
 static inline int PopcountSigned(T v) {
   // Converting to same-width unsigned then extending preserves the bit 
pattern.
-  return BitUtil::Popcount(static_cast<typename 
detail::make_unsigned<T>::type>(v));
+  return BitUtil::Popcount(detail::as_unsigned(v));
 }
 
 /// Returns the 'num_bits' least-significant bits of 'v'.
@@ -412,7 +391,7 @@ static inline T FromLittleEndian(T value) {
 template <typename T>
 static T ShiftRightLogical(T v, int shift) {
   // Conversion to unsigned ensures most significant bits always filled with 
0's
-  return static_cast<typename detail::make_unsigned<T>::type>(v) >> shift;
+  return detail::as_unsigned(v) >> shift;
 }
 
 void FillBitsFromBytes(const std::vector<uint8_t>& bytes, uint8_t* bits);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> [C++] Use std::make_unsigned
> ----------------------------
>
>                 Key: ARROW-2309
>                 URL: https://issues.apache.org/jira/browse/ARROW-2309
>             Project: Apache Arrow
>          Issue Type: Task
>          Components: C++
>    Affects Versions: 0.8.0
>            Reporter: Antoine Pitrou
>            Assignee: Antoine Pitrou
>            Priority: Trivial
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> {{arrow/util/bit-util.h}} has a reimplementation of {{boost::make_unsigned}}, 
> but we could simply use {{std::make_unsigned}}, which is C++11.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to