Skip to content
Snippets Groups Projects
Commit 3a75f982 authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Add the TupleVector class from dune-functions to dune-solvers

Because it is useful, e.g., to handle the bit vectors corresponding to MultiTypeBlockVector
vectors.  The same class already exists in dune-functions, which may lead to confusion.
In the long run, both implementations should be replaced by a single one in a module
further upstream.
parent a1c95798
No related branches found
No related tags found
No related merge requests found
......@@ -11,4 +11,5 @@ install(FILES
preconditioner.hh
resize.hh
staticmatrixtools.hh
tuplevector.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/solvers/common)
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_SOLVERS_COMMON_TUPLEVECTOR_HH
#define DUNE_SOLVERS_COMMON_TUPLEVECTOR_HH
#include <tuple>
#include <dune/typetree/utility.hh>
namespace Dune
{
namespace Solvers
{
/**
* \brief A std::tuple that allows access to its element via operator[]
*/
template<class... T>
class TupleVector : public std::tuple<T...>
{
using Base = std::tuple<T...>;
public:
/** \brief Construct from a set of arguments */
template<class... TT>
constexpr TupleVector(TT&&... tt) :
Base(std::forward<TT>(tt)...)
{}
/** \brief Default constructor */
constexpr TupleVector()
{}
/** \brief Const access to the tuple elements */
template<std::size_t i>
auto operator[](const Dune::TypeTree::index_constant<i>&) const
->decltype(std::get<i>(*this))
{
return std::get<i>(*this);
}
/** \brief Non-const access to the tuple elements */
template<std::size_t i>
auto operator[](const Dune::TypeTree::index_constant<i>&)
->decltype(std::get<i>(*this))
{
return std::get<i>(*this);
}
/** \brief Number of elements of the tuple */
static constexpr std::size_t size()
{
return std::tuple_size<Base>::value;
}
};
} // namespace Functions
} // namespace Dune
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment