Commit 5c7e0242 authored by Michael Lee's avatar Michael Lee Committed by Facebook Github Bot 5

Move the type_traits portability header into its own portability header

Summary: Split up the big, all-inclusive Portability header a bit

Reviewed By: yfeldblum

Differential Revision: D3723253

fbshipit-source-id: a91c38775825626f3c13853ac8168daa078a169a
parent 9b8488e8
......@@ -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 \
......
......@@ -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
......
......@@ -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 {
......
/*
* 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
......@@ -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
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment