Skip to content
Snippets Groups Projects
Commit 05fef93d authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Add template alias ConstCopyOrReference

This adds constness to the stored copy or reference.
Notice that simply using CopyOrReference<const T> for
ConstCopyOrReference<T> does not work since 'const T'
is the same as T for reference types because all references
are const.
parent 3c2d0b9a
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -17,7 +17,7 @@ namespace Solvers {
/**
* \brief A wrapper storing either a copy or reference
*
* \tparam T Type to be refered to
* \tparam T Type to be stored
*
* If T is of reference type, the wrapper stores a reference
* to the passed object. Otherwise it stores a copy.
......@@ -114,6 +114,27 @@ private:
/**
* \brief A wrapper storing either a const copy or const reference
*
* \tparam T Type to be stored
*
* This is an alias for CopyOrReference<TT> where TT
* is either 'const T' if T is a raw type or 'const S&'
* if T is a 'S&'. Notice that in the latter case this
* is different from 'const T' which would be the same
* as T.
*/
template<class T>
using ConstCopyOrReference =
CopyOrReference<
std::conditional_t<
std::is_reference<T>::value,
const std::remove_reference_t<T>&,
const T>>;
} // end namespace Solvers
} // end namespace Dune
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment