Commit d5f50c5a authored by Kenneth Moreland's avatar Kenneth Moreland Committed by Bolea Sanchez, Vicente Adolfo
Browse files

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



Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Maynard, Robert's avatarRobert Maynard <robert.maynard@kitware.com>
Merge-request: !1900
parent cb3d6e5c
...@@ -76,6 +76,37 @@ using std::is_trivially_copyable; ...@@ -76,6 +76,37 @@ using std::is_trivially_copyable;
} // namespace vtkmstd } // namespace vtkmstd
#endif #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 vtkm
{ {
namespace internal namespace internal
...@@ -118,45 +149,45 @@ struct AllTriviallyCopyable<> : std::true_type ...@@ -118,45 +149,45 @@ struct AllTriviallyCopyable<> : std::true_type
template <typename T0> template <typename T0>
struct AllTriviallyCopyable<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> template <typename T0, typename T1>
struct AllTriviallyCopyable<T0, T1> struct AllTriviallyCopyable<T0, T1>
: std::integral_constant<bool, : std::integral_constant<bool,
(std::is_trivially_copyable<T0>::value && (vtkmstd::is_trivially_copyable<T0>::value &&
std::is_trivially_copyable<T1>::value)> vtkmstd::is_trivially_copyable<T1>::value)>
{ {
}; };
template <typename T0, typename T1, typename T2> template <typename T0, typename T1, typename T2>
struct AllTriviallyCopyable<T0, T1, T2> struct AllTriviallyCopyable<T0, T1, T2>
: std::integral_constant<bool, : std::integral_constant<bool,
(std::is_trivially_copyable<T0>::value && (vtkmstd::is_trivially_copyable<T0>::value &&
std::is_trivially_copyable<T1>::value && vtkmstd::is_trivially_copyable<T1>::value &&
std::is_trivially_copyable<T2>::value)> vtkmstd::is_trivially_copyable<T2>::value)>
{ {
}; };
template <typename T0, typename T1, typename T2, typename T3> template <typename T0, typename T1, typename T2, typename T3>
struct AllTriviallyCopyable<T0, T1, T2, T3> struct AllTriviallyCopyable<T0, T1, T2, T3>
: std::integral_constant<bool, : std::integral_constant<bool,
(std::is_trivially_copyable<T0>::value && (vtkmstd::is_trivially_copyable<T0>::value &&
std::is_trivially_copyable<T1>::value && vtkmstd::is_trivially_copyable<T1>::value &&
std::is_trivially_copyable<T2>::value && vtkmstd::is_trivially_copyable<T2>::value &&
std::is_trivially_copyable<T3>::value)> vtkmstd::is_trivially_copyable<T3>::value)>
{ {
}; };
template <typename T0, typename T1, typename T2, typename T3, typename T4, typename... Ts> template <typename T0, typename T1, typename T2, typename T3, typename T4, typename... Ts>
struct AllTriviallyCopyable<T0, T1, T2, T3, T4, Ts...> struct AllTriviallyCopyable<T0, T1, T2, T3, T4, Ts...>
: std::integral_constant<bool, : std::integral_constant<bool,
(std::is_trivially_copyable<T0>::value && (vtkmstd::is_trivially_copyable<T0>::value &&
std::is_trivially_copyable<T1>::value && vtkmstd::is_trivially_copyable<T1>::value &&
std::is_trivially_copyable<T2>::value && vtkmstd::is_trivially_copyable<T2>::value &&
std::is_trivially_copyable<T3>::value && vtkmstd::is_trivially_copyable<T3>::value &&
std::is_trivially_copyable<T4>::value && vtkmstd::is_trivially_copyable<T4>::value &&
AllTriviallyCopyable<Ts...>::value)> AllTriviallyCopyable<Ts...>::value)>
{ {
}; };
......
...@@ -63,6 +63,7 @@ void TestIndexing() ...@@ -63,6 +63,7 @@ void TestIndexing()
void TestTriviallyCopyable() void TestTriviallyCopyable()
{ {
#ifndef VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED
// Make sure base types are behaving as expected // Make sure base types are behaving as expected
VTKM_STATIC_ASSERT(std::is_trivially_copyable<float>::value); VTKM_STATIC_ASSERT(std::is_trivially_copyable<float>::value);
VTKM_STATIC_ASSERT(std::is_trivially_copyable<int>::value); VTKM_STATIC_ASSERT(std::is_trivially_copyable<int>::value);
...@@ -85,6 +86,7 @@ void TestTriviallyCopyable() ...@@ -85,6 +86,7 @@ void TestTriviallyCopyable()
vtkm::internal::Variant<float, std::shared_ptr<float>, int>>::value)); vtkm::internal::Variant<float, std::shared_ptr<float>, int>>::value));
VTKM_STATIC_ASSERT((!std::is_trivially_copyable< VTKM_STATIC_ASSERT((!std::is_trivially_copyable<
vtkm::internal::Variant<float, int, std::shared_ptr<float>>>::value)); vtkm::internal::Variant<float, int, std::shared_ptr<float>>>::value));
#endif // !VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED
} }
struct TestFunctor struct TestFunctor
...@@ -166,7 +168,9 @@ void TestCopyDestroy() ...@@ -166,7 +168,9 @@ void TestCopyDestroy()
CountConstructDestruct, CountConstructDestruct,
TypePlaceholder<2>, TypePlaceholder<2>,
TypePlaceholder<3>>; TypePlaceholder<3>>;
#ifndef VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED
VTKM_STATIC_ASSERT(!std::is_trivially_copyable<VariantType>::value); VTKM_STATIC_ASSERT(!std::is_trivially_copyable<VariantType>::value);
#endif // !VTKM_IS_TRIVIALLY_COPYABLE_NOT_SUPPORTED
vtkm::Id count = 0; vtkm::Id count = 0;
VariantType variant1 = CountConstructDestruct(&count); VariantType variant1 = CountConstructDestruct(&count);
......
Supports Markdown
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