Commit 9eca9be7 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot
Browse files

Merge topic 'prefer_constexpr_over_const'

7c54125b

 Switch over from static const to static constexpr where possible.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1097
parents 1bd74413 7c54125b
......@@ -30,7 +30,7 @@
namespace
{
static const vtkm::Id ARRAY_SIZE = 10;
static constexpr vtkm::Id ARRAY_SIZE = 10;
template <typename PortalType>
struct TestKernelInOut : public vtkm::exec::FunctorBase
......
......@@ -31,7 +31,7 @@
namespace
{
static const vtkm::Id ARRAY_SIZE = 10;
static constexpr vtkm::Id ARRAY_SIZE = 10;
template <typename PortalType>
struct TestKernelOut : public vtkm::exec::FunctorBase
......
......@@ -34,7 +34,7 @@
namespace
{
static const vtkm::Id ARRAY_SIZE = 10;
static constexpr vtkm::Id ARRAY_SIZE = 10;
#define OFFSET 10
......
......@@ -430,7 +430,7 @@ public:
// Don't bother with the keys_output if it's an ArrayHandleDiscard -- there
// will be a runtime exception in Unique() otherwise:
if (!vtkm::cont::IsArrayHandleDiscard<KeysOutputType>::Value)
if (!vtkm::cont::IsArrayHandleDiscard<KeysOutputType>::value)
{
//find all the unique keys
DerivedAlgorithm::Copy(keys, keys_output);
......
......@@ -47,7 +47,7 @@ struct DeviceAdapterTraits;
template <typename DeviceAdapter>
struct DeviceAdapterTagCheck
{
static const bool Valid = false;
static constexpr bool Valid = false;
};
}
}
......@@ -68,12 +68,12 @@ struct DeviceAdapterTagCheck
{ \
static DeviceAdapterId GetId() { return DeviceAdapterId(Id); } \
static DeviceAdapterNameType GetName() { return DeviceAdapterNameType(#Name); } \
static const bool Valid = true; \
static constexpr bool Valid = true; \
}; \
template <> \
struct DeviceAdapterTagCheck<vtkm::cont::DeviceAdapterTag##Name> \
{ \
static const bool Valid = true; \
static constexpr bool Valid = true; \
}; \
} \
}
......@@ -94,12 +94,12 @@ struct DeviceAdapterTagCheck
{ \
static DeviceAdapterId GetId() { return DeviceAdapterId(Id); } \
static DeviceAdapterNameType GetName() { return DeviceAdapterNameType(#Name); } \
static const bool Valid = false; \
static constexpr bool Valid = false; \
}; \
template <> \
struct DeviceAdapterTagCheck<vtkm::cont::DeviceAdapterTag##Name> \
{ \
static const bool Valid = false; \
static constexpr bool Valid = false; \
}; \
} \
}
......
......@@ -29,7 +29,7 @@ namespace
template <typename T>
struct TemplatedTests
{
static const vtkm::Id ARRAY_SIZE = 10;
static constexpr vtkm::Id ARRAY_SIZE = 10;
using ValueType = T;
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
......@@ -76,7 +76,7 @@ struct TemplatedTests
{
ValueType array[ARRAY_SIZE];
static const ComponentType ORIGINAL_VALUE = 109;
constexpr ComponentType ORIGINAL_VALUE = 109;
FillIterator(array, array + ARRAY_SIZE, ORIGINAL_VALUE);
::vtkm::cont::internal::ArrayPortalFromIterators<ValueType*> portal(array, array + ARRAY_SIZE);
......@@ -124,7 +124,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(CheckPortal(const_portal, ORIGINAL_VALUE),
"Const portal iterator has bad value.");
static const ComponentType SET_VALUE = 62;
constexpr ComponentType SET_VALUE = 62;
std::cout << " Check get/set methods." << std::endl;
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
......
......@@ -39,7 +39,7 @@ namespace vtkm
template <>
struct VecTraits<std::string>
{
static const vtkm::IdComponent NUM_COMPONENTS = 1;
static constexpr vtkm::IdComponent NUM_COMPONENTS = 1;
using HasMultipleComponents = vtkm::VecTraitsTagSingleComponent;
};
......
......@@ -31,7 +31,7 @@ namespace
template <typename T>
struct TemplatedTests
{
static const vtkm::Id ARRAY_SIZE = 10;
static constexpr vtkm::Id ARRAY_SIZE = 10;
using ValueType = T;
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
......
......@@ -50,7 +50,7 @@ void DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagTBB>::ScheduleTask(
vtkm::exec::tbb::internal::TaskTiling3D& functor,
vtkm::Id3 size)
{
static const vtkm::UInt32 TBB_GRAIN_SIZE_3D[3] = { 1, 4, 256 };
static constexpr vtkm::UInt32 TBB_GRAIN_SIZE_3D[3] = { 1, 4, 256 };
const vtkm::Id MESSAGE_SIZE = 1024;
char errorString[MESSAGE_SIZE];
errorString[0] = '\0';
......
......@@ -88,7 +88,7 @@ using WrappedBinaryOperator = vtkm::cont::internal::WrappedBinaryOperator<Result
// The "grain size" of scheduling with TBB. Not a lot of thought has gone
// into picking this size.
static const vtkm::Id TBB_GRAIN_SIZE = 1024;
static constexpr vtkm::Id TBB_GRAIN_SIZE = 1024;
template <typename InputPortalType, typename OutputPortalType>
struct CopyBody
......
......@@ -686,7 +686,7 @@ private:
size_t max_elems_;
int max_threads_;
static const size_t kOutBufferSize = internal::kOutBufferSize;
static constexpr size_t kOutBufferSize = internal::kOutBufferSize;
ValueType *original_, *tmp_;
ValueType *src_, *dst_;
ValueType*** out_buf_;
......
......@@ -72,7 +72,7 @@ class quick_sort_range : private no_assign
}
public:
static const size_t grainsize = 500;
static constexpr size_t grainsize = 500;
const Compare& comp;
RandomAccessIterator begin;
size_t size;
......
......@@ -31,17 +31,17 @@
namespace kx
{
static const int kRadixBits = 8;
static const size_t kInsertSortThreshold = 64;
static const int kRadixMask = (1 << kRadixBits) - 1;
static const int kRadixBin = 1 << kRadixBits;
static constexpr int kRadixBits = 8;
static constexpr size_t kInsertSortThreshold = 64;
static constexpr int kRadixMask = (1 << kRadixBits) - 1;
static constexpr int kRadixBin = 1 << kRadixBits;
//================= HELPING FUNCTIONS ====================
template <class T>
struct RadixTraitsUnsigned
{
static const int nBytes = sizeof(T);
static constexpr int nBytes = sizeof(T);
int kth_byte(const T& x, int k) { return (x >> (kRadixBits * k)) & kRadixMask; }
bool compare(const T& x, const T& y) { return x < y; }
};
......@@ -49,7 +49,7 @@ struct RadixTraitsUnsigned
template <class T>
struct RadixTraitsSigned
{
static const int nBytes = sizeof(T);
static constexpr int nBytes = sizeof(T);
static const T kMSB = T(0x80) << ((sizeof(T) - 1) * 8);
int kth_byte(const T& x, int k) { return ((x ^ kMSB) >> (kRadixBits * k)) & kRadixMask; }
bool compare(const T& x, const T& y) { return x < y; }
......
......@@ -322,7 +322,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet0()
dataSet.AddField(make_Field(
"cellvar", vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 4, vtkm::CopyFlag::On));
static const vtkm::IdComponent dim = 3;
static constexpr vtkm::IdComponent dim = 3;
vtkm::cont::CellSetStructured<dim> cellSet("cells");
cellSet.SetPointDimensions(vtkm::make_Vec(3, 2, 3));
dataSet.AddCellSet(cellSet);
......@@ -349,7 +349,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet1()
dataSet.AddField(make_Field(
"cellvar", vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 1, vtkm::CopyFlag::On));
static const vtkm::IdComponent dim = 3;
static constexpr vtkm::IdComponent dim = 3;
vtkm::cont::CellSetStructured<dim> cellSet("cells");
cellSet.SetPointDimensions(vtkm::make_Vec(2, 2, 2));
dataSet.AddCellSet(cellSet);
......
......@@ -75,7 +75,7 @@ private:
static void TestAll()
{
using PointType = vtkm::Vec<vtkm::FloatDefault, 3>;
static const vtkm::Id length = 64;
static constexpr vtkm::Id length = 64;
vtkm::cont::ArrayHandle<PointType> out;
......
......@@ -132,7 +132,7 @@ struct TestingArrayHandles
};
private:
static const vtkm::Id ARRAY_SIZE = 100;
static constexpr vtkm::Id ARRAY_SIZE = 100;
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>;
......
......@@ -31,7 +31,7 @@ namespace
// need to ensure we instatiate each algorithm in a source
// file to verify compilation.
//
static const vtkm::Id ARRAY_SIZE = 10;
static constexpr vtkm::Id ARRAY_SIZE = 10;
void CopyTest()
{
......
......@@ -28,7 +28,7 @@
namespace
{
static const vtkm::Id ARRAY_SIZE = 10;
static constexpr vtkm::Id ARRAY_SIZE = 10;
template <typename PortalType>
void TestValues(const PortalType& portal)
......
......@@ -38,8 +38,8 @@ namespace UnitTestArrayHandleDiscardDetail
template <typename ValueType>
struct Test
{
static const vtkm::Id ARRAY_SIZE = 100;
static const vtkm::Id NUM_KEYS = 3;
static constexpr vtkm::Id ARRAY_SIZE = 100;
static constexpr vtkm::Id NUM_KEYS = 3;
using DeviceTag = vtkm::cont::DeviceAdapterTagSerial;
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceTag>;
......
......@@ -30,7 +30,7 @@ namespace
template <typename T>
struct TemplatedTests
{
static const vtkm::Id ARRAY_SIZE = 10;
static constexpr vtkm::Id ARRAY_SIZE = 10;
using ValueType = T;
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
......
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