4#ifndef DUNE_COMMON_PARALLEL_MPIDATA_HH
5#define DUNE_COMMON_PARALLEL_MPIDATA_HH
13#include <dune/common/std/type_traits.hh>
37 template<
class,
class =
void>
41 auto getMPIData(T& t){
46 template<
class T,
class Enable>
49 friend auto getMPIData<T>(T&);
63 static constexpr bool static_size =
true;
69 MPI_Datatype type()
const {
70 return MPITraits<std::decay_t<T>>::getType();
88 MPI_Datatype type()
const{
96 struct MPIData<T,
void_t<
std::tuple<decltype(std::declval<T>().data()),
97 decltype(std::declval<T>().size()),
98 typename std::decay_t<T>::value_type>>>{
101 using hasResizeOp =
decltype(std::declval<U>().resize(0));
104 friend auto getMPIData<T>(T&);
109 static constexpr bool static_size = std::is_const<T>::value || !Std::is_detected_v<hasResizeOp, T>;
111 return (
void*) data_.data();
116 MPI_Datatype type()
const{
117 return MPITraits<typename std::decay_t<T>::value_type>::getType();
120 template<
class S = T>
121 auto resize(
int size)
122 -> std::enable_if_t<!std::is_const<S>::value || !Std::is_detected_v<hasResizeOp, S>>
Traits for type conversions and type information.
typename Impl::voider< Types... >::type void_t
Is void for all valid input types (see N3911). The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
Traits classes for mapping types onto MPI_Datatype.
Dune namespace.
Definition: alignedallocator.hh:14