mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Be more conservative about is_trivial support
`std::is_trivial` is part of the C++14 specification. However, we have encountered multiple compilers that purport to implement C++14 but do not implement `std::is_trivial` and the like checks correctly. To avoid such issues, only use `std::is_trivial` on compilers that we have tested to support it.
This commit is contained in:
parent
8e70a7c55b
commit
80c1f0a974
@ -23,6 +23,8 @@
|
||||
#include <vtkm/TypeList.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkmstd/is_trivial.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace
|
||||
@ -63,7 +65,7 @@ template<typename T>
|
||||
void is_triv_noexcept_movable()
|
||||
{
|
||||
constexpr bool valid =
|
||||
#if !(defined(__GNUC__) && (__GNUC__ <= 5))
|
||||
#ifdef VTKM_USE_STD_IS_TRIVIAL
|
||||
//GCC 4.X and compilers that act like it such as Intel 17.0
|
||||
//don't have implementations for is_trivially_*
|
||||
std::is_trivially_move_constructible<T>::value &&
|
||||
|
@ -232,7 +232,7 @@ void TestIndexing()
|
||||
|
||||
void TestTriviallyCopyable()
|
||||
{
|
||||
#ifndef VTKM_USING_GLIBCXX_4
|
||||
#ifdef VTKM_USE_STD_IS_TRIVIAL
|
||||
// Make sure base types are behaving as expected
|
||||
VTKM_STATIC_ASSERT(std::is_trivially_constructible<float>::value);
|
||||
VTKM_STATIC_ASSERT(std::is_trivially_copyable<float>::value);
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <vtkmstd/is_trivial.h>
|
||||
|
||||
#include <vtkm/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
@ -135,8 +137,11 @@ void PairTest()
|
||||
|
||||
// Pair types should preserve the trivial properties of their components.
|
||||
// This insures that algorithms like std::copy will optimize fully.
|
||||
VTKM_TEST_ASSERT(std::is_trivial<T>::value &&
|
||||
std::is_trivial<U>::value == std::is_trivial<P>::value,
|
||||
// (Note, if std::is_trivial is not supported by the compiler, then
|
||||
// vtkmstd::is_trivial will always report false, but VTKM_IS_TRIVIAL will
|
||||
// always succeed.)
|
||||
VTKM_IS_TRIVIAL(T);
|
||||
VTKM_TEST_ASSERT(vtkmstd::is_trivial<U>::value == vtkmstd::is_trivial<P>::value,
|
||||
"PairType's triviality differs from ComponentTypes.");
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <vtkmstd/is_trivial.h>
|
||||
|
||||
#include <vtkm/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
@ -315,7 +317,7 @@ void GeneralVecTypeTest(const vtkm::Vec<ComponentType, Size>&)
|
||||
|
||||
// Vector types should preserve the trivial properties of their components.
|
||||
// This insures that algorithms like std::copy will optimize fully.
|
||||
VTKM_TEST_ASSERT(std::is_trivial<ComponentType>::value == std::is_trivial<T>::value,
|
||||
VTKM_TEST_ASSERT(vtkmstd::is_trivial<ComponentType>::value == vtkmstd::is_trivial<T>::value,
|
||||
"VectorType's triviality differs from ComponentType.");
|
||||
|
||||
VTKM_TEST_ASSERT(T::NUM_COMPONENTS == Size, "NUM_COMPONENTS is wrong size.");
|
||||
|
@ -11,10 +11,17 @@
|
||||
#define vtk_m_std_is_trivial_h
|
||||
|
||||
#include <vtkm/StaticAssert.h>
|
||||
#include <vtkm/internal/Configure.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#if defined(VTKM_USING_GLIBCXX_4)
|
||||
#if defined(VTKM_GCC) && !defined(VTKM_USING_GLIBCXX_4)
|
||||
#define VTKM_USE_STD_IS_TRIVIAL
|
||||
#elif defined(VTKM_CLANG)
|
||||
#define VTKM_USE_STD_IS_TRIVIAL
|
||||
#endif
|
||||
|
||||
#ifndef VTKM_USE_STD_IS_TRIVIAL
|
||||
namespace vtkmstd
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user