Commit 3b7b21c8 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Do not use std::is_trivially_copyable on GCC 4.X

Although GCC 4.8 and 4.9 claim to be C++11 compliant, there are a few
C++11 features they do not support. One of these features is
std::is_trivially_copyable. So on these platforms, do not attempt to use
it. Instead, treat nothing as trivially copyable.
parent 291f3527
......@@ -67,6 +67,37 @@ using std::aligned_union;
#endif
// It would make sense to put this in its own header file.
#if (defined(VTKM_GCC) && (__GNUC__ == 4))
#define VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED 1
namespace vtkmstd
{
// GCC 4.8 and 4.9 claim to support C++11, but do not support std::is_trivially_copyable.
// There is no relyable way to get this information (since it has to come special from
// the compiler). For our purposes, we will report as nothing being trivially copyable,
// which causes us to call the constructors with everything. This should be fine unless
// some other part of the compiler is trying to check for trivial copies (perhaps nvcc
// on top of GCC 4.8).
template <typename>
struct is_trivially_copyable : std::false_type
{
};
} // namespace vtkmstd
#else // is_trivially_copyable supported
namespace vtkmstd
{
using std::is_trivially_copyable;
} // namespace vtkmstd
#endif // is_trivially_copyable supported
namespace vtkm
{
namespace internal
......@@ -109,45 +140,45 @@ struct AllTriviallyCopyable<> : std::true_type
template <typename T0>
struct AllTriviallyCopyable<T0>
: std::integral_constant<bool, (std::is_trivially_copyable<T0>::value)>
: std::integral_constant<bool, (vtkmstd::is_trivially_copyable<T0>::value)>
{
};
template <typename T0, typename T1>
struct AllTriviallyCopyable<T0, T1>
: std::integral_constant<bool,
(std::is_trivially_copyable<T0>::value &&
std::is_trivially_copyable<T1>::value)>
(vtkmstd::is_trivially_copyable<T0>::value &&
vtkmstd::is_trivially_copyable<T1>::value)>
{
};
template <typename T0, typename T1, typename T2>
struct AllTriviallyCopyable<T0, T1, T2>
: std::integral_constant<bool,
(std::is_trivially_copyable<T0>::value &&
std::is_trivially_copyable<T1>::value &&
std::is_trivially_copyable<T2>::value)>
(vtkmstd::is_trivially_copyable<T0>::value &&
vtkmstd::is_trivially_copyable<T1>::value &&
vtkmstd::is_trivially_copyable<T2>::value)>
{
};
template <typename T0, typename T1, typename T2, typename T3>
struct AllTriviallyCopyable<T0, T1, T2, T3>
: std::integral_constant<bool,
(std::is_trivially_copyable<T0>::value &&
std::is_trivially_copyable<T1>::value &&
std::is_trivially_copyable<T2>::value &&
std::is_trivially_copyable<T3>::value)>
(vtkmstd::is_trivially_copyable<T0>::value &&
vtkmstd::is_trivially_copyable<T1>::value &&
vtkmstd::is_trivially_copyable<T2>::value &&
vtkmstd::is_trivially_copyable<T3>::value)>
{
};
template <typename T0, typename T1, typename T2, typename T3, typename T4, typename... Ts>
struct AllTriviallyCopyable<T0, T1, T2, T3, T4, Ts...>
: std::integral_constant<bool,
(std::is_trivially_copyable<T0>::value &&
std::is_trivially_copyable<T1>::value &&
std::is_trivially_copyable<T2>::value &&
std::is_trivially_copyable<T3>::value &&
std::is_trivially_copyable<T4>::value &&
(vtkmstd::is_trivially_copyable<T0>::value &&
vtkmstd::is_trivially_copyable<T1>::value &&
vtkmstd::is_trivially_copyable<T2>::value &&
vtkmstd::is_trivially_copyable<T3>::value &&
vtkmstd::is_trivially_copyable<T4>::value &&
AllTriviallyCopyable<Ts...>::value)>
{
};
......
......@@ -63,6 +63,7 @@ void TestIndexing()
void TestTriviallyCopyable()
{
#ifndef VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED
// Make sure base types are behaving as expected
VTKM_STATIC_ASSERT(std::is_trivially_copyable<float>::value);
VTKM_STATIC_ASSERT(std::is_trivially_copyable<int>::value);
......@@ -85,6 +86,7 @@ void TestTriviallyCopyable()
vtkm::internal::Variant<float, std::shared_ptr<float>, int>>::value));
VTKM_STATIC_ASSERT((!std::is_trivially_copyable<
vtkm::internal::Variant<float, int, std::shared_ptr<float>>>::value));
#endif // !VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED
}
struct TestFunctor
......@@ -166,7 +168,9 @@ void TestCopyDestroy()
CountConstructDestruct,
TypePlaceholder<2>,
TypePlaceholder<3>>;
#ifndef VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED
VTKM_STATIC_ASSERT(!std::is_trivially_copyable<VariantType>::value);
#endif // !VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED
vtkm::Id count = 0;
VariantType variant1 = CountConstructDestruct(&count);
......
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