Commit 6c8fcda5 authored by Kenneth Moreland's avatar Kenneth Moreland Committed by Kitware Robot
Browse files

Merge topic 'safer-is-trivial'

80c1f0a9

 Be more conservative about is_trivial support
Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Larsen, Matthew's avatarMatt Larsen <larsen30@llnl.gov>
Merge-request: !2427
parents 8e70a7c5 80c1f0a9
......@@ -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
{
......
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