Commit b15940c1 authored by Kenneth Moreland's avatar Kenneth Moreland

Declare new VTKM_STATIC_ASSERT

This is to be used in place of BOOST_STATIC_ASSERT so that we can
control its implementation.

The implementation is designed to fix the issue where the latest XCode
clang compiler gives a warning about a unused typedefs when the boost
static assert is used within a function. (This warning also happens when
using the C++11 static_assert keyword.) You can suppress this warning
with _Pragma commands, but _Pragma commands inside a block is not
supported in GCC. The implementation of VTKM_STATIC_ASSERT handles all
current cases.
parent 9b22a72d
......@@ -30,6 +30,7 @@ set(headers
Math.h
Matrix.h
Pair.h
StaticAssert.h
TopologyElementTag.h
TypeListTag.h
Types.h
......
......@@ -20,10 +20,10 @@
#ifndef vtk_m_CellShape_h
#define vtk_m_CellShape_h
#include <vtkm/StaticAssert.h>
#include <vtkm/Types.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
#include <boost/type_traits/integral_constant.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
......@@ -75,11 +75,9 @@ struct CellShapeTagCheck : boost::false_type { };
/// tag.
///
#define VTKM_IS_CELL_SHAPE_TAG(tag) \
VTKM_THIRDPARTY_PRE_INCLUDE \
BOOST_STATIC_ASSERT_MSG( \
VTKM_STATIC_ASSERT_MSG( \
::vtkm::internal::CellShapeTagCheck<tag>::value, \
"Provided type is not a valid VTK-m cell shape tag.") \
VTKM_THIRDPARTY_POST_INCLUDE
"Provided type is not a valid VTK-m cell shape tag.")
/// A traits-like class to get an CellShapeId known at compile time to a tag.
///
......
......@@ -22,10 +22,10 @@
#include <vtkm/internal/ListTagDetail.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/internal/ExportMacros.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_base_of.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
......@@ -48,11 +48,9 @@ struct ListTagCheck
/// code when a mistake is made.)
///
#define VTKM_IS_LIST_TAG(tag) \
VTKM_THIRDPARTY_PRE_INCLUDE \
BOOST_STATIC_ASSERT_MSG( \
VTKM_STATIC_ASSERT_MSG( \
::vtkm::internal::ListTagCheck<tag>::Valid, \
"Provided type is not a valid VTK-m list tag.") \
VTKM_THIRDPARTY_POST_INCLUDE
"Provided type is not a valid VTK-m list tag.")
namespace detail {
......
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_StaticAssert_h
#define vtk_m_StaticAssert_h
#include <vtkm/internal/Configure.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
// Newer versions of clang are causing the static assert to issue a warning
// about unused typedefs. In this case, we want to disable the warnings using
// pragmas. However, not all compiler support pragmas in code blocks (although
// fortunately clang does). Thus, only use these pragmas in the instance where
// we need it and know we can use it.
#if defined(VTKM_CLANG) && (__apple_build_version__ >= 7000072)
#define VTKM_STATIC_ASSERT(condition) \
VTKM_THIRDPARTY_PRE_INCLUDE \
BOOST_STATIC_ASSERT(condition) \
VTKM_THIRDPARTY_POST_INCLUDE
#define VTKM_STATIC_ASSERT_MSG(condition, message) \
VTKM_THIRDPARTY_PRE_INCLUDE \
BOOST_STATIC_ASSERT_MSG(condition, message) \
VTKM_THIRDPARTY_POST_INCLUDE
#else
#define VTKM_STATIC_ASSERT(condition) \
BOOST_STATIC_ASSERT(condition)
#define VTKM_STATIC_ASSERT_MSG(condition, message) \
BOOST_STATIC_ASSERT_MSG(condition, message)
#endif
#endif //vtk_m_StaticAssert_h
......@@ -24,14 +24,11 @@
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorControlInternal.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/VecTraits.h>
#include <vtkm/internal/FunctionInterface.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
#include <sstream>
namespace vtkm {
......@@ -181,7 +178,7 @@ public:
static const vtkm::IdComponent NUM_COMPONENTS =
vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
BOOST_STATIC_ASSERT(NUM_COMPONENTS == PortalTypes::ARITY);
VTKM_STATIC_ASSERT(NUM_COMPONENTS == PortalTypes::ARITY);
VTKM_EXEC_CONT_EXPORT
ArrayPortalCompositeVector() { }
......@@ -236,7 +233,7 @@ public:
// If you get a compile error here, it means you probably tried to create
// an ArrayHandleCompositeVector with a return type of a vector with a
// different number of components than the number of arrays given.
BOOST_STATIC_ASSERT(NUM_COMPONENTS == FunctionInterfaceArrays::ARITY);
VTKM_STATIC_ASSERT(NUM_COMPONENTS == FunctionInterfaceArrays::ARITY);
VTKM_CONT_EXPORT
ArrayPortalCompositeVectorCont() : NumberOfValues(0) { }
......
......@@ -20,6 +20,8 @@
#ifndef vtk_m_cont_CellSet_h
#define vtk_m_cont_CellSet_h
#include <vtkm/StaticAssert.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/Field.h>
#include <vtkm/cont/LogicalStructure.h>
......@@ -27,7 +29,6 @@
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_base_of.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
......@@ -95,9 +96,7 @@ struct CellSetCheck
};
#define VTKM_IS_CELL_SET(T) \
VTKM_THIRDPARTY_PRE_INCLUDE \
BOOST_STATIC_ASSERT(::vtkm::cont::internal::CellSetCheck<T>::type::value) \
VTKM_THIRDPARTY_POST_INCLUDE
VTKM_STATIC_ASSERT(::vtkm::cont::internal::CellSetCheck<T>::type::value)
} // namespace internal
......
......@@ -28,11 +28,9 @@
#define VTKM_STORAGE VTKM_STORAGE_BASIC
#endif
#include <vtkm/internal/ExportMacros.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
#include <vtkm/StaticAssert.h>
#include <vtkm/internal/ExportMacros.h>
namespace vtkm {
namespace cont {
......@@ -76,7 +74,7 @@ namespace detail {
// arguments.
template<typename T>
struct UndefinedArrayPortal {
BOOST_STATIC_ASSERT(sizeof(T) == static_cast<size_t>(-1));
VTKM_STATIC_ASSERT(sizeof(T) == static_cast<size_t>(-1));
};
} // namespace detail
......
......@@ -20,10 +20,10 @@
#ifndef vtk_m_cont_arg_ControlSignatureTagBase_h
#define vtk_m_cont_arg_ControlSignatureTagBase_h
#include <vtkm/StaticAssert.h>
#include <vtkm/internal/ExportMacros.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_base_of.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
......@@ -62,11 +62,9 @@ struct ControlSignatureTagCheck
/// get weird errors elsewhere in the code when a mistake is made.)
///
#define VTKM_IS_CONTROL_SIGNATURE_TAG(tag) \
VTKM_THIRDPARTY_PRE_INCLUDE \
BOOST_STATIC_ASSERT_MSG( \
VTKM_STATIC_ASSERT_MSG( \
::vtkm::cont::arg::internal::ControlSignatureTagCheck<tag>::Valid, \
"Provided a type that is not a valid ControlSignature tag.") \
VTKM_THIRDPARTY_POST_INCLUDE
"Provided a type that is not a valid ControlSignature tag.")
}
}
......
......@@ -20,15 +20,12 @@
#ifndef vtk_m_cont_internal_DeviceAdapterTag_h
#define vtk_m_cont_internal_DeviceAdapterTag_h
#include <vtkm/StaticAssert.h>
#include <vtkm/internal/Configure.h>
#include <vtkm/internal/ExportMacros.h>
#include <string>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
#define VTKM_DEVICE_ADAPTER_ERROR -2
#define VTKM_DEVICE_ADAPTER_UNDEFINED -1
#define VTKM_DEVICE_ADAPTER_SERIAL 1
......@@ -86,11 +83,9 @@ struct DeviceAdapterTagCheck
/// elsewhere in the code when a mistake is made.)
///
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag) \
VTKM_THIRDPARTY_PRE_INCLUDE \
BOOST_STATIC_ASSERT_MSG( \
VTKM_STATIC_ASSERT_MSG( \
::vtkm::cont::internal::DeviceAdapterTagCheck<tag>::Valid, \
"Provided type is not a valid VTK-m device adapter tag.") \
VTKM_THIRDPARTY_POST_INCLUDE
"Provided type is not a valid VTK-m device adapter tag.")
//-----------------------------------------------------------------------------
#if VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_SERIAL
......
......@@ -20,10 +20,10 @@
#ifndef vtk_m_cont_internal_PointCoordinatesBase_h
#define vtk_m_cont_internal_PointCoordinatesBase_h
#include <vtkm/StaticAssert.h>
#include <vtkm/Types.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_base_of.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
......@@ -32,7 +32,7 @@ VTKM_THIRDPARTY_POST_INCLUDE
/// argument is actually point coordinates. (You can get weird errors elsewhere
/// in the code when a mistake is made.)
#define VTKM_IS_POINT_COORDINATES(pctype) \
BOOST_STATIC_ASSERT_MSG( \
VTKM_STATIC_ASSERT_MSG( \
::vtkm::cont::internal::IsValidPointCoordinates<pctype>::type::value, \
"Provided type is not a valid VTK-m PointCoordinates type.")
......
......@@ -20,10 +20,10 @@
#ifndef vtk_m_exec_arg_ExecutionSignatureTagBase_h
#define vtk_m_exec_arg_ExecutionSignatureTagBase_h
#include <vtkm/StaticAssert.h>
#include <vtkm/internal/ExportMacros.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_base_of.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
......@@ -64,11 +64,9 @@ struct ExecutionSignatureTagCheck
/// get weird errors elsewhere in the code when a mistake is made.)
///
#define VTKM_IS_EXECUTION_SIGNATURE_TAG(tag) \
VTKM_THIRDPARTY_PRE_INCLUDE \
BOOST_STATIC_ASSERT_MSG( \
VTKM_STATIC_ASSERT_MSG( \
::vtkm::exec::arg::internal::ExecutionSignatureTagCheck<tag>::Valid, \
"Provided a type that is not a valid ExecutionSignature tag.") \
VTKM_THIRDPARTY_POST_INCLUDE
"Provided a type that is not a valid ExecutionSignature tag.")
}
}
......
......@@ -22,12 +22,13 @@
#include <vtkm/exec/arg/BasicArg.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/internal/FunctionInterface.h>
#include <vtkm/testing/Testing.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
......@@ -166,15 +167,15 @@ struct TestWorkletErrorProxy : vtkm::exec::FunctorBase
// Check behavior of InvocationToFetch helper class.
BOOST_STATIC_ASSERT(( boost::is_same<
VTKM_STATIC_ASSERT(( boost::is_same<
vtkm::exec::internal::detail::InvocationToFetch<InvocationType1,1>::type,
vtkm::exec::arg::Fetch<TestFetchTagInput,vtkm::exec::arg::AspectTagDefault,InvocationType1,1> >::type::value ));
BOOST_STATIC_ASSERT(( boost::is_same<
VTKM_STATIC_ASSERT(( boost::is_same<
vtkm::exec::internal::detail::InvocationToFetch<InvocationType1,2>::type,
vtkm::exec::arg::Fetch<TestFetchTagOutput,vtkm::exec::arg::AspectTagDefault,InvocationType1,2> >::type::value ));
BOOST_STATIC_ASSERT(( boost::is_same<
VTKM_STATIC_ASSERT(( boost::is_same<
vtkm::exec::internal::detail::InvocationToFetch<InvocationType2,0>::type,
vtkm::exec::arg::Fetch<TestFetchTagOutput,vtkm::exec::arg::AspectTagDefault,InvocationType2,2> >::type::value ));
......
......@@ -24,6 +24,7 @@
#include <vtkm/exec/internal/ErrorMessageBuffer.h>
#include <vtkm/CellTraits.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/VecVariable.h>
#include <vtkm/testing/Testing.h>
......@@ -76,9 +77,7 @@ void GetMinMaxPoints(CellShapeTag,
{
// If this line fails, then MAX_POINTS is not large enough to support all
// cell shapes.
VTKM_THIRDPARTY_PRE_INCLUDE
BOOST_STATIC_ASSERT((vtkm::CellTraits<CellShapeTag>::NUM_POINTS <= MAX_POINTS));
VTKM_THIRDPARTY_POST_INCLUDE
VTKM_STATIC_ASSERT((vtkm::CellTraits<CellShapeTag>::NUM_POINTS <= MAX_POINTS));
minPoints = maxPoints = vtkm::CellTraits<CellShapeTag>::NUM_POINTS;
}
......
......@@ -24,15 +24,12 @@
#include <vtkm/exec/internal/ErrorMessageBuffer.h>
#include <vtkm/CellTraits.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/VecRectilinearPointCoordinates.h>
#include <vtkm/VecVariable.h>
#include <vtkm/testing/Testing.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
namespace {
static const vtkm::IdComponent MAX_POINTS = 8;
......@@ -45,9 +42,7 @@ void GetMinMaxPoints(CellShapeTag,
{
// If this line fails, then MAX_POINTS is not large enough to support all
// cell shapes.
VTKM_THIRDPARTY_PRE_INCLUDE
BOOST_STATIC_ASSERT((vtkm::CellTraits<CellShapeTag>::NUM_POINTS <= MAX_POINTS));
VTKM_THIRDPARTY_POST_INCLUDE
VTKM_STATIC_ASSERT((vtkm::CellTraits<CellShapeTag>::NUM_POINTS <= MAX_POINTS));
minPoints = maxPoints = vtkm::CellTraits<CellShapeTag>::NUM_POINTS;
}
......
......@@ -22,6 +22,7 @@
#include <vtkm/exec/ParametricCoordinates.h>
#include <vtkm/CellTraits.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/VecVariable.h>
#include <vtkm/testing/Testing.h>
......@@ -29,7 +30,6 @@
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_real_distribution.hpp>
#include <boost/static_assert.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
#include <time.h>
......@@ -48,9 +48,7 @@ void GetMinMaxPoints(CellShapeTag,
{
// If this line fails, then MAX_POINTS is not large enough to support all
// cell shapes.
VTKM_THIRDPARTY_PRE_INCLUDE
BOOST_STATIC_ASSERT((vtkm::CellTraits<CellShapeTag>::NUM_POINTS <= MAX_POINTS));
VTKM_THIRDPARTY_POST_INCLUDE
VTKM_STATIC_ASSERT((vtkm::CellTraits<CellShapeTag>::NUM_POINTS <= MAX_POINTS));
minPoints = maxPoints = vtkm::CellTraits<CellShapeTag>::NUM_POINTS;
}
......
......@@ -22,14 +22,11 @@
#define vtk_m_internal_ConnectivityStructuredInternals_h
#include <vtkm/CellShape.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/TopologyElementTag.h>
#include <vtkm/Types.h>
#include <vtkm/VecVariable.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
namespace vtkm {
namespace internal {
......@@ -526,8 +523,8 @@ struct ConnectivityStructuredIndexHelper
// instantiated, because it means someone missed a topology mapping type.
// We need to create a test which depends on the templated types so
// it doesn't get picked up without a concrete instantiation.
BOOST_STATIC_ASSERT_MSG(sizeof(To) == static_cast<size_t>(-1),
"Missing Specialization for Topologies");
VTKM_STATIC_ASSERT_MSG(sizeof(To) == static_cast<size_t>(-1),
"Missing Specialization for Topologies");
};
template<vtkm::IdComponent Dimension>
......
......@@ -20,6 +20,8 @@
#ifndef vtk_m_worklet_internal_DispatcherBase_h
#define vtk_m_worklet_internal_DispatcherBase_h
#include <vtkm/StaticAssert.h>
#include <vtkm/internal/FunctionInterface.h>
#include <vtkm/internal/Invocation.h>
......@@ -38,7 +40,6 @@
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/utility/enable_if.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
......@@ -264,12 +265,10 @@ private:
const vtkm::internal::FunctionInterface<Signature> &parameters) const
{
typedef vtkm::internal::FunctionInterface<Signature> ParameterInterface;
VTKM_STATIC_ASSERT_MSG(ParameterInterface::ARITY == NUM_INVOKE_PARAMS,
"Dispatcher Invoke called with wrong number of arguments.");
VTKM_THIRDPARTY_PRE_INCLUDE
BOOST_STATIC_ASSERT_MSG(ParameterInterface::ARITY == NUM_INVOKE_PARAMS,
"Dispatcher Invoke called with wrong number of arguments.");
BOOST_MPL_ASSERT(( boost::is_base_of<BaseWorkletType,WorkletType> ));
VTKM_THIRDPARTY_POST_INCLUDE
// As we do the dynamic transform, we are also going to check the static
// type against the TypeCheckTag in the ControlSignature tags. To do this,
......
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