2 * Copyright 2017 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 // Unfortunately, boost::has_trivial_copy<T> is broken in libc++ due to its
20 // usage of __has_trivial_copy(), so we can't use it as a
21 // least-common-denominator for C++11 implementations that don't support
22 // std::is_trivially_copyable<T>.
24 // http://stackoverflow.com/questions/12754886/has-trivial-copy-behaves-differently-in-clang-and-gcc-whos-right
26 // As a result, use std::is_trivially_copyable() where it exists, and fall back
27 // to Boost otherwise.
28 #if FOLLY_HAVE_STD__IS_TRIVIALLY_COPYABLE
29 #include <type_traits>
30 #define FOLLY_IS_TRIVIALLY_COPYABLE(T) (std::is_trivially_copyable<T>::value)
32 #include <boost/type_traits.hpp>
33 #define FOLLY_IS_TRIVIALLY_COPYABLE(T) \
34 (boost::has_trivial_copy<T>::value && boost::has_trivial_destructor<T>::value)