Skip to content
Snippets Groups Projects
Commit 77f04bbf authored by Tobias Leibner's avatar Tobias Leibner
Browse files

Merge branch 'make-functions-copyable' of...

Merge branch 'make-functions-copyable' of zivgitlab.uni-muenster.de:ag-ohlberger/dune-community/dune-xt into fix_compilation_with_icc
parents 12e1fc3b b468e030
No related branches found
No related tags found
1 merge request!41Fix compilation with icc, several other changes
Checking pipeline status
...@@ -370,7 +370,7 @@ using tuple_tail_t = typename list_content<T1>::tail; ...@@ -370,7 +370,7 @@ using tuple_tail_t = typename list_content<T1>::tail;
/** These classes allow recursively visiting a typelist that may contain templates names /** These classes allow recursively visiting a typelist that may contain templates names
* So if you ever wanted to iterate over "AllDirichletBoundaryInfo, AllNeumannBoundaryInfo, etc" * So if you ever wanted to iterate over "AllDirichletBoundaryInfo, AllNeumannBoundaryInfo, etc"
* and then input another type as tpl arg, sthis is for you. * and then input another type as tpl arg, this is for you.
* *
* **/ * **/
...@@ -448,9 +448,23 @@ public: ...@@ -448,9 +448,23 @@ public:
using head_type = typename internal::head_hlp<tuple_head_t<type<T...>>>::type; using head_type = typename internal::head_hlp<tuple_head_t<type<T...>>>::type;
}; };
template <typename Head, typename... Tail>
struct list_content<template_tuple<Head, Tail...>>
{
template <class... Parameters>
using head = typename internal::from_tplwrap<Head, Parameters...>::type;
using tail = template_tuple<Tail...>;
};
using null_template_tuple = template_tuple<Dune::XT::Common::tuple_null_type>; template <typename T>
struct list_content<template_tuple<T>>
{
template <class... Parameters>
using head = typename internal::from_tplwrap<T, Parameters...>::type;
using tail = tuple_null_type;
};
using null_template_tuple = template_tuple<Dune::XT::Common::tuple_null_type>;
template <typename... input_t> template <typename... input_t>
using tuple_cat_t = decltype(std::tuple_cat(std::declval<input_t>()...)); using tuple_cat_t = decltype(std::tuple_cat(std::declval<input_t>()...));
...@@ -459,4 +473,12 @@ using tuple_cat_t = decltype(std::tuple_cat(std::declval<input_t>()...)); ...@@ -459,4 +473,12 @@ using tuple_cat_t = decltype(std::tuple_cat(std::declval<input_t>()...));
} // namespace XT } // namespace XT
} // namespace Dune } // namespace Dune
namespace std {
//! specialization for our custom tuple tuple_size can be use on it
template <class... Types>
class tuple_size<Dune::XT::Common::template_tuple<Types...>>
: public std::integral_constant<std::size_t, sizeof...(Types)>
{};
} // namespace std
#endif // DUNE_XT_COMMON_TUPLE_HH #endif // DUNE_XT_COMMON_TUPLE_HH
...@@ -80,14 +80,22 @@ struct tplB ...@@ -80,14 +80,22 @@ struct tplB
template <class Tuple> template <class Tuple>
void type_call() void type_call()
{ {
using TupleElement = typename Dune::XT::Common::list_content<Tuple>::template head<int, int>; if constexpr (std::tuple_size_v<Tuple> == 3) {
using Type = typename TupleElement::type; using TupleElement = typename Dune::XT::Common::list_content<Tuple>::template head<int, int>;
static_assert(std::is_same<Type, int>::value, ""); using Type = typename TupleElement::type;
using Tail = typename Tuple::template tail_type<int, int>; static_assert(std::is_same<TupleElement, tplA<int, int>>::value, "");
static_assert(std::is_same<Type, int>::value, "");
} else if constexpr (std::tuple_size_v<Tuple> == 2) {
using TupleElement = typename Dune::XT::Common::list_content<Tuple>::template head<int, int>;
using Type = typename TupleElement::type;
static_assert(std::is_same<TupleElement, tplB<int, int>>::value, "");
static_assert(std::is_same<Type, int>::value, "");
} else if constexpr (std::tuple_size_v<Tuple> == 1) {
using TupleElement = typename Dune::XT::Common::list_content<Tuple>::template head<int, int>;
static_assert(std::is_same<TupleElement, int>::value, "");
}
// do something meaningful with a single type using Tail = typename Tuple::template tail_type<int, int>;
EXPECT_EQ(Type(0), int(0));
EXPECT_EQ(Type(0.2), int(0.2));
type_call<Tail>(); type_call<Tail>();
} }
......
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