Move the type_traits portability header into its own portability header
authorMichael Lee <mzlee@fb.com>
Wed, 17 Aug 2016 15:33:12 +0000 (08:33 -0700)
committerFacebook Github Bot 5 <facebook-github-bot-5-bot@fb.com>
Wed, 17 Aug 2016 15:38:27 +0000 (08:38 -0700)
Summary: Split up the big, all-inclusive Portability header a bit

Reviewed By: yfeldblum

Differential Revision: D3723253

fbshipit-source-id: a91c38775825626f3c13853ac8168daa078a169a

folly/Makefile.am
folly/Portability.h
folly/experimental/LockFreeRingBuffer.h
folly/portability/TypeTraits.h [new file with mode: 0644]
folly/small_vector.h
folly/test/small_vector_test.cpp

index b9d5424ad700d1a49ee58678ce4559354e754f76..0691344b705eec9a601886c75963148cf7da22ca 100644 (file)
@@ -296,6 +296,7 @@ nobase_follyinclude_HEADERS = \
        portability/SysTypes.h \
        portability/SysUio.h \
        portability/Time.h \
+       portability/TypeTraits.h \
        portability/Windows.h \
        portability/Unistd.h \
        Preprocessor.h \
index e6d06a4d2ebb4ba954b42fad712ad3eb538844f3..a780eedc08e7964fe5a0f3f4cd04fe4429bd68e8 100644 (file)
@@ -245,28 +245,6 @@ namespace std { typedef ::max_align_t max_align_t; }
 #include <folly/detail/FunctionalExcept.h>
 #endif
 
-#if defined(__cplusplus)
-// Unfortunately, boost::has_trivial_copy<T> is broken in libc++ due to its
-// usage of __has_trivial_copy(), so we can't use it as a
-// least-common-denominator for C++11 implementations that don't support
-// std::is_trivially_copyable<T>.
-//
-//      http://stackoverflow.com/questions/12754886/has-trivial-copy-behaves-differently-in-clang-and-gcc-whos-right
-//
-// As a result, use std::is_trivially_copyable() where it exists, and fall back
-// to Boost otherwise.
-#if FOLLY_HAVE_STD__IS_TRIVIALLY_COPYABLE
-#include <type_traits>
-#define FOLLY_IS_TRIVIALLY_COPYABLE(T)                   \
-  (std::is_trivially_copyable<T>::value)
-#else
-#include <boost/type_traits.hpp>
-#define FOLLY_IS_TRIVIALLY_COPYABLE(T)                   \
-  (boost::has_trivial_copy<T>::value &&                  \
-   boost::has_trivial_destructor<T>::value)
-#endif
-#endif // __cplusplus
-
 // MSVC specific defines
 // mainly for posix compat
 #ifdef _MSC_VER
index 5ca4a7d20cd88bf0104566116d4cdb5b1d5eea3b..1a2bc464c7c17bc2a16a481f11b787790794a7a0 100644 (file)
@@ -24,8 +24,9 @@
 #include <string.h>
 #include <type_traits>
 
-#include <folly/detail/TurnSequencer.h>
 #include <folly/Portability.h>
+#include <folly/detail/TurnSequencer.h>
+#include <folly/portability/TypeTraits.h>
 #include <folly/portability/Unistd.h>
 
 namespace folly {
diff --git a/folly/portability/TypeTraits.h b/folly/portability/TypeTraits.h
new file mode 100644 (file)
index 0000000..4ff82b1
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+// Unfortunately, boost::has_trivial_copy<T> is broken in libc++ due to its
+// usage of __has_trivial_copy(), so we can't use it as a
+// least-common-denominator for C++11 implementations that don't support
+// std::is_trivially_copyable<T>.
+//
+//      http://stackoverflow.com/questions/12754886/has-trivial-copy-behaves-differently-in-clang-and-gcc-whos-right
+//
+// As a result, use std::is_trivially_copyable() where it exists, and fall back
+// to Boost otherwise.
+#if FOLLY_HAVE_STD__IS_TRIVIALLY_COPYABLE
+#include <type_traits>
+#define FOLLY_IS_TRIVIALLY_COPYABLE(T) (std::is_trivially_copyable<T>::value)
+#else
+#include <boost/type_traits.hpp>
+#define FOLLY_IS_TRIVIALLY_COPYABLE(T) \
+  (boost::has_trivial_copy<T>::value && boost::has_trivial_destructor<T>::value)
+#endif
index da4547b40ae6712b12cf6d6ef90736cae1b9e4fb..3da912d2bd15a97aff553d43227ce463ccaf5e65 100644 (file)
@@ -49,6 +49,7 @@
 #include <folly/SmallLocks.h>
 #include <folly/portability/Constexpr.h>
 #include <folly/portability/Malloc.h>
+#include <folly/portability/TypeTraits.h>
 
 // Ignore shadowing warnings within this file, so includers can use -Wshadow.
 #pragma GCC diagnostic push
index 86f24fce933c2adc140730e899ac676c0f58d204..7e8c92db6676308c7edf24162cc12ca1c84692c3 100644 (file)
@@ -28,6 +28,7 @@
 #include <gtest/gtest.h>
 
 #include <folly/Conv.h>
+#include <folly/portability/TypeTraits.h>
 
 using folly::small_vector;
 using namespace folly::small_vector_policy;