Commit f6e18ac4 authored by Robert Maynard's avatar Robert Maynard
Browse files

Remove IntegerSequence.h as we don't need it in vtk-m anymore

parent 7f762204
......@@ -56,7 +56,6 @@ set(headers
FunctionInterfaceDetailPost.h
FunctionInterfaceDetailPre.h
IndexTag.h
IntegerSequence.h
Invocation.h
ListTagDetail.h
Unreachable.h
......
//============================================================================
// 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 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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_internal_IntegerSequence_h
#define vtk_m_internal_IntegerSequence_h
#include <cstdlib>
namespace vtkm
{
namespace internal
{
/// \brief A container of unsigned integers
///
/// C++11 Doesn't provide an IntegerSequence class and helper constructor
// So we need to roll our own. This class has been tested up to 512 elements.
//
template <int...>
struct IntegerSequence
{
};
namespace detail
{
template <int N, int... Is> //unroll in blocks of 4
struct MakeSeq /** @cond */ : MakeSeq<N - 4, N - 3, N - 2, N - 1, N, Is...> /** @endcond */
{
//The cond/endcond are used to tell doxygen to ignore the inheritance, as that
//builds a massive inheritance tree
};
template <int... Is>
struct MakeSeq<0, 1, 2, 3, Is...> //termination case
{
using type = IntegerSequence<0, 1, 2, 3, Is...>;
};
template <int Mod, int N>
struct PreMakeSeq : MakeSeq<N - 3, N - 2, N - 1, N>
{
};
template <int N> //specialization for value +1 to divisible by 4
struct PreMakeSeq<1, N> : MakeSeq<N>
{
};
template <int N> //specialization for value +2 to divisible by 4
struct PreMakeSeq<2, N> : MakeSeq<N - 1, N>
{
};
template <int N> //specialization for value +3 to divisible by 4
struct PreMakeSeq<3, N> : MakeSeq<N - 2, N - 1, N>
{
};
template <> //specialization for 4
struct PreMakeSeq<4, 3>
{
using type = IntegerSequence<0, 1, 2, 3>;
};
template <> //specialization for 3
struct PreMakeSeq<3, 2>
{
using type = IntegerSequence<0, 1, 2>;
};
template <> //specialization for 2
struct PreMakeSeq<2, 1>
{
using type = IntegerSequence<0, 1>;
};
template <> //specialization for 1
struct PreMakeSeq<1, 0>
{
using type = IntegerSequence<0>;
};
template <> //specialization for 0
struct PreMakeSeq<0, -1>
{
using type = IntegerSequence<>;
};
} //namespace detail
/// \brief A helper method to create an Integer sequence of 0...N-1.
template <int N>
struct MakeIntegerSequence /** @cond */ : detail::PreMakeSeq<N % 4, N - 1> /** @endcond */
{
//The cond/endcond are used to tell doxygen to ignore the inheritance, as that
//builds a massive inheritance tree
};
}
}
#endif //vtk_m_internal_IntegerSequence_h
......@@ -23,6 +23,5 @@ set(unit_tests
UnitTestConfigureFor32.cxx
UnitTestConfigureFor64.cxx
UnitTestFunctionInterface.cxx
UnitTestIntegerSequence.cxx
)
vtkm_unit_tests(SOURCES ${unit_tests})
//============================================================================
// 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 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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.
//============================================================================
#include <vtkm/internal/IntegerSequence.h>
#include <vtkm/testing/Testing.h>
#include <vector>
namespace
{
template <std::size_t Len, int... Ts>
void verify_correct_length(vtkm::internal::IntegerSequence<Ts...>)
{
static_assert(Len == sizeof...(Ts), "Incorrect length");
//use a runtime time to verify the contents of the integer sequence
//are 0...N-1
std::vector<int> container = { Ts... };
for (std::size_t i = 0; i < Len; ++i)
{
VTKM_TEST_ASSERT(container[i] == static_cast<int>(i), "Incorrect value");
}
}
void IntegerSequenceSizes()
{
using zero = vtkm::internal::MakeIntegerSequence<0>::type;
using one = vtkm::internal::MakeIntegerSequence<1>::type;
using two = vtkm::internal::MakeIntegerSequence<2>::type;
using four = vtkm::internal::MakeIntegerSequence<4>::type;
using thirty_two = vtkm::internal::MakeIntegerSequence<32>::type;
using thirty_three = vtkm::internal::MakeIntegerSequence<33>::type;
using thirty_four = vtkm::internal::MakeIntegerSequence<34>::type;
using thirty_five = vtkm::internal::MakeIntegerSequence<35>::type;
using two_fifty_six = vtkm::internal::MakeIntegerSequence<256>::type;
using five_twelve = vtkm::internal::MakeIntegerSequence<512>::type;
verify_correct_length<0>(zero());
verify_correct_length<1>(one());
verify_correct_length<2>(two());
verify_correct_length<4>(four());
verify_correct_length<32>(thirty_two());
verify_correct_length<33>(thirty_three());
verify_correct_length<34>(thirty_four());
verify_correct_length<35>(thirty_five());
verify_correct_length<256>(two_fifty_six());
verify_correct_length<512>(five_twelve());
}
}
int UnitTestIntegerSequence(int, char* [])
{
return vtkm::testing::Testing::Run(IntegerSequenceSizes);
}
......@@ -36,7 +36,6 @@
#include <vtkm/exec/arg/ExecutionSignatureTagBase.h>
// #include <vtkm/internal/IntegerSequence.h>
#include <vtkm/internal/brigand.hpp>
#include <sstream>
......
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