Skip to content
Snippets Groups Projects
Commit fee9d0e2 authored by Oliver Sander's avatar Oliver Sander
Browse files

Make MultiTypeBlockVector export 'size_type'

The dune-istl vector interface requires it.
parent ece43a78
No related branches found
No related tags found
1 merge request!346Add missing Multitypeblockvector size methods
......@@ -58,6 +58,9 @@ namespace Dune {
typedef std::tuple<Args...> TupleType;
public:
/** \brief Type used for vector sizes */
using size_type = std::size_t;
/**
* \brief Get the constructors from tuple
*/
......@@ -78,7 +81,7 @@ namespace Dune {
typedef double field_type;
/** \brief Return the number of vector entries */
static constexpr std::size_t size()
static constexpr size_type size()
{
return sizeof...(Args);
}
......@@ -109,9 +112,9 @@ namespace Dune {
* v[std::integral_constant<std::size_t,0>()] = ...
* \endcode
*/
template< std::size_t index >
template< size_type index >
typename std::tuple_element<index,TupleType>::type&
operator[] ( const std::integral_constant< std::size_t, index > indexVariable )
operator[] ( const std::integral_constant< size_type, index > indexVariable )
{
DUNE_UNUSED_PARAMETER(indexVariable);
return std::get<index>(*this);
......@@ -122,9 +125,9 @@ namespace Dune {
* This is the const version of the random-access operator. See the non-const version for a full
* explanation of how to use it.
*/
template< std::size_t index >
template< size_type index >
const typename std::tuple_element<index,TupleType>::type&
operator[] ( const std::integral_constant< std::size_t, index > indexVariable ) const
operator[] ( const std::integral_constant< size_type, index > indexVariable ) const
{
DUNE_UNUSED_PARAMETER(indexVariable);
return std::get<index>(*this);
......
......@@ -25,6 +25,10 @@ using namespace Dune;
template<typename... Args>
void testMultiVector(const MultiTypeBlockVector<Args...>& multiVector)
{
// Test whether the vector exports 'size_type', and whether that is an integer
using size_type = typename MultiTypeBlockVector<Args...>::size_type;
static_assert(std::numeric_limits<size_type>::is_integer, "size_type is not an integer!");
// test operator<<
std::cout << multiVector << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment